Skip to content
English

Responses API

The Responses API fits Codex, agent workflows, tool use, and applications that continue a conversation. OpenAI recommends Responses for new projects; existing Chat Completions clients can keep using their current endpoint.

POST https://api.nexinfer.com/v1/responses

Legacy clients may also call POST /responses. New integrations should use the standard /v1 path.

Production acceptance passes both non-streaming JSON and streaming SSE. Omit stream or set it to false for one complete JSON Response; set it to true for typed SSE events.

Terminal window
curl https://api.nexinfer.com/v1/responses \
-H "Authorization: Bearer $NEXINFER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"input": "Reply with OK.",
"stream": false
}'

Responses use an output array, not the Chat Completions choices shape.

Field Purpose
model A model ID allowed by the key
input Text or structured input Items
instructions Top-level instructions for this request
stream Return typed SSE events when true
tools / tool_choice Declare tools and selection behavior
reasoning Reasoning configuration; model-dependent
max_output_tokens Limit output tokens for this response
prompt_cache_key Stable routing key for requests that share an exact long prefix
previous_response_id Continue from a previous Response
service_tier Service tier; availability depends on the selected model

NexInfer does not intentionally remove or rewrite tools, reasoning, previous_response_id, prompt_cache_key, service_tier, or context fields. Actual support still depends on the model, Key scope, and model provider.

Do not set truncation: auto unless dropping the oldest Items is explicitly acceptable. NexInfer does not enable it for you; OpenAI’s documented default is disabled, which returns an error instead of silently dropping context.

Terminal window
curl -N https://api.nexinfer.com/v1/responses \
-H "Authorization: Bearer $NEXINFER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"input": "Give one short deployment check.",
"stream": true
}'

Handle SSE by event type, including text deltas and completion events. Do not concatenate every data: line as plain text. After a dropped connection, do not blindly replay tool calls that may have side effects.

A model tool request is commonly returned as a function_call Item. After executing it, send a function_call_output with the matching call ID in the next request. Validate arguments and use idempotency controls for external writes.

The current production models reject previous_response_id and service_tier: auto. Omit both for production calls. Their presence in the OpenAI contract means NexInfer preserves the fields; it does not mean the selected model supports them.

When a supported model provides continuation, the OpenAI request shape is:

{
"model": "YOUR_MODEL_ID",
"previous_response_id": "resp_...",
"input": "Now summarize that in one sentence."
}

Top-level instructions apply only to the current request. They are not automatically inherited through previous_response_id; send persistent instructions again when needed.

For GPT-5.6 requests with a repeated prefix, keep static instructions, tools, and examples at the beginning, then reuse a stable prompt_cache_key. Do not enable a global Session Binding rule. Confirm cache behavior from usage.input_tokens_details.cached_tokens and cache_write_tokens; an identical key without an identical prefix is not a cache hit.

  • 400: check Item shapes, conversation IDs, and model-supported fields.
  • previous_response_id or service_tier error: omit the unsupported field; do not translate it into another value.
  • 401/403: check the key, base URL, model permission, and group.
  • 429: check balance or model-provider rate limits and follow retry-after.
  • Stream interruption: record the request ID and time, not the full key or private context.

Official references: Migrate to Responses · Streaming Responses · Function calling · Prompt caching