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
asyncfor msg in ai.run(agent, llm, "When will the robots take over?"):
37
32
print(msg.text_delta, end="")
@@ -204,23 +199,31 @@ Three event types are tracked:
204
199
#### LLM Providers
205
200
206
201
```python
207
-
# OpenAI-compatible (including Vercel AI Gateway)
208
-
llm = ai.openai.OpenAIModel(
202
+
# Vercel AI Gateway (recommended)
203
+
# Uses AI_GATEWAY_API_KEY env var by default
204
+
llm = ai.ai_gateway.GatewayModel(
209
205
model="anthropic/claude-opus-4.6",
210
-
base_url="https://ai-gateway.vercel.sh/v1",
211
-
api_key=os.environ["AI_GATEWAY_API_KEY"],
212
206
thinking=True, # enable reasoning output
213
207
budget_tokens=10000, # or reasoning_effort="medium"
214
208
)
215
209
216
-
# Anthropic (native client)
210
+
# OpenAI (direct)
211
+
llm = ai.openai.OpenAIModel(
212
+
model="gpt-4o",
213
+
thinking=True,
214
+
reasoning_effort="medium",
215
+
)
216
+
217
+
# Anthropic (direct)
217
218
llm = ai.anthropic.AnthropicModel(
218
-
model="claude-opus-4.6-20250916",
219
+
model="claude-opus-4-6-20250916",
219
220
thinking=True,
220
221
budget_tokens=10000,
221
222
)
222
223
```
223
224
225
+
The gateway provider automatically routes Anthropic models through the native Anthropic API for full feature support, and falls back to the OpenAI-compatible endpoint for structured output and non-Anthropic models.
0 commit comments