-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add OpenAI Responses API #1256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OpenAI Responses API #1256
Changes from all commits
00178b1
d7a57bd
6b4da84
b6c444c
c3cc473
67a30e7
600553c
98da00b
0ff6da3
3f5b20c
9f52eb0
69782bc
3e1a3fe
119030d
4534410
d40a2ef
deb5aed
00f9438
f91afd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,29 @@ agent = Agent(model) | |
... | ||
``` | ||
|
||
### OpenAI Responses API | ||
|
||
PydanticAI also supports OpenAI's [Responses API](https://platform.openai.com/docs/api-reference/responses) through the [`OpenAIResponsesModel`][pydantic_ai.models.openai.OpenAIResponsesModel] class. | ||
|
||
The Responses API has built-in tools that you can use instead of building your own: | ||
- [Web search](https://platform.openai.com/docs/guides/tools-web-search) | ||
- [File search](https://platform.openai.com/docs/guides/tools-file-search) | ||
- [Computer use](https://platform.openai.com/docs/guides/tools-computer-use) | ||
|
||
!!! warning "Work in progress" | ||
We currently don't support the native OpenAI tools listed above in the `OpenAIResponsesModel` class. | ||
|
||
You can learn more about the differences between the Responses API and Chat Completions API in the [OpenAI API docs](https://platform.openai.com/docs/guides/responses-vs-chat-completions). | ||
|
||
```python {title="openai_responses_model.py"} | ||
from pydantic_ai import Agent | ||
from pydantic_ai.models.openai import OpenAIResponsesModel | ||
|
||
model = OpenAIResponsesModel('gpt-4o') | ||
agent = Agent(model) | ||
... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This example should be complete, if minimal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well... There are 4 examples above that are exactly the same as this one. 🤔 Should I update all of them? Did you see them? |
||
``` | ||
|
||
## Anthropic | ||
|
||
### Install | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a note saying this is not yet supported in PydanticAI, will be soon.