Responses API

Early access
Copy Page as Markdown

Use the Responses API for stateful inference with SubQ Savant (subq-savant-1.4). Savant is early access, enabled per organization. Request access. SubQ stores each turn server-side and links them by ID, so multi-turn workflows — long document review, case research, and agent loops — need no client-side history management. Pass previous_response_id to continue from a prior turn.

For stateless requests where you send the full messages array each time, use the Chat Completions API.

POST /v1/responses

When to use which endpoint

Chat CompletionsResponses API
Conversation stateYou send full messages[] each requestServer stores history; continue with previous_response_id or conversation
Best forExisting Chat Completions clients, custom message assemblyMulti-turn apps, long-context workflows, simpler clients
System promptsystem role in messagesinstructions (per-turn; not inherited)
Built-in web searchNot availabletools: [{ "type": "web_search_preview" }]
Function callingNested shape ({"type":"function","function":{...}}), see Function callingFlattened shape ({"type":"function","name":...}), see Function calling
Structured Outputsresponse_formattext.format (flattened shape)
File inputfile parts (file_data or file_id)input_file parts (file_id only)
Reasoning effortTop-level reasoning_effortNested reasoning.effort
Stream terminatordata: [DONE]response.completed event

Request body

FieldTypeRequiredDescription
modelstringYesModel ID to use, such as subq-savant-1.4. See Models.
inputstring or content part[]YesThe user's message for this turn. A plain string, or an array of input_text and input_file parts. See Input.
instructionsstring or nullNoSystem prompt for the current turn only. Not inherited — pass it on every request if it must persist.
previous_response_idstring or nullNoContinues from a specific prior response. Mutually exclusive with conversation. Omit or pass null to start a new one. Returns 404 if the ID does not exist.
conversationstring or nullNoContinues a conversation by its conv_... id, picking up from its most recently written turn. Mutually exclusive with previous_response_id. See Multi-turn conversations. Returns 404 if the conversation does not exist.
toolsobject[] or nullNoTools available to the model: built-in tools SubQ executes server-side ({ "type": "web_search_preview" }, see Web search) and function tools your application executes ({ "type": "function", ... }, see Function calling).
reasoningobject or nullNoReasoning configuration for this turn. Set effort to low, high (the default), or max. Reasoning cannot be turned off. See Reasoning effort.
temperaturenumber or nullNoAccepted from 0 to 2 for OpenAI compatibility and ignored. Savant always samples at 1.
streambooleanNoWhen false or omitted, returns one JSON response. When true, returns server-sent events.
textobject or nullNoOutput format. Defaults to { "format": { "type": "text" } }. See Structured outputs.
storeboolean or nullNoSet false to run this turn without saving it. Defaults to true. See Storage.
metadataobject or nullNoUp to 16 key-value string pairs attached to the request, for your own tracking. Echoed back on the response, including streaming response.created/response.completed events. See Metadata for the limits.

Reasoning effort

SubQ Savant reasons before it answers. Pass a reasoning object with an effort field, not a boolean, to control how much: low, high (the default), or max. Reasoning cannot be turned off: effort: "none" returns 400 unsupported_value. The values and how reasoning is billed are the same as Chat Completions reasoning_effort.

{
  "model": "subq-savant-1.4",
  "instructions": "You are a legal research assistant. Use plain language. Cite only facts in the conversation.",
  "input": "Summarize the major self-preferencing antitrust cases since 2010 and list open questions for counsel.",
  "reasoning": {
    "effort": "max"
  }
}
cURLTypeScriptPython

Reasoning tokens are counted in usage.output_tokens. The reasoning itself comes back as a reasoning item in output, ahead of the answer. See Output items.

Input

Set input to a plain string:

{
  "input": "Summarize the major self-preferencing antitrust cases since 2010."
}

A content-part array is also accepted. SubQ processes input_text (user text) and input_file (an uploaded file referenced by file_id). Image parts are ignored. To send an image to Savant, use Chat Completions. Prefer the string form when the turn has no files.

For large documents, include the text in input (or earlier turns) and use SubQ's long context window, or upload the file and pass its file_id.

Uploaded files (file_id)

Upload the document with the Files API, wait until status is processed, then send an input_file part. Responses uses the input_file part type, not the Chat Completions file part.

{
  "model": "subq-savant-1.4",
  "input": [
    { "type": "input_file", "file_id": "file_abc123" },
    { "type": "input_text", "text": "Summarize this document." }
  ]
}
cURLTypeScriptPython
FieldTypeRequiredDescription
typestringYesMust be "input_file".
file_idstringYesFile identifier returned by POST /v1/files.

Inline file_data is not accepted on Responses. Upload the file and pass file_id, or use Chat Completions for a one-off base64 request. A missing file_id returns 400 validation_error. An unknown id, or a file owned by another organization, returns 404 file_not_found.

You can also wrap parts in a message item ({ "role": "user", "content": [ ... ] }), which is the shape the SDK sends. See Sending files for upload vs inline, accepted formats, and the Chat Completions part shape.

Instructions

Use instructions for system guidance — policy constraints, role, citation rules, or output style. It is inserted before conversation history for the current turn, equivalent to a Chat Completions system message.

instructions are not carried by previous_response_id. Resend them on every turn that needs the same system prompt.

{
  "model": "subq-savant-1.4",
  "instructions": "You are a legal research assistant. Use plain language. Cite only facts in the conversation.",
  "input": "Summarize the major self-preferencing antitrust cases since 2010 and list open questions for counsel."
}

Add the web_search_preview tool to enable built-in web search. SubQ runs the search loop server-side: when the model asks to search, SubQ runs the search, feeds the results back, and continues until the model gives a final answer, all within one request.

{
  "model": "subq-savant-1.4",
  "instructions": "Be concise (3 bullets max). Prefer Fed, FDIC, and OCC releases from today. If nothing material, say so.",
  "input": "Any material US bank regulatory news today?",
  "tools": [{ "type": "web_search_preview" }]
}
cURLTypeScriptPython

Each executed search appears in output as a web_search_call item, in the order it ran, followed by the final assistant message.

{
  "output": [
    {
      "id": "ws_019f5c714e4479a5a37680c82da9d06c",
      "type": "web_search_call",
      "status": "completed",
      "action": {
        "type": "search",
        "queries": [
          "US bank regulatory news today",
          "FDIC announcements today",
          "OCC regulatory updates today",
          "Federal Reserve banking regulations today"
        ],
        "query": "US bank regulatory news today"
      }
    },
    {
      "id": "msg_019f5c71d7b37b0695ca49dc05c81ba1",
      "type": "message",
      "status": "completed",
      "role": "assistant",
      "phase": "final_answer",
      "content": [
        {
          "type": "output_text",
          "annotations": [],
          "logprobs": [],
          "text": "Based on today's regulatory developments, here are the key updates affecting US banks:\n\n- **Immigrant Lending Guidance**: The OCC, FDIC, and NCUA jointly issued nonbinding guidance warning banks about credit risks when lending to undocumented immigrants, citing potential income instability and deportation risks. This implements a May 2026 Trump executive order and follows FinCEN's May advisory on identity theft and money laundering red flags.\n\n- **Circle National Trust Approval**: The OCC granted final approval for Circle to establish a federally regulated national trust bank (Circle National Trust) for digital asset custody. This allows Circle to manage USDC stablecoin reserves under federal oversight, marking a significant step in crypto regulation.\n\n- **Bank Failure**: The OCC shuttered Kentland Federal Savings and Loan Association (Indiana), the nation's smallest standalone bank, due to critical undercapitalization from unsafe practices. This is the third bank failure in 2026."
        }
      ]
    }
  ]
}

Production notes:

  • tool_choice is auto — the model searches only when needed.
  • A single web_search_call may carry up to 5 queries (action.queries), run concurrently; action.query mirrors the first.
  • Searches and answers are stored and replayed on later previous_response_id turns.
  • Works with streaming and non-streaming. usage covers every inference round in the loop.
  • Don't assume the answer is output[0] or the only message item — select output items by type, and if more than one message is present, the last one is the final answer. See Extracting the assistant text.

Function calling

Define a function tool with the flattened Responses API shape — type, name, description, parameters, and strict sit directly on the tool object (unlike Chat Completions, which nests these under a function object). See Function calling for the concept, the tool calling flow, and the Chat Completions comparison.

{
  "model": "subq-savant-1.4",
  "input": "What are NVDA and MSFT trading at, and which moved more today?",
  "tools": [
    {
      "type": "function",
      "name": "get_stock_quote",
      "description": "Get the latest price for one stock ticker. Returns symbol, price, change_percent, and as_of.",
      "parameters": {
        "type": "object",
        "properties": {
          "symbol": {
            "type": "string",
            "description": "Ticker symbol, e.g. NVDA or MSFT."
          }
        },
        "required": ["symbol"],
        "additionalProperties": false
      },
      "strict": true
    }
  ]
}
cURLTypeScriptPython

When the model calls a function, the response contains a function_call output item — one per call, since the model may call the same function (or several different ones) in parallel within a single turn:

{
  "id": "resp_01a3f8c2...",
  "output": [
    {
      "id": "fc_01a3f8c2b9d14e67a8b5c3d0e2f14a79",
      "type": "function_call",
      "status": "completed",
      "call_id": "call_5b1f0a9c3d7e42a68c0f1b2d",
      "name": "get_stock_quote",
      "arguments": "{\"symbol\": \"NVDA\"}"
    },
    {
      "id": "fc_01a3f8c2b9d14e67a8b5c3d0e2f14a80",
      "type": "function_call",
      "status": "completed",
      "call_id": "call_9e4d2c7a1f6b48d3a05c7e91",
      "name": "get_stock_quote",
      "arguments": "{\"symbol\": \"MSFT\"}"
    }
  ]
}

Treat call_id as an opaque string and pass it back verbatim in function_call_output.

Execute the function in your application, then send its result back as a function_call_output. Include one function call output per call_id:

{
  "model": "subq-savant-1.4",
  "previous_response_id": "resp_01a3f8c2...",
  "input": [
    {
      "type": "function_call_output",
      "call_id": "call_5b1f0a9c3d7e42a68c0f1b2d",
      "output": "{\"symbol\":\"NVDA\",\"price\":210.96,\"change_percent\":4.03,\"as_of\":\"2026-07-17T17:42:03.000Z\"}"
    },
    {
      "type": "function_call_output",
      "call_id": "call_9e4d2c7a1f6b48d3a05c7e91",
      "output": "{\"symbol\":\"MSFT\",\"price\":402.18,\"change_percent\":1.12,\"as_of\":\"2026-07-17T17:42:03.000Z\"}"
    }
  ],
  "tools": [{ "type": "function", "name": "get_stock_quote", "description": "...", "parameters": { "type": "object", "properties": {} } }]
}

SubQ adds the function call and its output to the model's context. The next response may contain a final response or another function_call; repeat the tool calling flow until the model returns a message. Resend tools on each request where the model should be allowed to make another call. Function call outputs are accepted only for calls from the immediately preceding previous_response_id.

Full loop

A response can contain more function calls after receiving function call outputs, so keep looping until the model returns a final response — cap the number of rounds to avoid runaway loops. Execute every function_call in a turn with Promise.all, since the model may call in parallel:

TypeScriptPython

Request examples

Basic request with system instructions:

cURLTypeScriptPython

Response

A non-streaming request returns a Response object:

{
  "id": "resp_01939abc1234567890abcdef",
  "object": "response",
  "created_at": 1768000000,
  "completed_at": 1768000001,
  "status": "completed",
  "model": "subq-savant-1.4",
  "output": [
    {
      "id": "rs_019f42995c1e7b02a9d1c3e5f7a80b12",
      "type": "reasoning",
      "status": "completed",
      "summary": [],
      "content": [
        {
          "type": "reasoning_text",
          "text": "The user wants a plain-language summary and open questions. Define self-preferencing first, name the leading cases, then list what counsel still has to decide."
        }
      ]
    },
    {
      "id": "msg_019f42995d097843a2bbdada3a046f14",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "phase": "final_answer",
      "content": [
        {
          "type": "output_text",
          "text": "Self-preferencing means a platform favors its own products over competitors. Major cases since 2010 include the EU Google Shopping decision and related follow-on actions. Open questions for counsel often include how to define the relevant market and how to measure harm to rivals.",
          "annotations": [],
          "logprobs": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 100,
    "input_tokens_details": { "cached_tokens": 0 },
    "output_tokens": 104,
    "output_tokens_details": { "reasoning_tokens": 36 },
    "total_tokens": 204
  },
  "instructions": "You are a legal research assistant. Use plain language. Cite only facts in the conversation.",
  "previous_response_id": null,
  "tools": [],
  "text": { "format": { "type": "text" } },
  "error": null,
  "incomplete_details": null
}

Extracting the assistant text

The answer is not at a fixed index. A reasoning item usually comes first, so output[0].content[0].text returns the model's reasoning, not its answer. When tools run, output also contains web_search_call or function_call items, and the model may first emit a short text preamble, such as "Let me look that up.", as its own message item ahead of them. A turn can therefore hold two message items, for example [message, web_search_call, message]. Select message items by type, and take the last one as the final answer:

const messages = response.output.filter((item) => item.type === "message");
const text = messages.at(-1)?.content[0]?.text ?? "";

Save response.id for the next turn's previous_response_id.

Key response fields

FieldDescription
idStable response ID for previous_response_id.
statuscompleted on a finished response. When streaming, in_progress on response.created and failed on response.failed.
outputOrdered items for this turn: reasoning, message, web_search_call, and function_call, in the order the model produced them. See Output items.
usageToken counts for this request. Input includes the conversation history replayed for the turn.
instructions / tools / text / reasoningEcho of request fields.
metadataEcho of the request's metadata, or {} if none was sent.
conversationPresent on every turn: { "id": "conv_..." } identifying the conversation this response belongs to. See the Conversations API.

Other request fields such as store and tool_choice may also be echoed. temperature is not: Savant always samples at 1.

Output items

typeMeaning
reasoningThe model's reasoning for this turn, before the answer. Read content[].text where type is reasoning_text. summary is always empty. Show it or log it, but don't parse it as the answer.
messageAssistant text. Read content[].text where type is output_text. A turn may include more than one — a preamble before tool calls, and the final answer.
web_search_callA completed search. See action.queries / action.query.
function_callA function call generated by the model. See call_id, name, arguments, and Function calling.

Usage fields

FieldDescription
input_tokensTokens the model read for this turn: instructions, the replayed conversation history, and the new input. A web search loop counts them once per round. Billed at the input rate.
input_tokens_details.cached_tokensAlways 0 on this endpoint. Chat Completions reports cached tokens in prompt_tokens_details.cached_tokens.
output_tokensTokens generated in the response, including reasoning tokens. Billed at the output rate.
output_tokens_details.reasoning_tokensHow many of output_tokens were reasoning.
total_tokensSum of input and output tokens.

See Models for the rates.

Multi-turn conversations

Pass the id from a previous response as previous_response_id to continue. The server rebuilds history automatically — send only the new input and the prior response ID.

Turn 1:  POST /v1/responses
         { "model": "subq-savant-1.4", "input": "Who won the 2024 Nobel Prize in Physics?" }
         ← { "id": "resp_019f42fa...", "output": [{ "content": [{ "text": "John J. Hopfield and Geoffrey E. Hinton — for foundational work on machine learning with artificial neural networks." }] }] }

Turn 2:  POST /v1/responses
         { "model": "subq-savant-1.4", "input": "How does this connect to modern deep learning?", "previous_response_id": "resp_019f42fa..." }
         ← { "id": "resp_019f430a...", "previous_response_id": "resp_019f42fa...", "output": [{ "content": [{ "text": "Hopfield networks inspired associative memory and energy-based models; Hinton's backpropagation and deep networks underpin today's CNNs, transformers, and LLMs." }] }] }

Turn 3:  POST /v1/responses
         { "model": "subq-savant-1.4", "input": "Are there any other physics-inspired ML ideas not from these laureates?", "previous_response_id": "resp_019f430a..." }
         ← { "id": "resp_019f4319...", "previous_response_id": "resp_019f430a...", "output": [{ "content": [{ "text": "Yes — Boltzmann machines, diffusion models, renormalization-group analyses of deep networks, and thermodynamics-inspired views of SGD, among others." }] }] }

Chain turns by passing the latest id as previous_response_id. Resend instructions (and tools, if needed) on each turn — they are not inherited.

Continuing by conversation id

Every response includes a conversation.id. Pass it as conversation on a later turn to continue instead of using a specific response id:

{
  "model": "subq-savant-1.4",
  "input": "What is my name?",
  "conversation": "conv_abc123"
}

Use one or the other, not both — sending both conversation and previous_response_id returns 400.

Key behaviors:

  • History is branch-safe: branching from an older previous_response_id creates a new conversation branch rather than corrupting the existing chain.
  • usage.input_tokens reflects the full conversation history resent each turn, not just the new input.
  • Prior web searches are replayed into context so the model retains what it found.
  • If previous_response_id or conversation does not exist, the server returns 404 immediately, before inference.

To manage the conversation itself — seed it with history up front, add or read back items, retag its metadata, or delete it — see the Conversations API.

Streaming

When stream: true, the response is SSE (Content-Type: text/event-stream). Lifecycle events are always present; tools add output-item events.

Lifecycle: response.created → response.reasoning_text.delta… → response.output_text.delta… → response.completed

Output items (reasoning, and tools when they run): response.output_item.added → item progress events → response.output_item.done

event: response.created
data: { "type": "response.created", "sequence_number": 0, "response": { ... } }

event: response.output_item.added
data: { "type": "response.output_item.added", "sequence_number": 1, "output_index": 0, "item": { "id": "rs_019f...", "type": "reasoning", "status": "in_progress", "summary": [], "content": [] } }

event: response.reasoning_text.delta
data: { "type": "response.reasoning_text.delta", "sequence_number": 2, "item_id": "rs_019f...", "output_index": 0, "content_index": 0, "delta": "The user wants" }

event: response.reasoning_text.done
data: { "type": "response.reasoning_text.done", "sequence_number": 3, "item_id": "rs_019f...", "output_index": 0, "content_index": 0, "text": "The user wants a plain-language summary..." }

event: response.output_item.done
data: { "type": "response.output_item.done", "sequence_number": 4, "output_index": 0, "item": { "id": "rs_019f...", "type": "reasoning", "status": "completed", ... } }

event: response.output_text.delta
data: { "type": "response.output_text.delta", "sequence_number": 5, "item_id": "msg_019f...", "output_index": 1, "content_index": 0, "delta": "Self" }

event: response.completed
data: { "type": "response.completed", "sequence_number": 6, "response": { ... } }
Event typeWhen
response.createdFirst. Skeleton response (status: "in_progress"). Use response.id for the next turn.
response.reasoning_text.delta / doneReasoning text, streamed before the answer as its own reasoning item. Keep it out of the answer you assemble.
response.output_text.deltaText chunk of assistant text: the final answer, or a preamble before tool calls. Concatenate delta values per output item.
response.completedLast. Full output and usage.
response.failedLast, in place of response.completed, when the request fails after the stream opens. response.error has the code and message.
response.output_item.added / doneA structured output item (reasoning, web_search_call, or function_call) is created / finalized.
response.web_search_call.in_progress / searching / completedStatus pings while a search runs. Queries appear on output_item.done.
response.function_call_arguments.delta / doneStreamed arguments for a function_call. Concatenate delta values, then parse done's arguments as JSON.

Items are ordered by output_index, incrementing per item in the order the model produced them. With no tools, the reasoning item is index 0 and the answer message is index 1.

Treat unknown event types as ignorable. The stream ends after response.completed — not data: [DONE]. A : keepalive comment is emitted every 15s while the model is slow. If the stream ends with response.failed, or closes without response.completed, treat it as an error.

cURLTypeScriptPython

Structured outputs

Set text.format to constrain the model's output — see Structured outputs for schema design guidance. Three modes are supported:

ModeShapeGuarantee
text (default){ "type": "text" }Unconstrained text.
json_object{ "type": "json_object" }Output is valid JSON, but not constrained to any schema.
json_schema{ "type": "json_schema", "name": "...", "strict": true, "schema": { ... } }Output conforms to the supplied JSON Schema.

Note the flattened shape: name, strict, and schema sit directly on text.format — unlike Chat Completions, where they nest under response_format.json_schema.

{
  "model": "subq-savant-1.4",
  "input": "RFI-042 from Structural: Confirm rebar grade for Level 3 slab. Spec section 03 20 00 says Grade 60. Reply needed by 2026-07-18 before pour.",
  "text": {
    "format": {
      "type": "json_schema",
      "name": "rfi_extract",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "rfi_id": { "type": "string" },
          "from_trade": { "type": "string" },
          "question": { "type": "string" },
          "spec_section": { "type": "string" },
          "due_date": { "type": "string" }
        },
        "required": ["rfi_id", "from_trade", "question", "spec_section", "due_date"],
        "additionalProperties": false
      }
    }
  }
}

Example output, in content[0].text of the message item (parse the string to get the object):

{
  "rfi_id": "RFI-042",
  "from_trade": "Structural",
  "question": "Confirm rebar grade for Level 3 slab. Spec section 03 20 00 says Grade 60.",
  "spec_section": "03 20 00",
  "due_date": "2026-07-18"
}

The structured JSON arrives as ordinary assistant text in the message item, not at a fixed index — select it by type, then parse content[0].text to get the object. json_schema guarantees a valid shape; for reliable field values, put the facts in input and ask the model to extract them (as above).

json_object mode does not require the word "JSON" in your prompt.

For a yes/no, category, or rating judgment with probabilities, use the Decisions API.

Storage

By default every turn is saved so later turns can continue from it. Saved turns stay until you delete the conversation; see Data retention. Set store: false to run a turn without saving it. The turn can still read earlier history:

{
  "model": "subq-savant-1.4",
  "input": "Which of those medications interact with warfarin?",
  "previous_response_id": "resp_019f42fa...",
  "store": false
}

An unsaved turn isn't part of the history, and can't be continued from later.

Errors

{
  "error": {
    "message": "Response 'resp_xxx' not found.",
    "type": "server_error",
    "code": "response_not_found"
  }
}

Use code for programmatic handling — message text may change.

Shared codes with Chat Completions include invalid_api_key, insufficient_credits, validation_error, rate_limit_exceeded, and model_not_allowed (403, the model is not enabled for your organization; see SubQ Savant). The full shared list, including model and rate-limit errors, is under Chat Completions errors. Responses-specific:

HTTPcodeMeaning
400validation_errorinput_file is missing file_id, or the part used unsupported inline file_data
400unsupported_valuereasoning.effort is none. Reasoning cannot be turned off; see Reasoning effort
404response_not_foundprevious_response_id does not exist in the store
404conversation_not_foundconversation does not exist or belongs to another organization
404file_not_foundfile_id does not exist or is owned by another organization

See the Conversations API for conversation-specific error codes.

Next steps