Skip to content

Commit af96ae7

Browse files
v3
1 parent 8c7ed49 commit af96ae7

File tree

4 files changed

+91
-148
lines changed

4 files changed

+91
-148
lines changed

images/supported-llm/lepton.png

20.8 KB
Loading

integrations/agents/openai-agents.mdx

Lines changed: 86 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,30 @@ set_default_openai_client(portkey)
685685
```
686686

687687

688+
689+
690+
**Filter Analytics by User**
691+
692+
With metadata in place, you can filter analytics by user and analyze performance metrics on a per-user basis:
693+
694+
<Frame caption="Filter analytics by user">
695+
<img src="/images/metadata-filters.png"/>
696+
</Frame>
697+
698+
699+
This enables:
700+
- Per-user cost tracking and budgeting
701+
- Personalized user analytics
702+
- Team or organization-level metrics
703+
- Environment-specific monitoring (staging vs. production)
704+
705+
<Card title="Learn More About Metadata" icon="tags" href="/product/observability/metadata">
706+
Explore how to use custom metadata to enhance your analytics
707+
</Card>
708+
709+
710+
711+
688712
### 6. Caching for Efficient Agents
689713

690714
Implement caching to make your OpenAI Agents agents more efficient and cost-effective:
@@ -737,25 +761,75 @@ Implement caching to make your OpenAI Agents agents more efficient and cost-effe
737761
</Tabs>
738762

739763

740-
**Filter Analytics by User**
741764

742-
With metadata in place, you can filter analytics by user and analyze performance metrics on a per-user basis:
743765

744-
<Frame caption="Filter analytics by user">
745-
<img src="/images/metadata-filters.png"/>
746-
</Frame>
766+
### 7. Model Interoperability
747767

768+
With Portkey, you can easily switch between different LLMs in your OpenAI Agents without changing your core agent logic.
748769

749-
This enables:
750-
- Per-user cost tracking and budgeting
751-
- Personalized user analytics
752-
- Team or organization-level metrics
753-
- Environment-specific monitoring (staging vs. production)
770+
```python
771+
# Configure Portkey with different LLM providers
772+
from portkey_ai import createHeaders, PORTKEY_GATEWAY_URL
773+
from openai import AsyncOpenAI
774+
from agents import set_default_openai_client
754775

755-
<Card title="Learn More About Metadata" icon="tags" href="/product/observability/metadata">
756-
Explore how to use custom metadata to enhance your analytics
776+
# Using OpenAI
777+
openai_config = {
778+
"provider": "openai",
779+
"api_key": "YOUR_OPENAI_API_KEY",
780+
"override_params": {
781+
"model": "gpt-4o"
782+
}
783+
}
784+
785+
# Using Anthropic
786+
anthropic_config = {
787+
"provider": "anthropic",
788+
"api_key": "YOUR_ANTHROPIC_API_KEY",
789+
"override_params": {
790+
"model": "claude-3-opus-20240229"
791+
}
792+
}
793+
794+
# Choose which config to use
795+
active_config = openai_config # or anthropic_config
796+
797+
# Configure OpenAI client with chosen provider
798+
portkey = AsyncOpenAI(
799+
base_url=PORTKEY_GATEWAY_URL,
800+
api_key=os.environ["PORTKEY_API_KEY"],
801+
default_headers=createHeaders(config=active_config)
802+
)
803+
set_default_openai_client(portkey)
804+
805+
# Create and run agent - no changes needed in agent code
806+
agent = Agent(
807+
name="Assistant",
808+
instructions="You are a helpful assistant.",
809+
# The model specified here will be used as a reference but the actual model
810+
# is determined by the active_config
811+
model="gpt-4o"
812+
)
813+
814+
result = Runner.run_sync(agent, "Tell me about quantum computing.")
815+
print(result.final_output)
816+
```
817+
818+
Portkey provides access to over 200 LLMs through a unified interface, including:
819+
820+
- OpenAI (GPT-4o, GPT-4 Turbo, etc.)
821+
- Anthropic (Claude 3.5 Sonnet, Claude 3 Opus, etc.)
822+
- Mistral AI (Mistral Large, Mistral Medium, etc.)
823+
- Google Vertex AI (Gemini 1.5 Pro, etc.)
824+
- Cohere (Command, Command-R, etc.)
825+
- AWS Bedrock (Claude, Titan, etc.)
826+
- Local/Private Models
827+
828+
<Card title="Supported Providers" icon="server" href="/integrations/llms">
829+
See the full list of LLM providers supported by Portkey
757830
</Card>
758831

832+
759833
## Tool Use in OpenAI Agents
760834

761835
OpenAI Agents SDK natively supports tools that enable your agents to interact with external systems and APIs. Portkey provides full observability for tool usage in your agents:
@@ -836,74 +910,6 @@ print(result.final_output)
836910

837911

838912

839-
## Model Interoperability
840-
841-
With Portkey, you can easily switch between different LLMs in your OpenAI Agents without changing your core agent logic.
842-
843-
```python
844-
# Configure Portkey with different LLM providers
845-
from portkey_ai import createHeaders, PORTKEY_GATEWAY_URL
846-
from openai import AsyncOpenAI
847-
from agents import set_default_openai_client
848-
849-
# Using OpenAI
850-
openai_config = {
851-
"provider": "openai",
852-
"api_key": "YOUR_OPENAI_API_KEY",
853-
"override_params": {
854-
"model": "gpt-4o"
855-
}
856-
}
857-
858-
# Using Anthropic
859-
anthropic_config = {
860-
"provider": "anthropic",
861-
"api_key": "YOUR_ANTHROPIC_API_KEY",
862-
"override_params": {
863-
"model": "claude-3-opus-20240229"
864-
}
865-
}
866-
867-
# Choose which config to use
868-
active_config = openai_config # or anthropic_config
869-
870-
# Configure OpenAI client with chosen provider
871-
portkey = AsyncOpenAI(
872-
base_url=PORTKEY_GATEWAY_URL,
873-
api_key=os.environ["PORTKEY_API_KEY"],
874-
default_headers=createHeaders(config=active_config)
875-
)
876-
set_default_openai_client(portkey)
877-
878-
# Create and run agent - no changes needed in agent code
879-
agent = Agent(
880-
name="Assistant",
881-
instructions="You are a helpful assistant.",
882-
# The model specified here will be used as a reference but the actual model
883-
# is determined by the active_config
884-
model="gpt-4o"
885-
)
886-
887-
result = Runner.run_sync(agent, "Tell me about quantum computing.")
888-
print(result.final_output)
889-
```
890-
891-
Portkey provides access to over 200 LLMs through a unified interface, including:
892-
893-
- OpenAI (GPT-4o, GPT-4 Turbo, etc.)
894-
- Anthropic (Claude 3.5 Sonnet, Claude 3 Opus, etc.)
895-
- Mistral AI (Mistral Large, Mistral Medium, etc.)
896-
- Google Vertex AI (Gemini 1.5 Pro, etc.)
897-
- Cohere (Command, Command-R, etc.)
898-
- AWS Bedrock (Claude, Titan, etc.)
899-
- Local/Private Models
900-
901-
<Card title="Supported Providers" icon="server" href="/integrations/llms">
902-
See the full list of LLM providers supported by Portkey
903-
</Card>
904-
905-
906-
907913

908914

909915
## Set Up Enterprise Governance for OpenAI Agents

integrations/llms.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ description: "Portkey connects with all major LLM providers and orchestration fr
9595
<Frame><img src="/images/supported-llm/lemonfox-ai.png" alt="Lemonfox AI" /></Frame>
9696
</Card>
9797

98+
99+
<Card title="Lepton AI" href="/integrations/llms/lepton">
100+
<Frame><img src="/images/supported-llm/lepton.png" alt="Lepton AI" /></Frame>
101+
</Card>
102+
98103
<Card title="Lingyi (01.ai)" href="/integrations/llms/lingyi-01.ai">
99104
<Frame><img src="/images/supported-llm/lingyi.png" alt="Lingyi (01.ai)" /></Frame>
100105
</Card>

integrations/llms/lepton.mdx

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -101,35 +101,6 @@ Use the Portkey instance to send requests to Lepton AI. You can also override th
101101
</Tab>
102102
</Tabs>
103103

104-
## Text Completions
105-
106-
For applications that require the traditional completions API, you can use Lepton AI's completions endpoint.
107-
108-
<Tabs>
109-
<Tab title="NodeJS SDK">
110-
```js
111-
const completion = await portkey.completions.create({
112-
prompt: 'Write a poem about AI',
113-
model: 'llama-3-8b-sft-v1',
114-
max_tokens: 250
115-
});
116-
117-
console.log(completion.choices);
118-
```
119-
</Tab>
120-
<Tab title="Python SDK">
121-
```python
122-
completion = portkey.completions.create(
123-
prompt="Write a poem about AI",
124-
model="llama-3-8b-sft-v1",
125-
max_tokens=250
126-
)
127-
128-
print(completion)
129-
```
130-
</Tab>
131-
</Tabs>
132-
133104
## Speech-to-Text (Transcription)
134105

135106
Lepton AI provides speech-to-text capabilities through Portkey's unified API:
@@ -195,45 +166,6 @@ Lepton AI supports streaming responses to provide real-time generation:
195166
</Tab>
196167
</Tabs>
197168
198-
### Lepton-Specific Parameters
199-
200-
Lepton AI models support several unique parameters for advanced control:
201-
202-
- `length_penalty`: Controls the length of generated text (default: 1)
203-
- `repetition_penalty`: Reduces repetitive patterns in generation (default: 1)
204-
- `dry_multiplier`: Controls monotonicity of text (default: 0)
205-
- `top_k`: Number of highest probability tokens to consider (default: 50)
206-
- `min_p`: Filters out tokens below a probability threshold (default: 0)
207-
208-
Example with custom parameters:
209-
210-
```python
211-
completion = portkey.chat.completions.create(
212-
messages=[{"role": "user", "content": "Write a creative story"}],
213-
model="llama-3-8b-sft-v1",
214-
temperature=0.8,
215-
top_p=0.95,
216-
repetition_penalty=1.2,
217-
length_penalty=1.1,
218-
top_k=40,
219-
min_p=0.05
220-
)
221-
```
222-
223-
### Audio Support
224-
225-
Lepton AI offers specialized audio features:
226-
227-
```python
228-
completion = portkey.chat.completions.create(
229-
messages=[{"role": "user", "content": "Generate a spoken response"}],
230-
model="llama-3-8b-sft-v1",
231-
require_audio=True,
232-
tts_preset_id="jessica", # Voice ID
233-
tts_audio_format="mp3", # Output format
234-
tts_audio_bitrate=64 # Quality setting
235-
)
236-
```
237169
238170
## Managing Lepton AI Prompts
239171

0 commit comments

Comments
 (0)