Responses and Compact are two independent OpenAI-compatible JSON contracts. Model IDs, capabilities, and availability follow the current configuration in the Models API and Model Market.
https://api.tokensmarket.ai/v1POST /responsesThe endpoint remains fixed. Use the parameter documentation on this page to replace the model ID and request data.
${base_url}/responses${base_url}/responses/compactResponses supports full input, sessions, tools, and output controls. Set background:false; public retrieve, cancel, and delete lifecycle operations are not guaranteed.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | Exact model ID. |
input | string | array | Yes | — | A string or an array of Responses input items. |
instructions | string | No | — | System instructions for this request. |
conversation | string | object | No | — | References an existing conversation when supported by the protocol. |
include | string[] | No | — | Additional protocol fields to return. |
max_output_tokens | integer | No | — | Maximum output tokens. |
metadata | object | No | — | Request metadata. |
reasoning | object | No | — | Reasoning configuration when supported by the model. |
context_management | object | No | — | Context management settings when supported by the model. |
max_tool_calls | integer | No | — | Maximum number of tool calls allowed when supported by the model. |
moderation | object | string | No | — | Content moderation controls when supported by the model. |
parallel_tool_calls | boolean | No | — | Whether to allow parallel tool calls. |
previous_response_id | string | No | — | Associates this request with the previous Responses response. |
prompt | string | object | No | — | Reuses a prompt template supported by the model. |
prompt_cache_key | string | No | — | Prompt cache key. |
prompt_cache_options | object | No | — | Prompt cache options. |
prompt_cache_retention | string | No | — | Prompt cache retention policy. |
safety_identifier | string | No | — | Safety identifier. |
service_tier | string | No | — | Service tier when supported by the model. |
store | boolean | No | — | Whether to store the response according to the protocol. |
stream_options | object | No | — | Streaming output options. |
temperature | number | No | — | Sampling temperature. |
tool_choice | string | object | No | — | Tool selection strategy. |
top_logprobs | integer | No | — | Number of candidate token log probabilities to return. |
top_p | number | No | — | Nucleus sampling threshold. |
truncation | string | No | — | Truncation strategy when the context exceeds its limit. |
user | string | No | — | Deprecated end-user identifier. Options / constraints: Deprecated. |
text | object | No | — | Text format and structured output configuration. |
tools | array | No | — | Tools the model can call when supported. |
stream | boolean | No | — | Set to true to enable SSE. |
background | boolean | No | false | We recommend setting this explicitly to false. |
Compact accepts an independent JSON request body only. It does not use Session routing and does not promise background task lifecycle operations.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | Exact model ID. |
input | string | array | Yes | — | Input to compact. |
instructions | string | No | — | Compaction requirements or output instructions. |
previous_response_id | string | No | — | Associates this request with the previous Responses response. |
prompt_cache_key | string | No | — | Prompt cache key. |
prompt_cache_retention | string | No | — | Prompt cache retention policy. |
service_tier | string | No | — | Service tier when supported by the model. |
extra_body.provider | object | No | — | Optional provider routing configuration. |
This endpoint supports routing and soft sticky Sessions. Session ID is limited to 256 characters and is read in this order: top-level session_id, extra_body.session_id, then X-Session-Id.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
extra_body.provider | object | No | — | Container for provider filters, ranges, sorting, and priority. Options / constraints: ignore, *_range, only, sort, order, allow_fallbacks. |
session_id | string | No | — | Top-level Session ID for consecutive conversations or tasks on the same model. Options / constraints: Maximum 256 characters. |
extra_body.session_id | string | No | — | Session ID used when top-level session_id is not provided. Options / constraints: Maximum 256 characters. |
X-Session-Id | string | No | — | Request header used when no Session ID is provided in the body. Options / constraints: Maximum 256 characters. |
extra_body.provider.allow_fallbacks | boolean | No | — | Defaults to false when only is non-empty; otherwise defaults to true. Options / constraints: true can relax only, ranges, sort, and order; it never relaxes ignore, permissions, endpoint capabilities, or channel availability. |
The following fields are HTTP response headers, not JSON, SSE event, or binary response body fields. They are not guaranteed when a network failure prevents the request from reaching the gateway.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
X-Client-Request-Id | string | No | — | Echoed when supplied by the caller; the gateway does not generate it automatically when omitted. |
X-Upstream-Request-Id | string | No | — | Usually used for gateway request tracing; it does not represent the provider's original request ID. |
The error body follows the selected protocol. HTTP 400 means invalid_request, HTTP 402 means insufficient available balance or quota, and HTTP 429 means rate limiting.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
error.code | string | No | — | Machine-readable error code defined by the protocol. |
error.message | string | No | — | Human-readable error description. |
A normal OpenAI Responses stream sends its protocol termination event and then ends with data: [DONE]. Clients should handle deltas, usage, and in-stream errors. An interrupted stream is not guaranteed to deliver the termination event or data: [DONE].
The examples use placeholders. Replace them with a currently available model ID from the model details page, and keep your API Key in a server-side environment variable.
curl https://api.tokensmarket.ai/v1/responses \
-H "Authorization: Bearer $TOKEN_MARKET_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Session-Id: conversation-<UUID>" \
-d '{
"model": "<MODEL_ID>",
"input": "Summarize the attached policy in three bullets.",
"instructions": "Use concise language.",
"stream": true,
"extra_body": {"provider": {"sort": ["latency"]}}
}'