diff --git a/docs.json b/docs.json index 278cc8de..7aeceb86 100644 --- a/docs.json +++ b/docs.json @@ -381,6 +381,7 @@ "integrations/ai-apps", "integrations/libraries/anythingllm", "integrations/libraries/claude-code", + "integrations/libraries/anthropic-computer-use", "integrations/libraries/cline", "integrations/libraries/goose", "integrations/libraries/janhq", @@ -788,6 +789,13 @@ { "tab": "Cookbook", "groups": [ + { + "group": "Evals", + "pages": [ + "guides/use-cases/run-batch-evals", + "guides/prompts/llm-as-a-judge" + ] + }, { "group": "Prompt Engineering", "pages": [ @@ -855,7 +863,6 @@ "pages": [ "guides/use-cases", "guides/use-cases/librechat-web-search", - "guides/use-cases/run-batch-evals", "guides/use-cases/few-shot-prompting", "guides/use-cases/enforcing-json-schema-with-anyscale-and-together", "guides/use-cases/emotions-with-gpt-4o", diff --git a/integrations/libraries.mdx b/integrations/libraries.mdx index 05b5eb09..888b0f75 100644 --- a/integrations/libraries.mdx +++ b/integrations/libraries.mdx @@ -13,6 +13,8 @@ title: "Overview" + + diff --git a/integrations/libraries/anthropic-computer-use.mdx b/integrations/libraries/anthropic-computer-use.mdx new file mode 100644 index 00000000..f21b0c02 --- /dev/null +++ b/integrations/libraries/anthropic-computer-use.mdx @@ -0,0 +1,296 @@ +--- +title: "Anthropic Computer Use" +--- + +Anthropic computer use is fully supported in Portkey. +For more information on the computer use tool, please refer to the [Anthropic documentation](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/computer-use-tool). + + +### Usage + + ```py Python + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", # Replace with your Portkey API key + virtual_key="VIRTUAL_KEY", + strict_open_ai_compliance="false" + + + ) + + # Create the request + response = portkey.chat.completions.create( + anthropic_beta="computer-use-2025-01-24", + model="claude-opus-4-20250514", + max_tokens=3000, + thinking={ + "type": "enabled", + "budget_tokens": 2030 + }, + stream=False, + + tools=[ + { + "type": "computer", + "computer": { + "name": "computer_20250124", + "display_width_px": 1024, + "display_height_px": 768, + "display_number": 1, + } + }, + { + "type": "text_editor_20250429", + "name": "str_replace_based_edit_tool" + }, + { + "type": "bash_20250124", + "name": "bash" + } + ], + messages=[ + { + "role": "user", + "content": "Save a picture of a cat to my desktop." + } + ] + ) + print(response) + ``` + ```ts NodeJS + import Portkey from 'portkey-ai'; + + // Initialize the Portkey client + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", // Replace with your Portkey API key + virtualKey: "VIRTUAL_KEY", // Add your anthropic's virtual key + strictOpenAiCompliance: false + }); + + // Generate a chat completion + async function getChatCompletionFunctions() { + const response = await portkey.chat.completions.create({ + model: "claude-4-opus-20250514", + anthropic_beta: "computer-use-2025-01-24", + max_tokens: 3000, + thinking: { + type: "enabled", + budget_tokens: 2030 + }, + stream: false, + tools: [ + { + type: "computer", + computer: { + name: "computer_20250124", // This is the version of the tool + display_width_px: 1024, + display_height_px: 768, + display_number: 1 + } + }, + { + type: "text_editor_20250429", + name: "str_replace_based_edit_tool" + }, + { + type: "bash_20250124", + name: "bash" + } + ], + "messages": [ + { + role: "user", + content: "Save a picture of a cat to my desktop." + } + ] + }); + console.log(response); + } + // Call the function + getChatCompletionFunctions(); + ``` + ```sh cURL + curl "https://api.portkey.ai/v1/chat/completions" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-provider: anthropic" \ + -H "x-api-key: $ANTHROPIC_API_KEY" \ + -H "x-portkey-strict-open-ai-compliance: false" \ + -d '{ + "model": "claude-4-opus-20250514", + "anthropic_beta": "computer-use-2025-01-24", + "max_tokens": 3000, + "thinking": { + "type": "enabled", + "budget_tokens": 2030 + }, + "stream": false, + "tools": [ + { + "type": "computer", + "computer": { + "name": "computer_20250124", + "display_width_px": 1024, + "display_height_px": 768, + "display_number": 1 + } + }, + { + "type": "text_editor_20250429", + "name": "str_replace_based_edit_tool" + }, + { + "type": "bash_20250124", + "name": "bash" + } + ], + "messages": [ + { + "role": "user", + "content": "Save a picture of a cat to my desktop." + } + ] + }' + ``` + + + + + + +# Portkey Features +Now that you have enterprise-grade Anthropic Computer Use setup, let's explore the comprehensive features Portkey provides to ensure secure, efficient, and cost-effective AI-assisted development. + +### 1. Comprehensive Metrics +Using Portkey you can track 40+ key metrics including cost, token usage, response time, and performance across all your LLM providers in real time. Filter these metrics by developer, team, or project using custom metadata. + + + + + +### 2. Advanced Logs +Portkey's logging dashboard provides detailed logs for every request made by Anthropic Computer Use. These logs include: +- Complete request and response tracking +- Code context and generation metrics +- Developer attribution +- Cost breakdown per coding session + + + + + +### 3. Unified Access to 250+ LLMs + +Easily switch between 250+ LLMs for different coding tasks. Use GPT-4 for complex architecture decisions, Claude for detailed code reviews, or specialized models for specific languages - all through a single interface. + +### 4. Advanced Metadata Tracking +Track coding patterns and productivity metrics with custom metadata: +- Language and framework usage +- Code generation vs completion tasks +- Time-of-day productivity patterns +- Project-specific metrics + + + + +### 5. Enterprise Access Management + + + +Set and manage spending limits per developer or team. Prevent budget overruns with automatic cutoffs. + + + +Enterprise-grade SSO integration for seamless developer onboarding and offboarding. + + + +Hierarchical structure with teams, projects, and role-based access control for development organizations. + + + +Comprehensive audit logging for security compliance and code generation tracking. + + + +### 6. Reliability Features + + + Automatically switch between models if one fails, ensuring uninterrupted coding. + + + Route requests based on code complexity or language requirements. + + + Distribute requests across multiple API keys or providers. + + + Cache common code patterns to reduce costs and improve response times. + + + Automatic retry handling for failed requests with exponential backoff. + + + Enforce spending limits to control development costs. + + + +### 7. Advanced Guardrails + +Protect your codebase and enhance security with real-time checks on AI interactions: +- Prevent exposure of API keys and secrets +- Block generation of malicious code patterns +- Enforce coding standards and best practices +- Custom security rules for your organization +- License compliance checks + + +Implement real-time protection for your development environment with automatic detection and filtering of sensitive code, credentials, and security vulnerabilities. + + +# FAQs + + + +Portkey provides several ways to track developer costs: +- Create separate Virtual Keys for each developer +- Use metadata tags to identify developers +- Set up developer-specific API keys +- View detailed analytics in the dashboard + + + +When a developer reaches their budget limit: +1. Further requests will be blocked +2. The developer and admin receive notifications +3. Coding history remains available +4. Admins can adjust limits as needed + + + +Yes! Portkey supports local models through Ollama and other self-hosted solutions. Configure your local endpoint as a custom provider in Portkey and use it with Anthropic Computer Use just like any other provider. + + + +Portkey provides multiple security layers: +- Guardrails to prevent sensitive data exposure +- Request/response filtering +- Audit logs for all interactions +- Custom security rules +- PII detection and masking + + + +# Next Steps + +**Join our Community** +- [Discord Community](https://portkey.sh/discord-report) +- [GitHub Repository](https://github.com/Portkey-AI) + + + + +For enterprise support and custom features for your development teams, contact our [enterprise team](https://calendly.com/portkey-ai). + diff --git a/integrations/libraries/autogen.mdx b/integrations/libraries/autogen.mdx index 49c2783d..1d5e5e78 100644 --- a/integrations/libraries/autogen.mdx +++ b/integrations/libraries/autogen.mdx @@ -1,8 +1,14 @@ --- -title: "Autogen" +title: "Autogen (DEPRECATED)" description: "AutoGen is a framework that enables the development of LLM applications using multiple agents that can converse with each other to solve tasks." --- + + +Click here to check out the latest integration of Autogen with Portkey + + + diff --git a/integrations/llms/anthropic/computer-use.mdx b/integrations/llms/anthropic/computer-use.mdx index c9b55e09..8cc0dc89 100644 --- a/integrations/llms/anthropic/computer-use.mdx +++ b/integrations/llms/anthropic/computer-use.mdx @@ -1,258 +1,4 @@ --- -title: "Computer use tool" +title: Computer use tool +url: /integrations/libraries/anthropic-computer-use --- - -Anthropic computer use is fully supported in Portkey. -For more information on the computer use tool, please refer to the [Anthropic documentation](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/computer-use-tool). - - -### Usage - - ```py Python - from portkey_ai import Portkey - - # Initialize the Portkey client - portkey = Portkey( - api_key="PORTKEY_API_KEY", # Replace with your Portkey API key - virtual_key="VIRTUAL_KEY", # Add your provider's virtual key - ) - - # Create the request - response = portkey.chat.completions.create( - model="claude-4-opus-20250514", - max_tokens=3000, - thinking={ - "type": "enabled", - "budget_tokens": 2030 - }, - stream=False, - tools=[ - { - type: "computer", - computer: { - name: "computer_20250124", # This is the version of the tool - display_width_px: 1024, - display_height_px: 768, - display_number: 1 - } - }, - { - type: "text_editor_20250429", - name: "str_replace_based_edit_tool" - }, - { - type: "bash_20250124", - name: "bash" - } - ], - messages=[ - { - role: "user", - content: "Save a picture of a cat to my desktop." - } - ] - ) - print(response) - - ``` - ```ts NodeJS - import Portkey from 'portkey-ai'; - - // Initialize the Portkey client - const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", // Replace with your Portkey API key - virtualKey: "VIRTUAL_KEY", // Add your anthropic's virtual key - strictOpenAiCompliance: false - }); - - // Generate a chat completion - async function getChatCompletionFunctions() { - const response = await portkey.chat.completions.create({ - model: "claude-4-opus-20250514", - max_tokens: 3000, - thinking: { - type: "enabled", - budget_tokens: 2030 - }, - stream: false, - tools: [ - { - type: "computer", - computer: { - name: "computer_20250124", // This is the version of the tool - display_width_px: 1024, - display_height_px: 768, - display_number: 1 - } - }, - { - type: "text_editor_20250429", - name: "str_replace_based_edit_tool" - }, - { - type: "bash_20250124", - name: "bash" - } - ], - "messages": [ - { - role: "user", - content: "Save a picture of a cat to my desktop." - } - ] - }); - console.log(response); - } - // Call the function - getChatCompletionFunctions(); - ``` - ```js OpenAI NodeJS - import OpenAI from 'openai'; - import { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai' - - const openai = new OpenAI({ - apiKey: 'ANTHROPIC_API_KEY', // defaults to process.env["OPENAI_API_KEY"], - baseURL: PORTKEY_GATEWAY_URL, - defaultHeaders: createHeaders({ - provider: "anthropic", - apiKey: "PORTKEY_API_KEY", // defaults to process.env["PORTKEY_API_KEY"] - strictOpenAiCompliance: false - }) - }); - - // Generate a chat completion with streaming - async function getChatCompletionFunctions(){ - const response = await openai.chat.completions.create({ - model: "claude-4-opus-20250514", - max_tokens: 3000, - thinking: { - type: "enabled", - budget_tokens: 2030 - }, - stream: false, - tools: [ - { - type: "computer", - computer: { - name: "computer_20250124", // This is the version of the tool - display_width_px: 1024, - display_height_px: 768, - display_number: 1 - } - }, - { - type: "text_editor_20250429", - name: "str_replace_based_edit_tool" - }, - { - type: "bash_20250124", - name: "bash" - } - ], - messages: [ - { - role: "user", - content: "Save a picture of a cat to my desktop." - } - ] - }); - - console.log(response) - } - await getChatCompletionFunctions(); - ``` - ```py OpenAI Python - from openai import OpenAI - from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders - - openai = OpenAI( - api_key='Anthropic_API_KEY', - base_url=PORTKEY_GATEWAY_URL, - default_headers=createHeaders( - provider="anthropic", - api_key="PORTKEY_API_KEY", - strict_open_ai_compliance=False - ) - ) - - - response = openai.chat.completions.create( - model="claude-4-opus-20250514", - max_tokens=3000, - thinking={ - "type": "enabled", - "budget_tokens": 2030 - }, - stream=False, - tools=[ - { - type: "computer", - computer: { - name: "computer_20250124", # This is the version of the tool - display_width_px: 1024, - display_height_px: 768, - display_number: 1 - } - }, - { - type: "text_editor_20250429", - name: "str_replace_based_edit_tool" - }, - { - type: "bash_20250124", - name: "bash" - } - ], - messages=[ - { - role: "user", - content: "Save a picture of a cat to my desktop." - } - ] - ) - - print(response) - ``` - ```sh cURL - curl "https://api.portkey.ai/v1/chat/completions" \ - -H "Content-Type: application/json" \ - -H "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-provider: anthropic" \ - -H "x-api-key: $ANTHROPIC_API_KEY" \ - -H "x-portkey-strict-open-ai-compliance: false" \ - -d '{ - "model": "claude-4-opus-20250514", - "max_tokens": 3000, - "thinking": { - "type": "enabled", - "budget_tokens": 2030 - }, - "stream": false, - "tools": [ - { - "type": "computer", - "computer": { - "name": "computer_20250124", - "display_width_px": 1024, - "display_height_px": 768, - "display_number": 1 - } - }, - { - "type": "text_editor_20250429", - "name": "str_replace_based_edit_tool" - }, - { - "type": "bash_20250124", - "name": "bash" - } - ], - "messages": [ - { - "role": "user", - "content": "Save a picture of a cat to my desktop." - } - ] - }' - ``` -