Skip to main content
POST
cURL
/v1/responses accepts compressed request bodies (Content-Encoding: gzip, deflate, or br) on authenticated JSON requests — useful for long conversations, where compressed uploads cut time-to-first-token. See Compressed Request Bodies.

Overview

The /v1/responses API is an OpenAI Responses API-compatible endpoint for creating AI model responses. It supports:
  • Stateless and stateful (conversation threading) chat completions
  • Streaming responses via Server-Sent Events (SSE)
  • Background (async) processing for long-running requests
  • Response storage and retrieval
  • Function/tool calling support
  • Multimodal inputs (images, video, files) for supported models
Recommended base URL: Use https://api.nano-gpt.com/api/v1 for Responses API clients. This dedicated API host accepts request bodies up to NanoGPT’s 32 MiB application limit and avoids the smaller ingress limit on the website host. It is especially important for Codex and other long-running agents that resend accumulated conversation state.
Accountless x402 payments: Non-streaming POST /api/v1/responses requests can be quoted without an account or API key on supported deployments when the initial quote request includes x-x402: true. Streaming and background Responses have implementation coverage but are not part of the stable public accountless contract. This endpoint supports accountless x402 payments where listed by GET /api/v1/x402/endpoints, including Lightning L402 when advertised. See Accountless x402 API Payments for the full flow.
Provider selection is available for supported open-source models. X-Provider explicitly selects a provider for the request and is always billed pay-as-you-go at the selected provider’s price, including provider-selection markup. For provider-selection-capable models, model may include routing preference suffixes such as :fast (alias for :speed) and :cheap (alias for :price). These are billed like explicit provider selection and follow the same conflict rules. For subscription users, sending X-Provider bypasses subscription coverage for that request; X-Billing-Mode: paygo is only needed when forcing pay-as-you-go without an explicit provider or when saved provider preferences should apply to subscription-included traffic. See Provider Selection, Model Suffixes, and Pay-As-You-Go Billing Override.
Advisor extension: Non-streaming pay-as-you-go API-key requests can include an advisor object so the executor model can consult one different model before returning its final answer. Use mode: "auto" to let the executor decide or mode: "required" to require a consultation attempt. Each completed model phase is billed separately. Advisor is a NanoGPT extension, not part of the standard OpenAI request schema. See Advisor.
Hosted tool search: Compatible models can discover relevant functions from large deferred catalogs. Add nanogpt:tool_search and mark functions with defer_loading: true. This pilot is Responses-only. See Hosted tool search.

Authentication

Use an API key for normal authenticated billing:
Or alternatively:
For API-key requests, you can optionally pass x-team-id to choose team context when team defaults are evaluated (for example, retention defaults). For supported accountless x402 requests, omit Authorization and x-api-key, and include x-x402: true to receive a payment quote. The advertised schemes, including Lightning L402 when enabled, are listed by GET /api/v1/x402/endpoints. If you receive 401 missing_api_key immediately, check that the initial quote request includes x-x402: true. Without that header, NanoGPT does not enter the x402 quote flow.

Endpoints

  • POST /v1/responses - Create a new response from the model
  • GET /v1/responses - Returns endpoint information
  • GET /v1/responses/{id} - Retrieve a stored response by ID
  • DELETE /v1/responses/{id} - Delete a stored response (soft delete)

Batch processing

For high-volume work that does not need an immediate response, /v1/responses requests can be submitted through the Batch API. Responses batches are non-streaming, stateless, use direct OpenAI models, and run with store: false. Function and custom tools, structured text output, and remote or data-URL images are supported; video input remains unsupported in Responses Batch. Stateful features, provider-hosted tools, file references, and NanoGPT-only request extensions are not.

BYOK Encryption (Stored Responses)

If you set store: true, you can optionally encrypt the stored response at rest using your own key or passphrase. To encrypt a stored response, include one of these headers on POST /v1/responses:
  • x-encryption-key: YOUR_ENCRYPTION_KEY
  • x-encryption-passphrase: YOUR_PASSPHRASE
When retrieving or deleting an encrypted response, include the same header you used at creation time. Example:

Create Response

Request

Request Body

Reproducibility guidance

Seeded generation is best-effort. To reduce avoidable variation:
  • Keep the exact model, input, instructions, tools, and sampling settings unchanged.
  • Select a specific provider where possible.
  • Disable automatic fallbacks where supported when route consistency matters.
  • Use a low or zero temperature where supported.
  • Do not treat seeded output as byte-identical. Record provider, route, and system-fingerprint metadata when NanoGPT exposes reliable values.
NanoGPT will publish a seed-support matrix when reliable route-level capability data is available. Until then, do not infer seed support from endpoint compatibility alone.

Response Storage And Retention

NanoGPT supports local Responses API storage for features that need server-side state, including response retrieval, previous_response_id threading, and background processing. Set store: false to disable stored Responses API data for a request:
When response storage is enabled and no override applies, stored Responses API records are retained for up to 7 days. You can override retention per request with either retentionDays or retention_days:
or:
A retention value of 0 means do not retain stored response data for that request:
Valid per-request retention values are integers from 0 to 365 days, or null to use the next configured default. If both retentionDays and retention_days are sent, they must match. Team and user defaults are configurable through API endpoints, not the main web Settings page today. Team owners/admins can set responses_retention_days with PATCH /api/teams/{teamUuid}/settings; users can set responsesRetentionDays with POST /api/user/responses-retention. See Teams: response retention defaults.

Retention Resolution

Effective retention for /v1/responses resolves in this order:
  1. Request override (retention_days / retentionDays)
  2. Team setting (responses_retention_days)
  3. User setting (responsesRetentionDays)
  4. Platform default (7 days)
Rules:
  • retention_days and retentionDays accept integer values 0..365, or null.
  • null means “no request override” and falls back to team/user/platform defaults.
  • If both request fields are provided, they must match.
  • Invalid retention values return 400 with invalid_request_error.
  • 0 enables zero-retention behavior for that request.
  • Existing clients that omit retention fields keep default behavior (team/user/platform retention resolution).
With effective retention 0:
  • previous_response_id is rejected.
  • background is rejected.
API-key team context for retention defaults:
  • If x-team-id is present and the caller is a member, that team is used.
  • Otherwise, the API uses the caller session’s default team (default_team_uuid / default_team_id) when membership is valid.

Input Types

The input parameter accepts either a simple string or an array of input items.

Simple String Input

Array Input

Input Item Types

Message Item

Supported roles: user, assistant, system, developer Content can be a string or an array of content parts:

Content Part Types

Image Input

The detail parameter can be: auto, low, or high.

Video Input

Use input_video for video understanding on a model that advertises video input:
video_url may be a public HTTPS URL or a valid data:video/*;base64,... URL. Chat-style video_url content parts are accepted as a compatibility alias, but input_video is the canonical Responses shape. input_file is treated as video only when NanoGPT can safely identify it from a video/* MIME type, video data URL, or recognized video filename/URL extension. PDFs, audio files, and unknown or opaque files are not silently treated as video. An opaque file_id is not resolved for Responses video input; it returns video_file_id_not_supported. Video is currently rejected in Responses Batch. Segment offsets are validated but no current public text-model route can honor them; valid offsets return video_segment_not_supported.

Function Call Item

Function Call Output Item

Tools

Provide function tools and built-in tools the model can use:

Function Tool

Define functions that the model can call:
For large function catalogs, add one nanogpt:tool_search entry (or its tool_search alias) and mark discoverable functions with defer_loading: true:
The search activity is returned as tool_search_call. A selected function is still returned as a normal function_call; your client executes it and sends function_call_output. See Hosted tool search for limits, billing, authorization, and compatibility.

Web Search Tool

File Search Tool

Code Interpreter Tool

MCP Tool

Image Generation Tool

Tool Choice

Use allowed_tools to restrict which tools the model may choose from:

Function Tool Normalization

Function tools in responses always include nullable fields:

Reasoning Configuration

Use reasoning to control depth and visibility of reasoning output:

Text/Format Configuration

Control response format and verbosity:

Text Parameter Structure

Format Types

  • { "type": "text" } - Plain text (default)
  • { "type": "json_object" } - JSON object output
  • { "type": "json_schema", "json_schema": { ... } } - Structured JSON with schema

Verbosity Values

  • low - Short, compact responses
  • medium - Balanced detail
  • high - Most detailed output

JSON Schema Format

Response Format

Successful Response

Response Fields

All fields below are always present; nullable values indicate an option was not set.

Usage Object

The usage object always includes token details:

Response Status Values

reasoning Response Field

text Response Field (Resolved)

Output Item Types

All output items include a status field.

Message Output

Function Call Output

Hosted Tool Search Call

This item records discovery activity. It does not execute or approve a client function. A revealed function selected by the model appears separately as function_call.

Reasoning Output (reasoning-capable models)

Web Search Call Output

Image Generation Call Output

Computer Call Output

Output Item Status Values

Output Text Parts

Output text parts include annotations and logprobs:

Annotation Types

URL Citation

File Citation

File Path

Streaming

See also: Streaming Protocol (SSE). Enable streaming to receive incremental response updates:

Streaming Response

The response is delivered as Server-Sent Events (SSE):

Streaming Event Types

Updated Event Fields

  • All content/output events include item_id for the parent output item.
  • Text delta/done events include logprobs.
Example response.output_text.delta:

Conversation Threading

Chain responses together for multi-turn conversations. You can use previous_response_id or the conversation object (id or messages) to manage context.

First Request

Response includes id: "resp_abc123"

Follow-up Request

The model has access to the conversation history and responds: “Your name is Alice.” Note: previous_response_id requires authentication, store: true on previous responses, and effective retention greater than 0.

Background Mode

For long-running requests, use background mode to receive an immediate response and poll for results.

Initiate Background Request

Immediate Response (202 Accepted)

Poll for Completion

Keep polling until status is completed, failed, or incomplete. Constraints:
  • Cannot be combined with stream: true
  • Requires authentication
  • Effective retention must be greater than 0
  • Maximum processing time: approximately 800 seconds

Retrieve Response

Response

Returns the full response object (same format as POST response).

Errors

  • 404 - Response not found or belongs to different account
  • 401 - Authentication required/invalid

Delete Response

Response

Error Handling

Error Response Format

HTTP Status Codes

Common Error Codes

Complete Examples

Simple Text Completion

Multi-turn Conversation

Streaming Response

Per-request Retention Override

Function Calling

Submitting Tool Results

Image Input (Vision)

Video Input (Understanding)

Video input is separate from video generation and is available only on models advertising video capability. See the Video Input guide for source rules, limits, YouTube behavior, and validation errors.

JSON Output

Background Processing

Limitations

  1. Deep research models: Deep research variants are not supported.
  2. GPU-TEE streaming: Streaming is not supported for GPU-TEE models. Use /v1/chat/completions for these models.
  3. Background mode: Maximum duration is approximately 800 seconds.
  4. Metadata limits: Maximum 16 keys, 64 character key names, 512 character values.
  5. Hosted tool search: Available only on compatible models in foreground Responses requests. It cannot currently be combined with background mode or other hosted built-ins. See Hosted tool search.

Service tiers (flex and priority)

Set service_tier to request a non-default capacity tier on providers that support service tiers:
  • auto or omitted: use NanoGPT’s normal routing and the provider default.
  • default: request the provider’s standard tier where the provider accepts an explicit default value.
  • flex: request lower-cost, variable-capacity processing where supported.
  • priority: request higher-cost priority processing where supported.
Behavior notes:
  • Service tier availability is model- and provider-specific. Model pages show which tiers are supported.
  • Flex and priority tiers are only applied when the routed provider supports them.
  • Header provider overrides (like X-Provider) and explicit provider selection are honored for pricing and x402 estimates.
  • Provider-native web search can force routing; tier pricing follows that routing.
  • If you explicitly force a provider that does not support service tiers, the requested tier may be ignored by the upstream provider, or routing and pricing may differ from the default route.
Billing note:
  • Flex tier billing uses flex pricing where applicable.
  • Priority tier billing uses priority pricing where applicable.
  • High-context pricing may also apply for models and providers with separate high-context SKUs, such as es2k pricing for GPT-5.5/GPT-5.4 where available.

Example: flex tier

Example: priority tier

Response Headers

All responses include:

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

X-Provider
string

Optional explicit provider override for supported open-source models (case-insensitive). Explicit provider selection is billed pay-as-you-go at the selected provider's price, including provider-selection markup; for subscription users it bypasses subscription coverage for that request.

X-Billing-Mode
string

Optional billing override to force pay-as-you-go without an explicit provider, or to apply saved provider preferences to subscription-included traffic (e.g., paygo). Header name is case-insensitive.

X-Team-Id
string

Optional team context override for API-key requests. If provided, it must reference a team the caller belongs to.

x-x402
enum<string>

Set to true on unauthenticated accountless x402 quote requests. Without this header, unauthenticated requests return 401 missing_api_key.

Available options:
true

Body

application/json

Parameters for the response request

model
string
required

Model ID to use for the response. Provider-selection-capable models may include routing preference suffixes such as ':fast', ':speed', ':cheap', ':price', ':latency', ':throughput', ':floor', ':tools', ':caching', ':cache', or ':cached'.

input
required

Prompt string or array of input items. Use an input_video content part with a video_url field for video understanding.

billing_mode
string

Billing override to force pay-as-you-go without an explicit provider, or to apply saved provider preferences to subscription-included traffic. Accepted values (case-insensitive): paygo, pay-as-you-go, pay_as_you_go, paid, payg.

billingMode
string

Alias for billing_mode.

instructions
string

System instructions for the model

max_output_tokens
integer

Maximum tokens in the response

Required range: x >= 16
temperature
number

Sampling temperature (not supported by reasoning models)

Required range: 0 <= x <= 2
top_p
number

Nucleus sampling parameter

Required range: 0 <= x <= 1
tools
object[]

Tools available to the model. The Responses-only hosted tool-search pilot accepts one nanogpt:tool_search or tool_search entry plus function tools marked defer_loading: true on compatible models.

tool_choice

How the model should use tools

parallel_tool_calls
boolean

Allow multiple tool calls in parallel

stream
boolean
default:false

Enable streaming responses

store
boolean
default:false

Store the response locally for later retrieval/threading/background processing. Set false to disable stored Responses API data for the request.

retention_days
integer | null

Per-request retention override in days (0..365). Use 0 to disable retention for the request; use null to fall back to configured defaults.

Required range: 0 <= x <= 365
retentionDays
integer | null

Alias for retention_days (0..365). If both are provided, values must match.

Required range: 0 <= x <= 365
previous_response_id
string

Link to previous response for conversation threading

reasoning
object

Reasoning configuration. Setting reasoning.effort to any non-none value explicitly requests reasoning mode.

text
object

Text/format configuration

metadata
object

Custom metadata

truncation
enum<string>

Truncation strategy

Available options:
auto,
disabled
user
string

Unique user identifier

seed
integer

Optional integer forwarded on model/provider routes that support seeded sampling. This may improve reproducibility but does not guarantee identical output. Results can change if NanoGPT selects a different automatic or fallback route, or if the provider changes its backend.

background
boolean

Enable background/async processing

service_tier
enum<string>

Optional service tier: "auto", "default", "flex", or "priority". Use "flex" for lower-cost variable-capacity processing or "priority" for higher-cost priority processing where supported by the routed model/provider.

Available options:
auto,
default,
flex,
priority
advisor
object

Allows the executor model to consult one different advisor model. Auto mode lets the executor decide whether to consult; required mode forces one consultation request. Advisor is non-streaming and available only for platform-billed pay-as-you-go API-key requests. Subscriptions, BYOK, accountless x402, Private Mode, inline moderation, client tools, structured outputs, memory, and server-side content enhancements are rejected before orchestration. Each completed executor, advisor, and continuation phase is billed separately.

Response

Response created

Response object returned by the Responses API

id
string
object
string
created_at
integer
model
string
status
enum<string>
Available options:
queued,
in_progress,
completed,
incomplete,
failed,
cancelled
output
object[]
output_text
string
usage
object
error
object
incomplete_details
object
metadata
object
service_tier
string
advisor
object

Advisor orchestration status and per-phase usage. Present on responses to requests that use the Advisor extension.