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/models/index.md
+42-5Lines changed: 42 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,43 @@ The Agents SDK comes with out-of-the-box support for OpenAI models in two flavor
5
5
-**Recommended**: the [`OpenAIResponsesModel`][agents.models.openai_responses.OpenAIResponsesModel], which calls OpenAI APIs using the new [Responses API](https://platform.openai.com/docs/api-reference/responses).
6
6
- The [`OpenAIChatCompletionsModel`][agents.models.openai_chatcompletions.OpenAIChatCompletionsModel], which calls OpenAI APIs using the [Chat Completions API](https://platform.openai.com/docs/api-reference/chat).
7
7
8
+
## OpenAI models
9
+
10
+
When you don't specify a model when initializing an `Agent`, the default model will be used. The default is currently [`gpt-4.1`](https://platform.openai.com/docs/models/gpt-4.1), which offers a strong balance of predictability for agentic workflows and low latency.
11
+
12
+
If you want to switch to other models like [`gpt-5`](https://platform.openai.com/docs/models/gpt-5), there are two ways to configure your agents.
13
+
14
+
### Change the default model
15
+
16
+
If you want to consistently use a specific model for all agents that do not set a custom model, set the `OPENAI_DEFAULT_MODEL` environment variable before running your agents.
17
+
18
+
```bash
19
+
export OPENAI_DEFAULT_MODEL=gpt-5
20
+
python3 my_awesome_agent.py
21
+
```
22
+
23
+
When you use a GPT-5 model this way, the SDK applies sensible `ModelSettings` by default. Specifically, it sets both `reasoning.effort` and `verbosity` to `"low"`. If you want to build these settings yourself, call `agents.models.get_default_model_settings("gpt-5")`.
24
+
25
+
If you prefer a different reasoning effort for the default model, pass your own `ModelSettings` as below. Note that some built-in tools (for example, file search and image generation) do not support "minimal" reasoning effort, which is why the SDK defaults to "low".
26
+
27
+
```python
28
+
from openai.types.shared import Reasoning
29
+
from agents import Agent, ModelSettings
30
+
31
+
my_agent = Agent(
32
+
name="My Agent",
33
+
instructions="You're a helpful agent.",
34
+
model_settings=ModelSettings(
35
+
reasoning=Reasoning(effort="minimal")
36
+
)
37
+
# If OPENAI_DEFAULT_MODEL=gpt-5 is set, passing only model_settings works.
38
+
# It's also fine to pass a GPT-5 model name explicitly:
39
+
# model="gpt-5",
40
+
)
41
+
```
42
+
43
+
If you pass a non–GPT-5 model name without custom `model_settings`, the SDK reverts to generic `ModelSettings` compatible with any model.
44
+
8
45
## Non-OpenAI models
9
46
10
47
You can use most other non-OpenAI models via the [LiteLLM integration](./litellm.md). First, install the litellm dependency group:
@@ -53,14 +90,14 @@ import asyncio
53
90
spanish_agent = Agent(
54
91
name="Spanish agent",
55
92
instructions="You only speak Spanish.",
56
-
model="o3-mini", # (1)!
93
+
model="gpt-5-mini", # (1)!
57
94
)
58
95
59
96
english_agent = Agent(
60
97
name="English agent",
61
98
instructions="You only speak English",
62
99
model=OpenAIChatCompletionsModel( # (2)!
63
-
model="gpt-4o",
100
+
model="gpt-5-nano",
64
101
openai_client=AsyncOpenAI()
65
102
),
66
103
)
@@ -69,7 +106,7 @@ triage_agent = Agent(
69
106
name="Triage agent",
70
107
instructions="Handoff to the appropriate agent based on the language of the request.",
71
108
handoffs=[spanish_agent, english_agent],
72
-
model="gpt-3.5-turbo",
109
+
model="gpt-5",
73
110
)
74
111
75
112
asyncdefmain():
@@ -88,7 +125,7 @@ from agents import Agent, ModelSettings
88
125
english_agent = Agent(
89
126
name="English agent",
90
127
instructions="You only speak English",
91
-
model="gpt-4o",
128
+
model="gpt-4.1",
92
129
model_settings=ModelSettings(temperature=0.1),
93
130
)
94
131
```
@@ -101,7 +138,7 @@ from agents import Agent, ModelSettings
0 commit comments