Skip to content

Commit f9de13e

Browse files
committed
consolidate docs in overview.md & update mkdocs
1 parent 3dc31b2 commit f9de13e

File tree

4 files changed

+123
-127
lines changed

4 files changed

+123
-127
lines changed

docs/gateway/overview.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,126 @@ print(result.output)
3636
The first known use of "hello, world" was in a 1974 textbook about the C programming language.
3737
"""
3838
```
39+
# Quick Start
40+
This section contains instructions on how to set up your account and run your app with Pydantic AI Gateway credentials.
41+
42+
## Create an account
43+
Using your GitHub or Google account, sign in at https://gateway.pydantic.dev.
44+
Choose a name for your organization (or accept the default). You will automatically be assigned the Admin role.
45+
46+
A default project will be created for you. You can choose to use it, or create a new one on the [Projects](https://gateway.pydantic.dev/admin/projects) page.
47+
48+
## Add **Providers** by bringing your own API keys (BYOK)
49+
Pydantic AI Gateway allows you to bring your API keys from your favourite provider(s).
50+
51+
On the [Providers](https://gateway.pydantic.dev/admin/providers) page, fill in the form to add a provider. Paste your API key into the form under Credentials, and make sure to **select the Project that will be associated to this provider**. It is possible to add multiple keys from the same provider.
52+
53+
## Grant access to your team
54+
On the [Users](https://gateway.pydantic.dev/admin/users) page, create an invitation and share the URL with your team to allow them to access the project.
55+
56+
## Create gateway project keys
57+
On the Keys page, Admins can create project keys which are not affected by spending limits. Users can only create personal keys, that will inherit spending caps from both User and Project levels, whichever is more restrictive.
58+
59+
# Usage
60+
After setting up your account with the instructions above, you will be able to make an AI model request with the Pydantic AI Gateway.
61+
The code snippets below show how you can use PAIG with different frameworks and SDKs.
62+
63+
To use different models, change the model string `gateway/<api_type>:<model_name>` to other models offered by the supported providers.
64+
65+
Examples of providers and models that can be used are:
66+
67+
| **Provider** | **Provider ID** | **Example Model** |
68+
| --- | --- | --- |
69+
| OpenAI | `openai` | `gateway/openai:gpt-4.1` |
70+
| Anthropic | `anthropic` | `gateway/anthropic:claude-sonnet-4-5` |
71+
| Google Vertex | `google-vertex` | `gateway/google-vertex:gemini-2.5-flash` |
72+
| Groq | `groq` | `gateway/groq:openai/gpt-oss-120b` |
73+
| AWS Bedrock | `bedrock` | `gateway/bedrock:amazon.nova-micro-v1:0` |
74+
75+
## Pydantic AI
76+
Before you start, update to the latest version of `pydantic-ai`:
77+
78+
=== "uv"
79+
80+
```bash
81+
uv sync -P pydantic-ai
82+
```
83+
84+
=== "pip"
85+
86+
```bash
87+
pip install -U pydantic-ai
88+
```
89+
90+
Set the `PYDANTIC_AI_GATEWAY_API_KEY` environment variable to your gateway API key:
91+
92+
```bash
93+
export PYDANTIC_AI_GATEWAY_API_KEY="YOUR_PAIG_TOKEN"
94+
```
95+
96+
You can access multiple models with the same API key, as shown in the code snippet below.
97+
98+
```python title="hello_world.py"
99+
from pydantic_ai import Agent
100+
101+
agent = Agent('gateway/chat:gpt-5')
102+
103+
result = agent.run_sync('Where does "hello world" come from?')
104+
print(result.output)
105+
"""
106+
The first known use of "hello, world" was in a 1974 textbook about the C programming language.
107+
"""
108+
```
109+
110+
111+
## Claude Code
112+
Before you start, log out of Claude Code using `/logout`.
113+
114+
Set your gateway credentials as environment variables:
115+
116+
```bash
117+
export ANTHROPIC_BASE_URL="https://gateway.pydantic.dev/proxy/anthropic"
118+
export ANTHROPIC_AUTH_TOKEN="YOUR_PAIG_TOKEN"
119+
```
120+
121+
Replace `YOUR_PAIG_TOKEN` with the API key from the Keys page.
122+
123+
Launch Claude Code by typing `claude`. All requests will now route through the Pydantic AI Gateway.
124+
125+
## SDKs
126+
127+
=== "OpenAI SDK"
128+
129+
```python {title="openai_sdk.py" test="skip"}
130+
import openai
131+
132+
client = openai.Client(
133+
base_url='https://gateway.pydantic.dev/proxy/chat/',
134+
api_key='paig_...',
135+
)
136+
137+
response = client.chat.completions.create(
138+
model='gpt-4o',
139+
messages=[{'role': 'user', 'content': 'Hello world'}],
140+
)
141+
print(response.choices[0].message.content)
142+
#> Hello user
143+
```
144+
=== "Anthropic SDK"
145+
146+
```python {title="anthropic_sdk.py" test="skip"}
147+
import anthropic
148+
149+
client = anthropic.Anthropic(
150+
base_url='https://gateway.pydantic.dev/proxy/anthropic/',
151+
auth_token='paig_...',
152+
)
153+
154+
response = client.messages.create(
155+
max_tokens=1000,
156+
model='claude-3-haiku-20240307',
157+
messages=[{'role': 'user', 'content': 'Hello world'}],
158+
)
159+
print(response.content[0].text)
160+
#> Hello user
161+
```

docs/gateway/quick-start.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

docs/gateway/usage.md

Lines changed: 0 additions & 103 deletions
This file was deleted.

mkdocs.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ nav:
5656

5757
- Pydantic AI Gateway:
5858
- Overview: gateway/overview.md
59-
- Getting Started:
60-
- Quick Start: gateway/quick-start.md
61-
- Usage: gateway/usage.md
6259

6360
- Pydantic Evals:
6461
- Overview: evals.md

0 commit comments

Comments
 (0)