Skip to content

Commit 007686c

Browse files
authored
Merge branch 'main' into temporal-usage-on-context
2 parents 05cfb68 + be2929c commit 007686c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

docs/gateway.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ status: new
55

66
# Pydantic AI Gateway
77

8-
**[Pydantic AI Gateway](https://pydantic.dev/ai-gateway)** (PAIG) is a unified interface for accessing multiple AI providers with a single key. Features include built-in OpenTelemetry observability, real-time cost monitoring, failover management, and native integration with the other tools in the [Pydantic stack](https://pydantic.dev/).
8+
**[Pydantic AI Gateway](https://pydantic.dev/ai-gateway)** is a unified interface for accessing multiple AI providers with a single key. Features include built-in OpenTelemetry observability, real-time cost monitoring, failover management, and native integration with the other tools in the [Pydantic stack](https://pydantic.dev/).
99

1010
!!! note "Free while in Beta"
1111
The Pydantic AI Gateway is currently in Beta. You can bring your own key (BYOK) or buy inference through the Gateway (we will eat the card fee for now).
@@ -26,8 +26,8 @@ To help you get started with [Pydantic AI Gateway](https://gateway.pydantic.dev)
2626
- **BYOK and managed providers:** Bring your own API keys (BYOK) from LLM providers, or pay for inference directly through the platform.
2727
- **Multi-provider support:** Access models from OpenAI, Anthropic, Google Vertex, Groq, and AWS Bedrock. _More providers coming soon_.
2828
- **Backend observability:** Log every request through [Pydantic Logfire](https://pydantic.dev/logfire) or any OpenTelemetry backend (_coming soon_).
29-
- **Zero translation**: Unlike traditional AI gateways that translate everything to one common schema, PAIG allows requests to flow through directly in each provider's native format. This gives you immediate access to the new model features as soon as they are released.
30-
- **Open source with self-hosting**: PAIG's core is [open source](https://github.com/pydantic/pydantic-ai-gateway/) (under [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.en.html)), allowing self-hosting with file-based configuration, instead of using the managed service.
29+
- **Zero translation**: Unlike traditional AI gateways that translate everything to one common schema, **Pydantic AI Gateway** allows requests to flow through directly in each provider's native format. This gives you immediate access to the new model features as soon as they are released.
30+
- **Open source with self-hosting**: Pydantic AI Gateway core is [open source](https://github.com/pydantic/pydantic-ai-gateway/) (under [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.en.html)), allowing self-hosting with file-based configuration, instead of using the managed service.
3131
- **Enterprise ready**: Includes SSO (with OIDC support), granular permissions, and flexible deployment options. Deploy to your Cloudflare account, or run on-premises with our [consulting support](https://pydantic.dev/contact).
3232

3333
```python {title="hello_world.py"}
@@ -80,7 +80,7 @@ Users can only create personal keys, that will inherit spending caps from both U
8080
## Usage
8181

8282
After setting up your account with the instructions above, you will be able to make an AI model request with the Pydantic AI Gateway.
83-
The code snippets below show how you can use PAIG with different frameworks and SDKs.
83+
The code snippets below show how you can use Pydantic AI Gateway with different frameworks and SDKs.
8484
You can add `gateway/` as prefix on every known provider that
8585

8686
To use different models, change the model string `gateway/<api_format>:<model_name>` to other models offered by the supported providers.
@@ -114,7 +114,7 @@ Before you start, make sure you are on version 1.16 or later of `pydantic-ai`. T
114114
Set the `PYDANTIC_AI_GATEWAY_API_KEY` environment variable to your Gateway API key:
115115

116116
```bash
117-
export PYDANTIC_AI_GATEWAY_API_KEY="YOUR_PAIG_TOKEN"
117+
export PYDANTIC_AI_GATEWAY_API_KEY="YOUR_PYDANTIC_AI_GATEWAY_API_KEY"
118118
```
119119

120120
You can access multiple models with the same API key, as shown in the code snippet below.
@@ -140,10 +140,10 @@ Set your gateway credentials as environment variables:
140140

141141
```bash
142142
export ANTHROPIC_BASE_URL="https://gateway.pydantic.dev/proxy/anthropic"
143-
export ANTHROPIC_AUTH_TOKEN="YOUR_PAIG_TOKEN"
143+
export ANTHROPIC_AUTH_TOKEN="YOUR_PYDANTIC_AI_GATEWAY_API_KEY"
144144
```
145145

146-
Replace `YOUR_PAIG_TOKEN` with the API key from the Keys page.
146+
Replace `YOUR_PYDANTIC_AI_GATEWAY_API_KEY` with the API key from the Keys page.
147147

148148
Launch Claude Code by typing `claude`. All requests will now route through the Pydantic AI Gateway.
149149

pydantic_ai_slim/pydantic_ai/providers/gateway.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ def gateway_provider(
132132
environment variable will be used if available. Otherwise, defaults to `https://gateway.pydantic.dev/proxy`.
133133
http_client: The HTTP client to use for the Gateway.
134134
"""
135-
api_key = api_key or os.getenv('PYDANTIC_AI_GATEWAY_API_KEY')
135+
api_key = api_key or os.getenv('PYDANTIC_AI_GATEWAY_API_KEY', os.getenv('PAIG_API_KEY'))
136136
if not api_key:
137137
raise UserError(
138138
'Set the `PYDANTIC_AI_GATEWAY_API_KEY` environment variable or pass it via `gateway_provider(..., api_key=...)`'
139139
' to use the Pydantic AI Gateway provider.'
140140
)
141141

142-
base_url = base_url or os.getenv('PYDANTIC_AI_GATEWAY_BASE_URL', GATEWAY_BASE_URL)
142+
base_url = base_url or os.getenv('PYDANTIC_AI_GATEWAY_BASE_URL', os.getenv('PAIG_BASE_URL', GATEWAY_BASE_URL))
143143
http_client = http_client or cached_async_http_client(provider=f'gateway/{upstream_provider}')
144144
http_client.event_hooks = {'request': [_request_hook(api_key)]}
145145

0 commit comments

Comments
 (0)