Skip to main content
The Responses API supports both simple string input and structured message arrays, making it easy to get started with basic text generation.

Simple String Input

The simplest way to use the API is with a string input:
Output

Structured Message Input

For more complex conversations, use the message array format:
Output

Response Format

The API returns a structured response with the generated content:

Server Tool Usage

For a request that invokes an OpenRouter server tool, the usage object includes server_tool_use_details. The field is omitted when no tool usage is recorded. Provider-native web search may still report web_search_requests without an OpenRouter server-tool invocation. The object reports aggregate activity for the request; web_search_requests is currently the only tool-specific counter:
  • tool_calls_requested counts OpenRouter server-orchestrated tool calls requested by the model.
  • tool_calls_executed counts calls that ran and returned a result.
  • web_search_requests counts searches performed by server-side tools. A server-orchestrated search is also included in tool_calls_requested; provider-native search may only report web_search_requests.
These fields describe tool activity; the request’s overall usage.cost includes applicable server-tool charges.

Deferred-Tools Usage

When a request executes a managed multi-turn deferred-tools run under the universal profile, native token fields (input_tokens, output_tokens, total_tokens, input_tokens_details, and output_tokens_details) report the final upstream model turn, cost and cost_details sum all turns plus any billable router-run tools, and deferred_tools_details reports the summed token totals across every model turn with settled usage. Multi-turn runs under the portable profile report cumulative native token counts and omit deferred_tools_details, as do standard requests:
  • turns: Model turns with settled usage in the run (positive integer; failed upstream attempts with no settled usage are not counted).
  • prompt_tokens: Prompt tokens summed across every settled model turn.
  • completion_tokens: Completion tokens summed across every settled model turn.
  • total_tokens: Sum of prompt_tokens and completion_tokens across every settled model turn.
See Usage Accounting for per-turn Logs rows, spend thresholds, and behavior across APIs.

Streaming Responses

Enable streaming for real-time response generation:
Output

Example Streaming Output

The streaming response returns Server-Sent Events (SSE) chunks:

Common Parameters

Error Handling

Handle common errors gracefully:
Output

Multiple Turn Conversations

Since the Responses API is stateless, you must include the full conversation history in each request to maintain context. Replayed assistant content uses output_text, while user content uses input_text. Stateful parameters like store: true and previous_response_id are not supported and are rejected with a 400 error:
Output
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