Skip to content

Commit ff082f5

Browse files
authored
openai responses model class (#229)
1 parent afbe4b2 commit ff082f5

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
| Name | Type | Default | Description |
2+
| ----------------------------- | --------------------------------- | -------------------- | ------------------------------------------------------------------------------------- |
3+
| `id` | `str` | `"gpt-4o"` | The id of the OpenAI model to use. |
4+
| `name` | `str` | `"OpenAIResponses"` | The name of this response model instance. |
5+
| `provider` | `str` | `"OpenAI"` | The provider of the model. |
6+
| `include` | `Optional[List[str]]` | `None` | List of response components to include in the response. |
7+
| `max_output_tokens` | `Optional[int]` | `None` | The maximum number of tokens to generate in the response output. |
8+
| `metadata` | `Optional[Dict[str, Any]]` | `None` | Additional metadata to include with the request. |
9+
| `parallel_tool_calls` | `Optional[bool]` | `None` | Whether to allow parallel tool calls. |
10+
| `reasoning` | `Optional[Dict[str, Any]]` | `None` | Parameters for enabling and controlling reasoning/thinking in the response. |
11+
| `store` | `Optional[bool]` | `None` | Whether to store the output of this response request for model distillation or evals. |
12+
| `temperature` | `Optional[float]` | `None` | Controls randomness in the model's output. |
13+
| `top_p` | `Optional[float]` | `None` | Controls diversity via nucleus sampling. |
14+
| `truncation` | `Optional[str]` | `None` | How to handle content that exceeds the token limit. |
15+
| `user` | `Optional[str]` | `None` | A unique identifier representing your end-user. |
16+
| `response_format` | `Optional[Any]` | `None` | An object specifying the format that the model must output. |
17+
| `request_params` | `Optional[Dict[str, Any]]` | `None` | Additional parameters to include in the request. |
18+
| `api_key` | `Optional[str]` | `None` | The API key for authenticating with OpenAI. |
19+
| `organization` | `Optional[str]` | `None` | The organization to use for API requests. |
20+
| `base_url` | `Optional[Union[str, httpx.URL]]` | `None` | The base URL for API requests. |
21+
| `timeout` | `Optional[float]` | `None` | The timeout for API requests. |
22+
| `max_retries` | `Optional[int]` | `None` | The maximum number of retries for failed requests. |
23+
| `default_headers` | `Optional[Dict[str, str]]` | `None` | Default headers to include in all requests. |
24+
| `default_query` | `Optional[Dict[str, str]]` | `None` | Default query parameters to include in all requests. |
25+
| `http_client` | `Optional[httpx.Client]` | `None` | An optional pre-configured HTTP client. |
26+
| `client_params` | `Optional[Dict[str, Any]]` | `None` | Additional parameters for client configuration. |
27+
| `vector_store_name` | `str` | `"knowledge_base"` | The name of the vector store for file uploads and retrieval. |

mint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"models/compatibility",
122122
"models/openai",
123123
"models/openai-like",
124+
"models/openai-responses",
124125
"models/anthropic",
125126
{
126127
"group": "AWS",

models/openai-responses.mdx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: OpenAI Responses
3+
---
4+
5+
`OpenAIResponses` is a class for interacting with OpenAI models using the Responses API. This class provides a streamlined interface for working with OpenAI's newer Responses API, which is distinct from the traditional Chat API. It supports advanced features like tool use, file processing, and knowledge retrieval.
6+
7+
8+
## Authentication
9+
10+
Set your `OPENAI_API_KEY` environment variable. You can get one [from OpenAI here](https://platform.openai.com/account/api-keys).
11+
12+
<CodeGroup>
13+
14+
```bash Mac
15+
export OPENAI_API_KEY=sk-***
16+
```
17+
18+
```bash Windows
19+
setx OPENAI_API_KEY sk-***
20+
```
21+
22+
</CodeGroup>
23+
24+
## Example
25+
26+
Use `OpenAIResponses` with your `Agent`:
27+
28+
<CodeGroup>
29+
30+
```python agent.py
31+
32+
from agno.agent import Agent
33+
from agno.media import File
34+
from agno.models.openai.responses import OpenAIResponses
35+
36+
agent = Agent(
37+
model=OpenAIResponses(id="gpt-4o-mini"),
38+
tools=[{"type": "file_search"}, {"type": "web_search_preview"}],
39+
markdown=True,
40+
)
41+
42+
agent.print_response(
43+
"Summarize the contents of the attached file and search the web for more information.",
44+
files=[File(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf")],
45+
)
46+
47+
```
48+
49+
</CodeGroup>
50+
51+
<Note> View more examples [here](../examples/models/openai/responses). </Note>
52+
53+
## Params
54+
55+
For more information, please refer to the [OpenAI Responses docs](https://platform.openai.com/docs/api-reference/responses) as well.
56+
57+
<Snippet file="model-openai-responses-params.mdx" />
58+
59+
`OpenAIResponses` is a subclass of the [Model](/reference/models/model) class and has access to the same params.

0 commit comments

Comments
 (0)