You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/install.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,6 +128,23 @@ agent = Agent(model)
128
128
...
129
129
```
130
130
131
+
#### `base_url` argument
132
+
133
+
To use another OpenAI-compatible API, such as [OpenRouter](https://openrouter.ai), you can make use of the [`base_url` argument][pydantic_ai.models.openai.OpenAIModel.__init__]:
134
+
135
+
```python {title="openai_model_base_url.py"}
136
+
from pydantic_ai import Agent
137
+
from pydantic_ai.models.openai import OpenAIModel
138
+
139
+
model = OpenAIModel(
140
+
'anthropic/claude-3.5-sonnet',
141
+
base_url='https://openrouter.ai/api/v1',
142
+
api_key='your-api-key',
143
+
)
144
+
agent = Agent(model)
145
+
...
146
+
```
147
+
131
148
#### Custom OpenAI Client
132
149
133
150
`OpenAIModel` also accepts a custom `AsyncOpenAI` client via the [`openai_client` parameter][pydantic_ai.models.openai.OpenAIModel.__init__],
0 commit comments