Simple String Input
The simplest way to use the API is with a string input:Structured Message Input
For more complex conversations, use the message array format:Response Format
The API returns a structured response with the generated content:Streaming Responses
Enable streaming for real-time response generation:Example Streaming Output
The streaming response returns Server-Sent Events (SSE) chunks:Common Parameters
| Parameter | Type | Description |
|---|---|---|
model | string | Required. Model to use (e.g., openai/o4-mini) |
input | string or array | Required. Text or message array |
stream | boolean | Enable streaming responses (default: false) |
max_output_tokens | integer | Maximum tokens to generate |
temperature | number | Sampling temperature (0-2) |
top_p | number | Nucleus sampling parameter (0-1) |
Error Handling
Handle common errors gracefully:Multiple Turn Conversations
Since the Responses API Beta is stateless, you must include the full conversation history in each request to maintain context:Required FieldsThe
id and status fields are required for any assistant role messages included in the conversation history.Conversation HistoryAlways include the complete conversation history in each request. The API does not store previous messages, so context must be maintained client-side.
Next Steps
- Learn about Reasoning capabilities
- Explore Tool Calling functionality
- Try Web Search integration