Responses

POST /v1/responses

Generate a model response using the Responses API format. Supports instructions, multi-turn via previous_response_id, tools, and streaming.

Headers

Header Required Description
Authorization Yes Bearer <api-key-or-jwt>
Content-Type Yes application/json
X-Quantized-Provider No Force a specific provider — openrouter (default), openai, or bedrock

Request body

Required fields

Field Type Description
model string Model identifier (e.g., openai/gpt-4.1-mini)
input string or array The input text or a list of input items

Generation parameters

Field Type Default Description
instructions string null System-level instructions for the model (non-empty when present)
max_output_tokens integer null Maximum tokens in the response (minimum: 1)
temperature float null Sampling temperature (0–2)
top_p float null Nucleus sampling threshold (0–1)
frequency_penalty float null Frequency penalty (−2 to 2)
presence_penalty float null Presence penalty (−2 to 2)

Tool calling

Field Type Default Description
tools array null Tool definitions in Responses format, forwarded to the provider as-is. Supports built-in tools (web_search_preview) and custom functions: {"type": "function", "name": "...", "description": "...", "parameters": {...}}
tool_choice string or object null "auto", "none", "required", or {"type": "function", "name": "..."}
parallel_tool_calls boolean null Allow parallel tool execution

Reasoning & state

Field Type Default Description
reasoning object null Reasoning config for thinking models. effort: "none", "minimal", "low", "medium", "high", "xhigh", or "max". "none" disables reasoning. The router translates effort into each model’s provider-native setting; an effort the model doesn’t support returns 400. When the model has no such mapping, the object is forwarded to the provider as-is, so other keys such as summary reach it unchanged. Example: {"effort": "low"}
previous_response_id string null ID of a previous response for multi-turn continuation (non-empty when present). Not supported by cheaperinference (400) and ignored by bedrock

Streaming

Field Type Default Description
stream boolean false Enable SSE streaming
Strict validation

The API uses strict parameter validation. Any field not listed above will be rejected with a 400 invalid_request error, with param naming the field. Parameters like store, text, truncation, include, service_tier, background, top_k, metadata, and user are not currently supported.

Input format

The input field accepts either a plain string or an array of input items:

// Simple string
{"input": "What is the capital of France?"}

// Array of items
{"input": [
  {"role": "user", "content": "What is the capital of France?"}
]}

Array items are forwarded to the provider as-is, so any Responses input item the provider accepts works: for example, messages with input_text or input_image content parts, or function_call_output items that return a tool result. Bedrock flattens input items to plain text.

Examples

cURL
Python
OpenAI SDK
curl -X POST https://api.quantized.us/v1/responses \
  -H "Authorization: Bearer sk-quantized-YOUR-KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1-mini",
    "input": "What is the capital of France?",
    "instructions": "You are a geography expert. Be concise.",
    "max_output_tokens": 128
  }'
import httpx

response = httpx.post(
    "https://api.quantized.us/v1/responses",
    headers={"Authorization": "Bearer sk-quantized-YOUR-KEY"},
    json={
        "model": "openai/gpt-4.1-mini",
        "input": "What is the capital of France?",
        "instructions": "You are a geography expert. Be concise.",
        "max_output_tokens": 128,
    },
)
data = response.json()
# Reasoning models may put a reasoning item before the message, so look up the message item.
message = next(item for item in data["output"] if item["type"] == "message")
print(message["content"][0]["text"])
from openai import OpenAI

client = OpenAI(
    api_key="sk-quantized-YOUR-KEY",
    base_url="https://api.quantized.us/v1",
)

response = client.responses.create(
    model="openai/gpt-4.1-mini",
    input="What is the capital of France?",
    instructions="You are a geography expert. Be concise.",
    max_output_tokens=128,
)
print(response.output_text)

Response

{
  "id": "resp-abc123",
  "object": "response",
  "status": "completed",
  "model": "openai/gpt-4.1-mini",
  "output": [
    {
      "id": "msg-001",
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "The capital of France is Paris."
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 20,
    "output_tokens": 8,
    "total_tokens": 28,
    "credits_used": 2000,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens_details": {
      "reasoning_tokens": 0
    }
  },
  "created_at": 1719000000
}

Response fields

Field Type Description
id string Unique response ID
object string Always "response"
status string Status reported by the provider, e.g. "completed", "incomplete", "failed"
model string Model that generated the response
output array List of output items. Fields that are null are omitted
output[].id string Item ID (may be absent, e.g. on Bedrock message items)
output[].type string "message", "function_call", or another provider item type such as "reasoning" (reasoning items carry only id and type)
output[].role string "assistant" for message items
output[].status string Item status, when the provider reports one
output[].content array Content parts (message items)
output[].content[].type string "output_text"
output[].content[].text string The generated text
output[].content[].annotations array Annotations such as citations, when the provider returns them
output[].name string Function name (function_call items)
output[].arguments string JSON-encoded function arguments (function_call items)
output[].call_id string ID to reference in the function_call_output input item (function_call items)
usage.input_tokens integer Input tokens
usage.output_tokens integer Output tokens
usage.total_tokens integer Total tokens
usage.credits_used integer Micro-credits consumed
usage.input_tokens_details object or null Token breakdown: cached_tokens
usage.output_tokens_details object or null Token breakdown: reasoning_tokens
created_at integer, string, or null Creation timestamp (null on Bedrock)

Streaming

Set "stream": true to receive Server-Sent Events. The Responses endpoint uses typed events (response.created, response.output_text.delta, response.completed, etc.). See the Streaming guide for the full event format and code examples.

Errors

Status Code Condition
400 invalid_request Request body failed validation: a missing or invalid field (e.g. no model, empty input, temperature out of range), or an unrecognized field. param names the field
400 invalid_request Malformed X-Quantized-Provider header (param: "X-Quantized-Provider")
400 invalid_metadata_header Invalid X-Quantized-Metadata header
400 invalid_request The model does not support the requested reasoning effort (param: "reasoning.effort")
400 invalid_request previous_response_id sent to cheaperinference, which is stateless
400 invalid_request The provider rejected the request (e.g. a bad parameter); the provider’s message is returned
400 context_length_exceeded The input, or the input plus max_output_tokens, doesn’t fit the model’s context window
400 no_provider_available No provider available for the model or endpoint (e.g. a pin your license doesn’t allow)
401 missing_api_key, invalid_api_key, api_key_expired, license_inactive Missing, invalid, or expired API key, or an inactive license
402 budget_exhausted Your license is out of budget. metadata names the limit that blocked the request
403 policy_denied Your license’s policy does not allow this service or parameter value (param names the parameter)
403 content_policy_violation Request blocked by a guardrail
404 model_not_found No available provider accepts a modality you sent, or the provider doesn’t know the model (who validates the model)
429 rate_limit_exceeded The provider rate-limited the request. retry-after is set when the provider sent one
500 internal_error Unexpected error, or a budget configuration error
502 provider_error The provider returned a 5xx or an invalid response, or the connection dropped
503 provider_misconfigured Our credentials for the provider are missing or were rejected
503 policy_unavailable Your license’s policy can’t be evaluated
504 upstream_timeout The provider timed out

Every error uses the standard error body. Branch on the status and code; see the Error reference for each.

Errors that occur after a stream has started are reported inside the stream. See Errors during a stream.