Simple Text Request
The simplest way to use the Responses API is with a plain text string:Structured Message Input
For more control, use structured message format with conversation history:Multi-Turn Conversations
Since the API is stateless, you must include the full conversation history in each request:Using Instructions
You can provide system-level instructions to guide the model’s behavior:Handling Responses
The response contains anoutput array with one or more output items. Each item has:
type: The type of output (usually “message”)role: The role of the message (usually “assistant”)status: The status of the output (“completed”, “incomplete”, etc.)content: An array of content parts
Error Handling
Always check for errors in the response:Best Practices
- Always include conversation history: Since the API is stateless, include all previous messages in each request. The API does not remember previous conversations.
- Manage state client-side: You are responsible for maintaining conversation history and including it in each request.
- Set appropriate token limits: Use
max_output_tokensto control response length - Handle errors gracefully: Check response status codes and error messages
- Use structured input: Prefer structured message format for better control and multimodal support
- Monitor usage: Check the
usagefield in responses to track token consumption
Stateless vs StatefulOpenAI’s Responses API has both stateless and stateful versions. Anannas implements only the stateless version, which means:
- No server-side conversation state
- No
previous_response_idparameter support - You must include full conversation history in each request
- Each request is completely independent
Was this page helpful?