Skip to content
Skip to article
View as Markdown

Responses API

POST /r/{router_slug}/v1/responses

Send text in input, or supply an array of messages and typed items for a multi-turn conversation. With the OpenAI SDK, set the base URL to $DODO_ROUTER_URL/v1 and call responses.create. Set the URL and key.

curl "$DODO_ROUTER_URL/v1/responses" \
  -H "Authorization: Bearer $DODO_ROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"default","input":"Reply with pong.","max_output_tokens":100}'

For a completed text reply, look for an output item with type: "message" and a content part with type: "output_text". The OpenAI SDK also exposes response.output_text. Representative response fields follow.

{
  "id": "resp_example", "object": "response", "status": "completed", "model": "gpt-5.5",
  "output": [{"type": "message", "role": "assistant", "content": [{"type":"output_text","text":"pong"}]}],
  "usage": {"input_tokens": 13, "output_tokens": 5, "total_tokens": 18}
}

Reported input_tokens_details and output_tokens_details carry cache-read and reasoning token counts in both the synchronous response and response.completed. A provider can report zero or omit the details.

Typed input items

On a Responses-format upstream such as OpenAI Codex, DodoRouter preserves native non-message input items with their type, payload and order. This includes reasoning items, additional_tools, function calls and function-call outputs. An additional_tools item can carry a developer role without a content field. Assistant message content arrays retain their output blocks when a conversation resumes. Configure Codex CLI.

Translation happens separately for each routing attempt. On other upstream formats, DodoRouter translates text blocks, user input_image blocks with an image URL, and function-call history with text results. It preserves call IDs and groups consecutive parallel calls into one assistant turn.

Some inputs require a Responses-format provider that supports them. A step unable to represent an item such as additional_tools, a reasoning item or a non-text function-call result records unsupported_responses_item with its field and type. The router can then try another step with the original typed items. Inspect the trace if a request with tool history takes a different route from a text-only request.

On Responses upstreams, the client’s reasoning object can include context, summary and effort. Leaving the routing step at provider default allows client-supplied reasoning settings through. An explicit parallel_tool_calls: false is preserved.

Function tools on other API formats

Declare a Responses function tool with top-level type: "function", name, description, and parameters. On an Anthropic step, DodoRouter converts the schema to input_schema and retains tool-level cache_control. On a Chat Completions step it nests the function definition and named tool_choice, preserving explicit strict: false. Built-in Responses tools require a compatible Responses-format upstream.

Streaming event sequence

curl -N "$DODO_ROUTER_URL/v1/responses" \
  -H "Authorization: Bearer $DODO_ROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"default","input":"Reply with pong.","stream":true}'

For a successful text response, handle the events in this order.

  1. response.created opens the response with status in_progress.
  2. response.output_item.added and response.content_part.added introduce the text item and part.
  3. Each response.output_text.delta adds text. The corresponding response.output_text.done, response.content_part.done and response.output_item.done close the text and its containers.
  4. response.completed carries the completed response. Read response.model and response.usage here. The initial response.created event uses the client's requested model name.

A router without routing steps returns an HTTP 400 JSON error. With a configured chain, DodoRouter opens HTTP 200 and sends response.created before provider dispatch. Handle event: error even if no text delta arrived. For idempotent retries, use a non-streaming request. Retry behavior.