Responses API
This page documents the 24 gateway endpoints tagged responses in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.
| Method | Path | Summary |
|---|---|---|
| POST | /openai/v1/responses | Create a model response |
| POST | /responses | Create a model response |
| POST | /v1/responses | Create a model response |
| GET | /cursor/v1/models | List the models a Cursor client can use |
| GET | /cursor/models | List the models a Cursor client can use |
| POST | /cursor/chat/completions | Chat completion for Cursor clients |
| GET | /openai/v1/responses/{response_id} | Read a stored response |
| DELETE | /openai/v1/responses/{response_id} | Delete a stored response |
| GET | /responses/{response_id} | Read a stored response |
| DELETE | /responses/{response_id} | Delete a stored response |
| GET | /v1/responses/{response_id} | Read a stored response |
| DELETE | /v1/responses/{response_id} | Delete a stored response |
| GET | /openai/v1/responses/{response_id}/input_items | List the input items of a response |
| GET | /responses/{response_id}/input_items | List the input items of a response |
| GET | /v1/responses/{response_id}/input_items | List the input items of a response |
| POST | /openai/v1/responses/compact | Compact a long conversation |
| POST | /responses/compact | Compact a long conversation |
| POST | /v1/responses/compact | Compact a long conversation |
| POST | /openai/v1/responses/input_tokens | Count the input tokens of a Responses API request |
| POST | /responses/input_tokens | Count the input tokens of a Responses API request |
| POST | /v1/responses/input_tokens | Count the input tokens of a Responses API request |
| POST | /openai/v1/responses/{response_id}/cancel | Cancel a background response |
| POST | /responses/{response_id}/cancel | Cancel a background response |
| POST | /v1/responses/{response_id}/cancel | Cancel a background response |
Endpoints
POST /openai/v1/responses
Create a model response
Sends a request to a model through the gateway in the OpenAI Responses API format and returns the model's
answer, as one JSON object or as server sent events when stream is true. Any key allowed to call the model
may use it; the gateway applies the key's model access, budgets, rate limits, guardrails and logging, and the
request's spend is recorded against the key, team and user.
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses
Supports background mode with polling_via_cache for partial response retrieval. When background=true and polling_via_cache is enabled, returns a polling_id immediately and streams the response in the background, updating Redis cache.
**Normal request**
curl -X POST http://localhost:4000/v1/responses -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": "Tell me about AI"
}'
**Background request with polling**
curl -X POST http://localhost:4000/v1/responses -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": "Tell me about AI",
"background": true
}'
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
x-spanway-routing-skips | header | enum: "true" | No | Send true to get the candidates the router skipped in the answer headers. See https://docs.spanway.ai/docs/proxy/routing_headers |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
context_fit | boolean or "middle_out" or object or null | No | How to fit a prompt that is longer than the context window. true or middle_out drops the oldest middle turns until it fits, false turns it off for this request |
transforms | array of string | No | Another way to ask for context fit: ["middle-out"] turns it on and [] turns it off |
include | array of enum: "file_search_call.results", "web_search_call.results", "web_search_call.action.sources", "message.input_image.image_url", "computer_call_output.output.image_url", "code_interpreter_call.outputs", "reasoning.encrypted_content", "message.output_text.logprobs" or null | No | Include |
instructions | string or null | No | Instructions |
max_output_tokens | integer or null | No | Max Output Tokens |
metadata | object or null | No | Metadata |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
previous_response_id | string or null | No | Previous Response Id |
reasoning | Reasoning or null | No | |
store | boolean or null | No | Store |
background | boolean or null | No | Background |
stream | boolean or null | No | Stream |
temperature | number or null | No | Temperature |
text | ResponseTextConfigParam or null | No | |
tool_choice | enum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or null | No | Tool Choice |
tools | array of FunctionToolParam or FileSearchToolParam or ComputerToolParam or ComputerUsePreviewToolParam or WebSearchToolParam or Mcp or CodeInterpreter or ImageGeneration or LocalShell or FunctionShellToolParam or CustomToolParam or NamespaceToolParam or ToolSearchToolParam or WebSearchPreviewToolParam or ApplyPatchToolParam or ResponsesComputerToolParam or ShellToolParam or null | No | Tools |
top_p | number or null | No | Top P |
truncation | enum: "auto", "disabled" or null | No | Truncation |
user | string or null | No | User |
service_tier | string or null | No | Service Tier |
safety_identifier | string or null | No | Safety Identifier |
prompt | PromptObject or null | No | |
max_tool_calls | integer or null | No | Max Tool Calls |
prompt_cache_key | string or null | No | Prompt Cache Key |
prompt_cache_retention | string or null | No | Prompt Cache Retention |
prompt_cache_options | PromptCacheOptions or null | No | |
stream_options | ResponsesAPIStreamOptions or null | No | |
top_logprobs | integer or null | No | Top Logprobs |
partial_images | integer or null | No | Partial Images |
context_management | array of ContextManagementEntry or null | No | Context Management |
input | string or array of EasyInputMessageParam or Message or ResponseOutputMessageParam or ResponseFileSearchToolCallParam or ResponseComputerToolCallParam or ComputerCallOutput or ResponseFunctionWebSearchParam or ResponseFunctionToolCallParam or FunctionCallOutput or ToolSearchCall or ResponseToolSearchOutputItemParamParam or ResponseReasoningItemParam or ResponseCompactionItemParamParam or ResponsesAPIRequestParams_ImageGenerationCall or ResponseCodeInterpreterToolCallParam or LocalShellCall or LocalShellCallOutput or ShellCall or ShellCallOutput or ApplyPatchCall or ApplyPatchCallOutput or McpListTools or McpApprovalRequest or ResponsesAPIRequestParams_McpApprovalResponse or McpCall or ResponseCustomToolCallOutputParam or ResponseCustomToolCallParam or ItemReference | Yes | Input |
model | string | Yes | Model |
Example request:
curl -X POST "http://localhost:4000/openai/v1/responses" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"input": "What does an AI gateway do?"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The finished response, or server sent events when stream is true | application/json ResponsesAPIResponse |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | openai__types__responses__response__IncompleteDetails or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of ResponseOutputMessage or ResponseFileSearchToolCall or ResponseFunctionToolCall or ResponseFunctionToolCallOutputItem or ResponseFunctionWebSearch or ResponseComputerToolCall or ResponseComputerToolCallOutputItem or ResponseReasoningItem or ResponseToolSearchCall or ResponseToolSearchOutputItem or ResponseCompactionItem or ImageGenerationCall or ResponseCodeInterpreterToolCall or LocalShellCall or LocalShellCallOutput or ResponseFunctionShellToolCall or ResponseFunctionShellToolCallOutput or ResponseApplyPatchToolCall or ResponseApplyPatchToolCallOutput or McpCall or McpListTools or McpApprovalRequest or McpApprovalResponse or ResponseCustomToolCall or ResponseCustomToolCallOutputItem or object or array of GenericResponseOutputItem or OutputCodeInterpreterCall or OutputFunctionToolCall or OutputImageGenerationCall or ResponseFunctionToolCall or ResponseFunctionWebSearch or CustomToolCallOutputItem | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or null | No | Tool Choice |
tools | array of openai__types__responses__function_tool__FunctionTool or openai__types__responses__file_search_tool__FileSearchTool or ComputerTool or ComputerUsePreviewTool or WebSearchTool or Mcp or CodeInterpreter or ImageGeneration or LocalShell or FunctionShellTool or CustomTool or NamespaceTool or ToolSearchTool or WebSearchPreviewTool or ApplyPatchTool or array of ResponseFunctionToolCall or array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | ResponseTextConfigParam or object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | ResponseAPIUsage or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
POST /responses
Create a model response
Sends a request to a model through the gateway in the OpenAI Responses API format and returns the model's
answer, as one JSON object or as server sent events when stream is true. Any key allowed to call the model
may use it; the gateway applies the key's model access, budgets, rate limits, guardrails and logging, and the
request's spend is recorded against the key, team and user.
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses
Supports background mode with polling_via_cache for partial response retrieval. When background=true and polling_via_cache is enabled, returns a polling_id immediately and streams the response in the background, updating Redis cache.
**Normal request**
curl -X POST http://localhost:4000/v1/responses -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": "Tell me about AI"
}'
**Background request with polling**
curl -X POST http://localhost:4000/v1/responses -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": "Tell me about AI",
"background": true
}'
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
x-spanway-routing-skips | header | enum: "true" | No | Send true to get the candidates the router skipped in the answer headers. See https://docs.spanway.ai/docs/proxy/routing_headers |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
context_fit | boolean or "middle_out" or object or null | No | How to fit a prompt that is longer than the context window. true or middle_out drops the oldest middle turns until it fits, false turns it off for this request |
transforms | array of string | No | Another way to ask for context fit: ["middle-out"] turns it on and [] turns it off |
include | array of enum: "file_search_call.results", "web_search_call.results", "web_search_call.action.sources", "message.input_image.image_url", "computer_call_output.output.image_url", "code_interpreter_call.outputs", "reasoning.encrypted_content", "message.output_text.logprobs" or null | No | Include |
instructions | string or null | No | Instructions |
max_output_tokens | integer or null | No | Max Output Tokens |
metadata | object or null | No | Metadata |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
previous_response_id | string or null | No | Previous Response Id |
reasoning | Reasoning or null | No | |
store | boolean or null | No | Store |
background | boolean or null | No | Background |
stream | boolean or null | No | Stream |
temperature | number or null | No | Temperature |
text | ResponseTextConfigParam or null | No | |
tool_choice | enum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or null | No | Tool Choice |
tools | array of FunctionToolParam or FileSearchToolParam or ComputerToolParam or ComputerUsePreviewToolParam or WebSearchToolParam or Mcp or CodeInterpreter or ImageGeneration or LocalShell or FunctionShellToolParam or CustomToolParam or NamespaceToolParam or ToolSearchToolParam or WebSearchPreviewToolParam or ApplyPatchToolParam or ResponsesComputerToolParam or ShellToolParam or null | No | Tools |
top_p | number or null | No | Top P |
truncation | enum: "auto", "disabled" or null | No | Truncation |
user | string or null | No | User |
service_tier | string or null | No | Service Tier |
safety_identifier | string or null | No | Safety Identifier |
prompt | PromptObject or null | No | |
max_tool_calls | integer or null | No | Max Tool Calls |
prompt_cache_key | string or null | No | Prompt Cache Key |
prompt_cache_retention | string or null | No | Prompt Cache Retention |
prompt_cache_options | PromptCacheOptions or null | No | |
stream_options | ResponsesAPIStreamOptions or null | No | |
top_logprobs | integer or null | No | Top Logprobs |
partial_images | integer or null | No | Partial Images |
context_management | array of ContextManagementEntry or null | No | Context Management |
input | string or array of EasyInputMessageParam or Message or ResponseOutputMessageParam or ResponseFileSearchToolCallParam or ResponseComputerToolCallParam or ComputerCallOutput or ResponseFunctionWebSearchParam or ResponseFunctionToolCallParam or FunctionCallOutput or ToolSearchCall or ResponseToolSearchOutputItemParamParam or ResponseReasoningItemParam or ResponseCompactionItemParamParam or ResponsesAPIRequestParams_ImageGenerationCall or ResponseCodeInterpreterToolCallParam or LocalShellCall or LocalShellCallOutput or ShellCall or ShellCallOutput or ApplyPatchCall or ApplyPatchCallOutput or McpListTools or McpApprovalRequest or ResponsesAPIRequestParams_McpApprovalResponse or McpCall or ResponseCustomToolCallOutputParam or ResponseCustomToolCallParam or ItemReference | Yes | Input |
model | string | Yes | Model |
Example request:
curl -X POST "http://localhost:4000/responses" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"input": "What does an AI gateway do?"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The finished response, or server sent events when stream is true | application/json ResponsesAPIResponse |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | openai__types__responses__response__IncompleteDetails or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of ResponseOutputMessage or ResponseFileSearchToolCall or ResponseFunctionToolCall or ResponseFunctionToolCallOutputItem or ResponseFunctionWebSearch or ResponseComputerToolCall or ResponseComputerToolCallOutputItem or ResponseReasoningItem or ResponseToolSearchCall or ResponseToolSearchOutputItem or ResponseCompactionItem or ImageGenerationCall or ResponseCodeInterpreterToolCall or LocalShellCall or LocalShellCallOutput or ResponseFunctionShellToolCall or ResponseFunctionShellToolCallOutput or ResponseApplyPatchToolCall or ResponseApplyPatchToolCallOutput or McpCall or McpListTools or McpApprovalRequest or McpApprovalResponse or ResponseCustomToolCall or ResponseCustomToolCallOutputItem or object or array of GenericResponseOutputItem or OutputCodeInterpreterCall or OutputFunctionToolCall or OutputImageGenerationCall or ResponseFunctionToolCall or ResponseFunctionWebSearch or CustomToolCallOutputItem | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or null | No | Tool Choice |
tools | array of openai__types__responses__function_tool__FunctionTool or openai__types__responses__file_search_tool__FileSearchTool or ComputerTool or ComputerUsePreviewTool or WebSearchTool or Mcp or CodeInterpreter or ImageGeneration or LocalShell or FunctionShellTool or CustomTool or NamespaceTool or ToolSearchTool or WebSearchPreviewTool or ApplyPatchTool or array of ResponseFunctionToolCall or array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | ResponseTextConfigParam or object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | ResponseAPIUsage or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
POST /v1/responses
Create a model response
Sends a request to a model through the gateway in the OpenAI Responses API format and returns the model's
answer, as one JSON object or as server sent events when stream is true. Any key allowed to call the model
may use it; the gateway applies the key's model access, budgets, rate limits, guardrails and logging, and the
request's spend is recorded against the key, team and user.
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses
Supports background mode with polling_via_cache for partial response retrieval. When background=true and polling_via_cache is enabled, returns a polling_id immediately and streams the response in the background, updating Redis cache.
**Normal request**
curl -X POST http://localhost:4000/v1/responses -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": "Tell me about AI"
}'
**Background request with polling**
curl -X POST http://localhost:4000/v1/responses -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": "Tell me about AI",
"background": true
}'
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
x-spanway-routing-skips | header | enum: "true" | No | Send true to get the candidates the router skipped in the answer headers. See https://docs.spanway.ai/docs/proxy/routing_headers |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
context_fit | boolean or "middle_out" or object or null | No | How to fit a prompt that is longer than the context window. true or middle_out drops the oldest middle turns until it fits, false turns it off for this request |
transforms | array of string | No | Another way to ask for context fit: ["middle-out"] turns it on and [] turns it off |
include | array of enum: "file_search_call.results", "web_search_call.results", "web_search_call.action.sources", "message.input_image.image_url", "computer_call_output.output.image_url", "code_interpreter_call.outputs", "reasoning.encrypted_content", "message.output_text.logprobs" or null | No | Include |
instructions | string or null | No | Instructions |
max_output_tokens | integer or null | No | Max Output Tokens |
metadata | object or null | No | Metadata |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
previous_response_id | string or null | No | Previous Response Id |
reasoning | Reasoning or null | No | |
store | boolean or null | No | Store |
background | boolean or null | No | Background |
stream | boolean or null | No | Stream |
temperature | number or null | No | Temperature |
text | ResponseTextConfigParam or null | No | |
tool_choice | enum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or null | No | Tool Choice |
tools | array of FunctionToolParam or FileSearchToolParam or ComputerToolParam or ComputerUsePreviewToolParam or WebSearchToolParam or Mcp or CodeInterpreter or ImageGeneration or LocalShell or FunctionShellToolParam or CustomToolParam or NamespaceToolParam or ToolSearchToolParam or WebSearchPreviewToolParam or ApplyPatchToolParam or ResponsesComputerToolParam or ShellToolParam or null | No | Tools |
top_p | number or null | No | Top P |
truncation | enum: "auto", "disabled" or null | No | Truncation |
user | string or null | No | User |
service_tier | string or null | No | Service Tier |
safety_identifier | string or null | No | Safety Identifier |
prompt | PromptObject or null | No | |
max_tool_calls | integer or null | No | Max Tool Calls |
prompt_cache_key | string or null | No | Prompt Cache Key |
prompt_cache_retention | string or null | No | Prompt Cache Retention |
prompt_cache_options | PromptCacheOptions or null | No | |
stream_options | ResponsesAPIStreamOptions or null | No | |
top_logprobs | integer or null | No | Top Logprobs |
partial_images | integer or null | No | Partial Images |
context_management | array of ContextManagementEntry or null | No | Context Management |
input | string or array of EasyInputMessageParam or Message or ResponseOutputMessageParam or ResponseFileSearchToolCallParam or ResponseComputerToolCallParam or ComputerCallOutput or ResponseFunctionWebSearchParam or ResponseFunctionToolCallParam or FunctionCallOutput or ToolSearchCall or ResponseToolSearchOutputItemParamParam or ResponseReasoningItemParam or ResponseCompactionItemParamParam or ResponsesAPIRequestParams_ImageGenerationCall or ResponseCodeInterpreterToolCallParam or LocalShellCall or LocalShellCallOutput or ShellCall or ShellCallOutput or ApplyPatchCall or ApplyPatchCallOutput or McpListTools or McpApprovalRequest or ResponsesAPIRequestParams_McpApprovalResponse or McpCall or ResponseCustomToolCallOutputParam or ResponseCustomToolCallParam or ItemReference | Yes | Input |
model | string | Yes | Model |
Example request:
curl -X POST "http://localhost:4000/v1/responses" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"input": "What does an AI gateway do?"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The finished response, or server sent events when stream is true | application/json ResponsesAPIResponse |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | openai__types__responses__response__IncompleteDetails or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of ResponseOutputMessage or ResponseFileSearchToolCall or ResponseFunctionToolCall or ResponseFunctionToolCallOutputItem or ResponseFunctionWebSearch or ResponseComputerToolCall or ResponseComputerToolCallOutputItem or ResponseReasoningItem or ResponseToolSearchCall or ResponseToolSearchOutputItem or ResponseCompactionItem or ImageGenerationCall or ResponseCodeInterpreterToolCall or LocalShellCall or LocalShellCallOutput or ResponseFunctionShellToolCall or ResponseFunctionShellToolCallOutput or ResponseApplyPatchToolCall or ResponseApplyPatchToolCallOutput or McpCall or McpListTools or McpApprovalRequest or McpApprovalResponse or ResponseCustomToolCall or ResponseCustomToolCallOutputItem or object or array of GenericResponseOutputItem or OutputCodeInterpreterCall or OutputFunctionToolCall or OutputImageGenerationCall or ResponseFunctionToolCall or ResponseFunctionWebSearch or CustomToolCallOutputItem | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or null | No | Tool Choice |
tools | array of openai__types__responses__function_tool__FunctionTool or openai__types__responses__file_search_tool__FileSearchTool or ComputerTool or ComputerUsePreviewTool or WebSearchTool or Mcp or CodeInterpreter or ImageGeneration or LocalShell or FunctionShellTool or CustomTool or NamespaceTool or ToolSearchTool or WebSearchPreviewTool or ApplyPatchTool or array of ResponseFunctionToolCall or array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | ResponseTextConfigParam or object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | ResponseAPIUsage or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
GET /cursor/v1/models
List the models a Cursor client can use
Lists the models the key may call, for Cursor configured with <gateway>/cursor as its OpenAI base URL.
Cursor checks a key by listing models before it sends any chat request, so this route answers that check.
Any key may call it. Nothing changes.
Clients pointed at <proxy>/cursor as an OpenAI-compatible base URL resolve and
verify models via GET {base}/models (the OpenAI SDK contract). Without this
route those requests fall through to the Cursor Cloud Agents passthrough, which
demands a Cursor API key and 401s, so key verification silently fails before any
chat request is ever sent. Delegates to the standard /v1/models handler.
Example request:
curl -X GET "http://localhost:4000/cursor/v1/models" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The models this key may call, in the OpenAI listing shape | application/json ModelListResponse |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
object | "list" | Yes | Object |
data | array of ModelInfoResponse | Yes | Data |
GET /cursor/models
List the models a Cursor client can use
Lists the models the key may call, for Cursor configured with <gateway>/cursor as its OpenAI base URL.
Cursor checks a key by listing models before it sends any chat request, so this route answers that check.
Any key may call it. Nothing changes.
Clients pointed at <proxy>/cursor as an OpenAI-compatible base URL resolve and
verify models via GET {base}/models (the OpenAI SDK contract). Without this
route those requests fall through to the Cursor Cloud Agents passthrough, which
demands a Cursor API key and 401s, so key verification silently fails before any
chat request is ever sent. Delegates to the standard /v1/models handler.
Example request:
curl -X GET "http://localhost:4000/cursor/models" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The models this key may call, in the OpenAI listing shape | application/json ModelListResponse |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
object | "list" | Yes | Object |
data | array of ModelInfoResponse | Yes | Data |
POST /cursor/chat/completions
Chat completion for Cursor clients
Cursor BYOK endpoint. Accepts both request shapes Cursor sends to its OpenAI-compatible base URL and always answers in chat completions format.
Cursor agent mode sends Responses API format bodies (input, flat tool defs, reasoning,
custom tools) to the chat/completions path while expecting chat completions responses;
those are routed through the Responses API pipeline and converted back. Genuine chat
completions bodies (messages present) are routed through the standard chat completions
pipeline, after normalizing each level of the tools array and tool_choice to the chat
completions shapes OpenAI requires. Cursor mixes Responses API shapes into chat bodies
per level, independently: a flat tool def ({"type": "custom", "name": "ApplyPatch", ...})
gets nested under custom, and a flat grammar format
({"type": "grammar", "definition", "syntax"}) gets wrapped as
{"type": "grammar", "grammar": {...}} wherever it appears, including inside tool defs
Cursor already sent pre-nested.
curl -X POST http://localhost:4000/cursor/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": [{"role": "user", "content": "Hello"}]
}'
Responds back in chat completions format.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
messages | array of object | Yes | Messages |
frequency_penalty | number or null | No | Frequency Penalty |
logit_bias | object or null | No | Logit Bias |
logprobs | boolean or null | No | Logprobs |
top_logprobs | integer or null | No | Top Logprobs |
max_tokens | integer or null | No | Max Tokens |
n | integer or null | No | N |
presence_penalty | number or null | No | Presence Penalty |
response_format | object or null | No | Response Format |
seed | integer or null | No | Seed |
service_tier | string or null | No | Service Tier |
stop | string or array of string or null | No | Stop |
stream_options | object or null | No | Stream Options |
temperature | number or null | No | Temperature |
top_p | number or null | No | Top P |
tools | array of object or null | No | Tools |
tool_choice | string or object or null | No | Tool Choice |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
function_call | string or object or null | No | Function Call |
functions | array of object or null | No | Functions |
user | string or null | No | User |
stream | boolean or null | No | Stream |
metadata | object or null | No | Metadata |
guardrails | array of string or null | No | Guardrails |
caching | boolean or null | No | Caching |
num_retries | integer or null | No | Num Retries |
context_window_fallback_dict | object or null | No | Context Window Fallback Dict |
fallbacks | array of string or null | No | Fallbacks |
prompt_id | string or null | No | Stored prompt to render into the messages, by id |
prompt_variables | object or null | No | Values for the stored prompt's variables |
prompt_version | integer or null | No | Version of the stored prompt to use. Leave out for the latest |
prompt_environment | string or null | No | Environment label of the stored prompt to use, such as production |
vector_store_ids | array of string or null | No | Vector stores to search and add to the context before the model call |
thinking | object or null | No | Extended thinking for models that support it, e.g. {"type": "enabled"} |
top_k | integer or null | No | Sample only from the top k tokens, for providers that support it |
cache | object or null | No | Per-request cache controls such as ttl, no-cache or use-cache |
context_fit | boolean or "middle_out" or object or null | No | How to fit a prompt that is longer than the context window |
provider | object or null | No | Provider preferences for this request, such as sort, only or ignore |
max_tool_calls | integer or null | No | Most server tool calls the gateway runs for this request |
structured_output_repair | enum: "off", "repair", "retry", "repair_and_retry" or null | No | Repair or re-ask when a JSON reply fails its schema |
structured_output_max_retries | integer or null | No | Most re-asks when structured_output_repair retries |
Example request:
curl -X POST "http://localhost:4000/cursor/chat/completions" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"messages": [
{
"role": "system",
"content": "You are a concise assistant."
},
{
"role": "user",
"content": "Explain what a model group is."
}
],
"temperature": 0.2,
"max_tokens": 300
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The completion in the OpenAI chat completion shape, or a stream of chat.completion.chunk events. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created | integer | Yes | Created |
model | string or null | No | Model |
object | string | Yes | Object |
system_fingerprint | string or null | No | System Fingerprint |
choices | array of object | Yes | Choices |
GET /openai/v1/responses/{response_id}
Read a stored response
Reads back a response created earlier, by its id, for example to collect the result of a background request. Any key may call it. Nothing changes.
Supports both:
- Polling IDs (spanway_poll_*): Returns cumulative cached content from background responses
- Provider response IDs: Passes through to provider API
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/get
**Get polling response**
curl -X GET http://localhost:4000/v1/responses/spanway_poll_abc123 -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
**Get provider response**
curl -X GET http://localhost:4000/v1/responses/resp_abc123 -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/openai/v1/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The stored response object | application/json ResponsesAPIResponse |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | openai__types__responses__response__IncompleteDetails or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of ResponseOutputMessage or ResponseFileSearchToolCall or ResponseFunctionToolCall or ResponseFunctionToolCallOutputItem or ResponseFunctionWebSearch or ResponseComputerToolCall or ResponseComputerToolCallOutputItem or ResponseReasoningItem or ResponseToolSearchCall or ResponseToolSearchOutputItem or ResponseCompactionItem or ImageGenerationCall or ResponseCodeInterpreterToolCall or LocalShellCall or LocalShellCallOutput or ResponseFunctionShellToolCall or ResponseFunctionShellToolCallOutput or ResponseApplyPatchToolCall or ResponseApplyPatchToolCallOutput or McpCall or McpListTools or McpApprovalRequest or McpApprovalResponse or ResponseCustomToolCall or ResponseCustomToolCallOutputItem or object or array of GenericResponseOutputItem or OutputCodeInterpreterCall or OutputFunctionToolCall or OutputImageGenerationCall or ResponseFunctionToolCall or ResponseFunctionWebSearch or CustomToolCallOutputItem | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or null | No | Tool Choice |
tools | array of openai__types__responses__function_tool__FunctionTool or openai__types__responses__file_search_tool__FileSearchTool or ComputerTool or ComputerUsePreviewTool or WebSearchTool or Mcp or CodeInterpreter or ImageGeneration or LocalShell or FunctionShellTool or CustomTool or NamespaceTool or ToolSearchTool or WebSearchPreviewTool or ApplyPatchTool or array of ResponseFunctionToolCall or array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | ResponseTextConfigParam or object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | ResponseAPIUsage or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
DELETE /openai/v1/responses/{response_id}
Delete a stored response
Deletes a stored response by its id, so the provider and the gateway's polling cache no longer keep it. Any key may call it.
Supports both:
- Polling IDs (spanway_poll_*): Deletes from Redis cache
- Provider response IDs: Passes through to provider API
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/delete
curl -X DELETE http://localhost:4000/v1/responses/resp_abc123 -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/openai/v1/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The response was deleted | application/json DeleteResponseResult |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string or null | Yes | Id |
object | string or null | Yes | Object |
deleted | boolean or null | Yes | Deleted |
GET /responses/{response_id}
Read a stored response
Reads back a response created earlier, by its id, for example to collect the result of a background request. Any key may call it. Nothing changes.
Supports both:
- Polling IDs (spanway_poll_*): Returns cumulative cached content from background responses
- Provider response IDs: Passes through to provider API
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/get
**Get polling response**
curl -X GET http://localhost:4000/v1/responses/spanway_poll_abc123 -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
**Get provider response**
curl -X GET http://localhost:4000/v1/responses/resp_abc123 -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The stored response object | application/json ResponsesAPIResponse |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | openai__types__responses__response__IncompleteDetails or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of ResponseOutputMessage or ResponseFileSearchToolCall or ResponseFunctionToolCall or ResponseFunctionToolCallOutputItem or ResponseFunctionWebSearch or ResponseComputerToolCall or ResponseComputerToolCallOutputItem or ResponseReasoningItem or ResponseToolSearchCall or ResponseToolSearchOutputItem or ResponseCompactionItem or ImageGenerationCall or ResponseCodeInterpreterToolCall or LocalShellCall or LocalShellCallOutput or ResponseFunctionShellToolCall or ResponseFunctionShellToolCallOutput or ResponseApplyPatchToolCall or ResponseApplyPatchToolCallOutput or McpCall or McpListTools or McpApprovalRequest or McpApprovalResponse or ResponseCustomToolCall or ResponseCustomToolCallOutputItem or object or array of GenericResponseOutputItem or OutputCodeInterpreterCall or OutputFunctionToolCall or OutputImageGenerationCall or ResponseFunctionToolCall or ResponseFunctionWebSearch or CustomToolCallOutputItem | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or null | No | Tool Choice |
tools | array of openai__types__responses__function_tool__FunctionTool or openai__types__responses__file_search_tool__FileSearchTool or ComputerTool or ComputerUsePreviewTool or WebSearchTool or Mcp or CodeInterpreter or ImageGeneration or LocalShell or FunctionShellTool or CustomTool or NamespaceTool or ToolSearchTool or WebSearchPreviewTool or ApplyPatchTool or array of ResponseFunctionToolCall or array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | ResponseTextConfigParam or object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | ResponseAPIUsage or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
DELETE /responses/{response_id}
Delete a stored response
Deletes a stored response by its id, so the provider and the gateway's polling cache no longer keep it. Any key may call it.
Supports both:
- Polling IDs (spanway_poll_*): Deletes from Redis cache
- Provider response IDs: Passes through to provider API
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/delete
curl -X DELETE http://localhost:4000/v1/responses/resp_abc123 -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The response was deleted | application/json DeleteResponseResult |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string or null | Yes | Id |
object | string or null | Yes | Object |
deleted | boolean or null | Yes | Deleted |
GET /v1/responses/{response_id}
Read a stored response
Reads back a response created earlier, by its id, for example to collect the result of a background request. Any key may call it. Nothing changes.
Supports both:
- Polling IDs (spanway_poll_*): Returns cumulative cached content from background responses
- Provider response IDs: Passes through to provider API
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/get
**Get polling response**
curl -X GET http://localhost:4000/v1/responses/spanway_poll_abc123 -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
**Get provider response**
curl -X GET http://localhost:4000/v1/responses/resp_abc123 -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/v1/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The stored response object | application/json ResponsesAPIResponse |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | openai__types__responses__response__IncompleteDetails or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of ResponseOutputMessage or ResponseFileSearchToolCall or ResponseFunctionToolCall or ResponseFunctionToolCallOutputItem or ResponseFunctionWebSearch or ResponseComputerToolCall or ResponseComputerToolCallOutputItem or ResponseReasoningItem or ResponseToolSearchCall or ResponseToolSearchOutputItem or ResponseCompactionItem or ImageGenerationCall or ResponseCodeInterpreterToolCall or LocalShellCall or LocalShellCallOutput or ResponseFunctionShellToolCall or ResponseFunctionShellToolCallOutput or ResponseApplyPatchToolCall or ResponseApplyPatchToolCallOutput or McpCall or McpListTools or McpApprovalRequest or McpApprovalResponse or ResponseCustomToolCall or ResponseCustomToolCallOutputItem or object or array of GenericResponseOutputItem or OutputCodeInterpreterCall or OutputFunctionToolCall or OutputImageGenerationCall or ResponseFunctionToolCall or ResponseFunctionWebSearch or CustomToolCallOutputItem | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or null | No | Tool Choice |
tools | array of openai__types__responses__function_tool__FunctionTool or openai__types__responses__file_search_tool__FileSearchTool or ComputerTool or ComputerUsePreviewTool or WebSearchTool or Mcp or CodeInterpreter or ImageGeneration or LocalShell or FunctionShellTool or CustomTool or NamespaceTool or ToolSearchTool or WebSearchPreviewTool or ApplyPatchTool or array of ResponseFunctionToolCall or array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | ResponseTextConfigParam or object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | ResponseAPIUsage or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
DELETE /v1/responses/{response_id}
Delete a stored response
Deletes a stored response by its id, so the provider and the gateway's polling cache no longer keep it. Any key may call it.
Supports both:
- Polling IDs (spanway_poll_*): Deletes from Redis cache
- Provider response IDs: Passes through to provider API
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/delete
curl -X DELETE http://localhost:4000/v1/responses/resp_abc123 -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/v1/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The response was deleted | application/json DeleteResponseResult |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string or null | Yes | Id |
object | string or null | Yes | Object |
deleted | boolean or null | Yes | Deleted |
GET /openai/v1/responses/{response_id}/input_items
List the input items of a response
Lists the input items (the messages and tool results) that were sent to create a stored response, by the response id. Any key may call it. Nothing changes.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/openai/v1/responses/response_id-123/input_items" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The input items of the response | application/json ResponseItemList |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of ResponseInputMessageItem or ResponseOutputMessage or ResponseFileSearchToolCall or ResponseComputerToolCall or ResponseComputerToolCallOutputItem or ResponseFunctionWebSearch or ResponseFunctionToolCallItem or ResponseFunctionToolCallOutputItem or ResponseToolSearchCall or ResponseToolSearchOutputItem or ResponseReasoningItem or ResponseCompactionItem or ImageGenerationCall or ResponseCodeInterpreterToolCall or LocalShellCall or LocalShellCallOutput or ResponseFunctionShellToolCall or ResponseFunctionShellToolCallOutput or ResponseApplyPatchToolCall or ResponseApplyPatchToolCallOutput or McpListTools or McpApprovalRequest or McpApprovalResponse or McpCall or ResponseCustomToolCallItem or ResponseCustomToolCallOutputItem | Yes | Data |
first_id | string | Yes | First Id |
has_more | boolean | Yes | Has More |
last_id | string | Yes | Last Id |
object | "list" | Yes | Object |
GET /responses/{response_id}/input_items
List the input items of a response
Lists the input items (the messages and tool results) that were sent to create a stored response, by the response id. Any key may call it. Nothing changes.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/responses/response_id-123/input_items" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The input items of the response | application/json ResponseItemList |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of ResponseInputMessageItem or ResponseOutputMessage or ResponseFileSearchToolCall or ResponseComputerToolCall or ResponseComputerToolCallOutputItem or ResponseFunctionWebSearch or ResponseFunctionToolCallItem or ResponseFunctionToolCallOutputItem or ResponseToolSearchCall or ResponseToolSearchOutputItem or ResponseReasoningItem or ResponseCompactionItem or ImageGenerationCall or ResponseCodeInterpreterToolCall or LocalShellCall or LocalShellCallOutput or ResponseFunctionShellToolCall or ResponseFunctionShellToolCallOutput or ResponseApplyPatchToolCall or ResponseApplyPatchToolCallOutput or McpListTools or McpApprovalRequest or McpApprovalResponse or McpCall or ResponseCustomToolCallItem or ResponseCustomToolCallOutputItem | Yes | Data |
first_id | string | Yes | First Id |
has_more | boolean | Yes | Has More |
last_id | string | Yes | Last Id |
object | "list" | Yes | Object |
GET /v1/responses/{response_id}/input_items
List the input items of a response
Lists the input items (the messages and tool results) that were sent to create a stored response, by the response id. Any key may call it. Nothing changes.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/v1/responses/response_id-123/input_items" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The input items of the response | application/json ResponseItemList |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of ResponseInputMessageItem or ResponseOutputMessage or ResponseFileSearchToolCall or ResponseComputerToolCall or ResponseComputerToolCallOutputItem or ResponseFunctionWebSearch or ResponseFunctionToolCallItem or ResponseFunctionToolCallOutputItem or ResponseToolSearchCall or ResponseToolSearchOutputItem or ResponseReasoningItem or ResponseCompactionItem or ImageGenerationCall or ResponseCodeInterpreterToolCall or LocalShellCall or LocalShellCallOutput or ResponseFunctionShellToolCall or ResponseFunctionShellToolCallOutput or ResponseApplyPatchToolCall or ResponseApplyPatchToolCallOutput or McpListTools or McpApprovalRequest or McpApprovalResponse or McpCall or ResponseCustomToolCallItem or ResponseCustomToolCallOutputItem | Yes | Data |
first_id | string | Yes | First Id |
has_more | boolean | Yes | Has More |
last_id | string | Yes | Last Id |
object | "list" | Yes | Object |
POST /openai/v1/responses/compact
Compact a long conversation
Shrinks a long conversation into a few opaque compaction items that the model can read, so an agent can keep working without hitting the context limit or paying for the whole history on every turn. Any key allowed to call the model may use it, and the call is billed like a normal request.
Compact a response by running a compaction pass over a conversation.
Returns encrypted, opaque items that can be used to reduce context size.
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/compact
curl -X POST http://localhost:4000/v1/responses/compact -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": [{"role": "user", "content": "Hello"}]
}'
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
input | string or array of object | Yes | Input |
instructions | string or null | No | Instructions |
previous_response_id | string or null | No | Previous Response Id |
Example request:
curl -X POST "http://localhost:4000/openai/v1/responses/compact" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"input": [
{
"role": "user",
"content": "Hello"
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | A response object whose output holds compaction items that replace the earlier turns. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | object or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of object | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or object or null | No | Tool Choice |
tools | array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | object or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
POST /responses/compact
Compact a long conversation
Shrinks a long conversation into a few opaque compaction items that the model can read, so an agent can keep working without hitting the context limit or paying for the whole history on every turn. Any key allowed to call the model may use it, and the call is billed like a normal request.
Compact a response by running a compaction pass over a conversation.
Returns encrypted, opaque items that can be used to reduce context size.
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/compact
curl -X POST http://localhost:4000/v1/responses/compact -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": [{"role": "user", "content": "Hello"}]
}'
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
input | string or array of object | Yes | Input |
instructions | string or null | No | Instructions |
previous_response_id | string or null | No | Previous Response Id |
Example request:
curl -X POST "http://localhost:4000/responses/compact" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"input": [
{
"role": "user",
"content": "Hello"
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | A response object whose output holds compaction items that replace the earlier turns. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | object or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of object | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or object or null | No | Tool Choice |
tools | array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | object or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
POST /v1/responses/compact
Compact a long conversation
Shrinks a long conversation into a few opaque compaction items that the model can read, so an agent can keep working without hitting the context limit or paying for the whole history on every turn. Any key allowed to call the model may use it, and the call is billed like a normal request.
Compact a response by running a compaction pass over a conversation.
Returns encrypted, opaque items that can be used to reduce context size.
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/compact
curl -X POST http://localhost:4000/v1/responses/compact -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": [{"role": "user", "content": "Hello"}]
}'
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
input | string or array of object | Yes | Input |
instructions | string or null | No | Instructions |
previous_response_id | string or null | No | Previous Response Id |
Example request:
curl -X POST "http://localhost:4000/v1/responses/compact" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"input": [
{
"role": "user",
"content": "Hello"
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | A response object whose output holds compaction items that replace the earlier turns. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | object or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of object | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or object or null | No | Tool Choice |
tools | array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | object or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
POST /openai/v1/responses/input_tokens
Count the input tokens of a Responses API request
Tells you how many input tokens a Responses API request would use, for example to check a prompt fits the model's context window before sending it. Any key allowed to call the model may use it. No answer is generated.
Count the input tokens of a Responses API request without calling the model.
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/input-tokens
curl -X POST http://localhost:4000/v1/responses/input_tokens -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": "Hello, how are you?"
}'
The response is {"object": "response.input_tokens", "input_tokens": <count>}.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
input | string or array of object | Yes | Input |
instructions | string or null | No | Instructions |
tools | array of object or null | No | Tools |
Example request:
curl -X POST "http://localhost:4000/openai/v1/responses/input_tokens" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"input": "Hello, how are you?"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The number of input tokens the request would use. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
object | "response.input_tokens" | No | Object |
input_tokens | integer | Yes | Input Tokens |
POST /responses/input_tokens
Count the input tokens of a Responses API request
Tells you how many input tokens a Responses API request would use, for example to check a prompt fits the model's context window before sending it. Any key allowed to call the model may use it. No answer is generated.
Count the input tokens of a Responses API request without calling the model.
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/input-tokens
curl -X POST http://localhost:4000/v1/responses/input_tokens -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": "Hello, how are you?"
}'
The response is {"object": "response.input_tokens", "input_tokens": <count>}.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
input | string or array of object | Yes | Input |
instructions | string or null | No | Instructions |
tools | array of object or null | No | Tools |
Example request:
curl -X POST "http://localhost:4000/responses/input_tokens" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"input": "Hello, how are you?"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The number of input tokens the request would use. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
object | "response.input_tokens" | No | Object |
input_tokens | integer | Yes | Input Tokens |
POST /v1/responses/input_tokens
Count the input tokens of a Responses API request
Tells you how many input tokens a Responses API request would use, for example to check a prompt fits the model's context window before sending it. Any key allowed to call the model may use it. No answer is generated.
Count the input tokens of a Responses API request without calling the model.
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/input-tokens
curl -X POST http://localhost:4000/v1/responses/input_tokens -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"model": "gpt-6.1-sol",
"input": "Hello, how are you?"
}'
The response is {"object": "response.input_tokens", "input_tokens": <count>}.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
input | string or array of object | Yes | Input |
instructions | string or null | No | Instructions |
tools | array of object or null | No | Tools |
Example request:
curl -X POST "http://localhost:4000/v1/responses/input_tokens" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"input": "Hello, how are you?"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The number of input tokens the request would use. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
object | "response.input_tokens" | No | Object |
input_tokens | integer | Yes | Input Tokens |
POST /openai/v1/responses/{response_id}/cancel
Cancel a background response
Stops a response that is still running in the background, so the model stops generating and billing for it. Any key may call it for a response it can see.
Cancel a response by ID.
Supports both:
- Polling IDs (spanway_poll_*): Cancels background response and updates status in Redis
- Provider response IDs: Passes through to provider API
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/cancel
**Cancel polling response**
curl -X POST http://localhost:4000/v1/responses/spanway_poll_abc123/cancel -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
**Cancel provider response**
curl -X POST http://localhost:4000/v1/responses/resp_abc123/cancel -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Request body (application/json, object):
Example request:
curl -X POST "http://localhost:4000/openai/v1/responses/response_id-123/cancel" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The cancelled response object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | object or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of object | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or object or null | No | Tool Choice |
tools | array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | object or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
POST /responses/{response_id}/cancel
Cancel a background response
Stops a response that is still running in the background, so the model stops generating and billing for it. Any key may call it for a response it can see.
Cancel a response by ID.
Supports both:
- Polling IDs (spanway_poll_*): Cancels background response and updates status in Redis
- Provider response IDs: Passes through to provider API
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/cancel
**Cancel polling response**
curl -X POST http://localhost:4000/v1/responses/spanway_poll_abc123/cancel -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
**Cancel provider response**
curl -X POST http://localhost:4000/v1/responses/resp_abc123/cancel -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Request body (application/json, object):
Example request:
curl -X POST "http://localhost:4000/responses/response_id-123/cancel" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The cancelled response object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | object or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of object | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or object or null | No | Tool Choice |
tools | array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | object or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |
POST /v1/responses/{response_id}/cancel
Cancel a background response
Stops a response that is still running in the background, so the model stops generating and billing for it. Any key may call it for a response it can see.
Cancel a response by ID.
Supports both:
- Polling IDs (spanway_poll_*): Cancels background response and updates status in Redis
- Provider response IDs: Passes through to provider API
Follows the OpenAI Responses API spec: https://platform.openai.com/docs/api-reference/responses/cancel
**Cancel polling response**
curl -X POST http://localhost:4000/v1/responses/spanway_poll_abc123/cancel -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
**Cancel provider response**
curl -X POST http://localhost:4000/v1/responses/resp_abc123/cancel -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
response_id | path | string | Yes |
Request body (application/json, object):
Example request:
curl -X POST "http://localhost:4000/v1/responses/response_id-123/cancel" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The cancelled response object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
error | object or null | No | Error |
incomplete_details | object or null | No | |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string or null | No | Model |
object | string or null | No | Object |
output | array of object | Yes | Output |
parallel_tool_calls | boolean or null | No | Parallel Tool Calls |
temperature | number or null | No | Temperature |
tool_choice | enum: "none", "auto", "required" or object or null | No | Tool Choice |
tools | array of object or null | No | Tools |
top_p | number or null | No | Top P |
max_output_tokens | integer or null | No | Max Output Tokens |
previous_response_id | string or null | No | Previous Response Id |
reasoning | object or null | No | Reasoning |
status | string or null | No | Status |
text | object or null | No | Text |
truncation | enum: "auto", "disabled" or null | No | Truncation |
usage | object or null | No | |
user | string or null | No | User |
store | boolean or null | No | Store |