Skip to content

Docs / Responses API

Responses API

POST /v1/responses for clients that speak the OpenAI Responses API, such as the Codex CLI. Stateless, function tools only.

Get an API key

POST /v1/responses accepts the OpenAI Responses API for clients that use it, such as the Codex CLI. It is billed, limited and routed exactly like /v1/chat/completions.

Base URL: https://api.yunshurouter.com/v1

Two things differ from OpenAI’s own Responses API:

  1. It is stateless. Nothing is stored. previous_response_id and conversation are refused with 400 invalid_request. Send the whole conversation in input each time, with store: false. The Codex CLI already works this way.
  2. Only function tools reach the model. Hosted tools (web_search, file_search, local_shell, custom tools) are removed from the request without an error. The model never sees them.

Example

curl https://api.yunshurouter.com/v1/responses \
  -H "Authorization: Bearer $YUNSHU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-pro",
    "instructions": "You answer in one sentence.",
    "input": "What is a context window?",
    "store": false
  }'
from openai import OpenAI

client = OpenAI(base_url="https://api.yunshurouter.com/v1", api_key="tq-...")

response = client.responses.create(
    model="deepseek-v4-pro",
    instructions="You answer in one sentence.",
    input="What is a context window?",
    store=False,
)
print(response.output_text)
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.yunshurouter.com/v1", apiKey: "tq-..." });

const response = await client.responses.create({
  model: "deepseek-v4-pro",
  instructions: "You answer in one sentence.",
  input: "What is a context window?",
  store: false,
});
console.log(response.output_text);

Multi-turn

Because nothing is stored, pass earlier turns back in input:

history = [
    {"role": "user", "content": "Pick a number between 1 and 10."},
]
first = client.responses.create(model="deepseek-v4-pro", input=history, store=False)

history += first.output  # the assistant's output items
history.append({"role": "user", "content": "Double it."})
second = client.responses.create(model="deepseek-v4-pro", input=history, store=False)
print(second.output_text)

Request fields

Field Handling
model Required. Model ID, combo or :floor / :nitro
input Required. A string, or a list of up to 4,096 items. Messages, function_call and function_call_output items are used. Reasoning items and hosted-tool calls are dropped, with any output that answered them
instructions Sent as the system prompt
max_output_tokens 1 to 1,000,000. When omitted, the model’s own maximum output is used (not 1,024 as on Chat Completions)
temperature 0 to 2
top_p 0 to 1
stream true for Responses streaming events
tools Function tools, and namespace groups of function tools. Up to 512. Other tool types are dropped
tool_choice auto, none, required, or one function. A choice naming a dropped tool falls back to auto
parallel_tool_calls Passed to the model
reasoning.effort none or minimal turns reasoning off; any other value turns it on. See Reasoning
text.format json_object and json_schema are passed to the model. text is the default
previous_response_id, conversation Refused (400)
store, include, metadata, prompt_cache_key, service_tier and other fields Accepted and not sent to the model. metadata is echoed back

Input content: text parts and input_image (by URL) are kept. Files and audio are dropped.

The models fallback list is not read on this endpoint. To get fallbacks here, call a saved combo ("model": "combo/<name>"). See Fallbacks and combos.

Response

A Responses response object with output items (message, function_call, and reasoning when the model returns reasoning text), status (completed or incomplete) and usage:

"usage": {
  "input_tokens": 1540,
  "input_tokens_details": {"cached_tokens": 0},
  "output_tokens": 212,
  "output_tokens_details": {"reasoning_tokens": 0},
  "total_tokens": 1752
}

Response headers are the same as Chat Completions: x-yunshu-request-id, x-yunshu-model, x-yunshu-cache, x-yunshu-request-ref.

Streaming

With stream: true you receive the standard events: response.created, response.in_progress, response.output_item.added, response.output_text.delta, response.function_call_arguments.delta, the matching .done events, and then response.completed or response.incomplete.

If the model fails after the stream has started, you receive response.failed with an error object (code, message) instead of a silent end. See Streaming.

Using the Codex CLI

# ~/.codex/config.toml   (export YUNSHU_API_KEY="tq-..." in your shell)
model = "deepseek-v4-pro"
model_provider = "yunshu"

[model_providers.yunshu]
name = "Yunshu Router"
base_url = "https://api.yunshurouter.com/v1"
env_key = "YUNSHU_API_KEY"
wire_api = "responses"

Codex’s shell and MCP tools are function tools, so they work. Its hosted web search does not.

Errors

Errors before the stream starts use the OpenAI envelope with a real HTTP status. See Errors.