Skip to main content

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.

MethodPathSummary
POST/openai/v1/responsesCreate a model response
POST/responsesCreate a model response
POST/v1/responsesCreate a model response
GET/cursor/v1/modelsList the models a Cursor client can use
GET/cursor/modelsList the models a Cursor client can use
POST/cursor/chat/completionsChat 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_itemsList the input items of a response
GET/responses/{response_id}/input_itemsList the input items of a response
GET/v1/responses/{response_id}/input_itemsList the input items of a response
POST/openai/v1/responses/compactCompact a long conversation
POST/responses/compactCompact a long conversation
POST/v1/responses/compactCompact a long conversation
POST/openai/v1/responses/input_tokensCount the input tokens of a Responses API request
POST/responses/input_tokensCount the input tokens of a Responses API request
POST/v1/responses/input_tokensCount the input tokens of a Responses API request
POST/openai/v1/responses/{response_id}/cancelCancel a background response
POST/responses/{response_id}/cancelCancel a background response
POST/v1/responses/{response_id}/cancelCancel 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:

NameInTypeRequiredDescription
x-spanway-routing-skipsheaderenum: "true"NoSend 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):

FieldTypeRequiredDescription
context_fitboolean or "middle_out" or object or nullNoHow 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
transformsarray of stringNoAnother way to ask for context fit: ["middle-out"] turns it on and [] turns it off
includearray 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 nullNoInclude
instructionsstring or nullNoInstructions
max_output_tokensinteger or nullNoMax Output Tokens
metadataobject or nullNoMetadata
parallel_tool_callsboolean or nullNoParallel Tool Calls
previous_response_idstring or nullNoPrevious Response Id
reasoningReasoning or nullNo
storeboolean or nullNoStore
backgroundboolean or nullNoBackground
streamboolean or nullNoStream
temperaturenumber or nullNoTemperature
textResponseTextConfigParam or nullNo
tool_choiceenum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or nullNoTool Choice
toolsarray 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 nullNoTools
top_pnumber or nullNoTop P
truncationenum: "auto", "disabled" or nullNoTruncation
userstring or nullNoUser
service_tierstring or nullNoService Tier
safety_identifierstring or nullNoSafety Identifier
promptPromptObject or nullNo
max_tool_callsinteger or nullNoMax Tool Calls
prompt_cache_keystring or nullNoPrompt Cache Key
prompt_cache_retentionstring or nullNoPrompt Cache Retention
prompt_cache_optionsPromptCacheOptions or nullNo
stream_optionsResponsesAPIStreamOptions or nullNo
top_logprobsinteger or nullNoTop Logprobs
partial_imagesinteger or nullNoPartial Images
context_managementarray of ContextManagementEntry or nullNoContext Management
inputstring 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 ItemReferenceYesInput
modelstringYesModel

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:

StatusDescriptionBody
200The finished response, or server sent events when stream is trueapplication/json ResponsesAPIResponse
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsopenai__types__responses__response__IncompleteDetails or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray 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 CustomToolCallOutputItemYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or nullNoTool Choice
toolsarray 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 nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textResponseTextConfigParam or object or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageResponseAPIUsage or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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:

NameInTypeRequiredDescription
x-spanway-routing-skipsheaderenum: "true"NoSend 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):

FieldTypeRequiredDescription
context_fitboolean or "middle_out" or object or nullNoHow 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
transformsarray of stringNoAnother way to ask for context fit: ["middle-out"] turns it on and [] turns it off
includearray 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 nullNoInclude
instructionsstring or nullNoInstructions
max_output_tokensinteger or nullNoMax Output Tokens
metadataobject or nullNoMetadata
parallel_tool_callsboolean or nullNoParallel Tool Calls
previous_response_idstring or nullNoPrevious Response Id
reasoningReasoning or nullNo
storeboolean or nullNoStore
backgroundboolean or nullNoBackground
streamboolean or nullNoStream
temperaturenumber or nullNoTemperature
textResponseTextConfigParam or nullNo
tool_choiceenum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or nullNoTool Choice
toolsarray 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 nullNoTools
top_pnumber or nullNoTop P
truncationenum: "auto", "disabled" or nullNoTruncation
userstring or nullNoUser
service_tierstring or nullNoService Tier
safety_identifierstring or nullNoSafety Identifier
promptPromptObject or nullNo
max_tool_callsinteger or nullNoMax Tool Calls
prompt_cache_keystring or nullNoPrompt Cache Key
prompt_cache_retentionstring or nullNoPrompt Cache Retention
prompt_cache_optionsPromptCacheOptions or nullNo
stream_optionsResponsesAPIStreamOptions or nullNo
top_logprobsinteger or nullNoTop Logprobs
partial_imagesinteger or nullNoPartial Images
context_managementarray of ContextManagementEntry or nullNoContext Management
inputstring 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 ItemReferenceYesInput
modelstringYesModel

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:

StatusDescriptionBody
200The finished response, or server sent events when stream is trueapplication/json ResponsesAPIResponse
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsopenai__types__responses__response__IncompleteDetails or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray 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 CustomToolCallOutputItemYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or nullNoTool Choice
toolsarray 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 nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textResponseTextConfigParam or object or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageResponseAPIUsage or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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:

NameInTypeRequiredDescription
x-spanway-routing-skipsheaderenum: "true"NoSend 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):

FieldTypeRequiredDescription
context_fitboolean or "middle_out" or object or nullNoHow 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
transformsarray of stringNoAnother way to ask for context fit: ["middle-out"] turns it on and [] turns it off
includearray 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 nullNoInclude
instructionsstring or nullNoInstructions
max_output_tokensinteger or nullNoMax Output Tokens
metadataobject or nullNoMetadata
parallel_tool_callsboolean or nullNoParallel Tool Calls
previous_response_idstring or nullNoPrevious Response Id
reasoningReasoning or nullNo
storeboolean or nullNoStore
backgroundboolean or nullNoBackground
streamboolean or nullNoStream
temperaturenumber or nullNoTemperature
textResponseTextConfigParam or nullNo
tool_choiceenum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or nullNoTool Choice
toolsarray 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 nullNoTools
top_pnumber or nullNoTop P
truncationenum: "auto", "disabled" or nullNoTruncation
userstring or nullNoUser
service_tierstring or nullNoService Tier
safety_identifierstring or nullNoSafety Identifier
promptPromptObject or nullNo
max_tool_callsinteger or nullNoMax Tool Calls
prompt_cache_keystring or nullNoPrompt Cache Key
prompt_cache_retentionstring or nullNoPrompt Cache Retention
prompt_cache_optionsPromptCacheOptions or nullNo
stream_optionsResponsesAPIStreamOptions or nullNo
top_logprobsinteger or nullNoTop Logprobs
partial_imagesinteger or nullNoPartial Images
context_managementarray of ContextManagementEntry or nullNoContext Management
inputstring 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 ItemReferenceYesInput
modelstringYesModel

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:

StatusDescriptionBody
200The finished response, or server sent events when stream is trueapplication/json ResponsesAPIResponse
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsopenai__types__responses__response__IncompleteDetails or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray 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 CustomToolCallOutputItemYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or nullNoTool Choice
toolsarray 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 nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textResponseTextConfigParam or object or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageResponseAPIUsage or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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:

StatusDescriptionBody
200The models this key may call, in the OpenAI listing shapeapplication/json ModelListResponse
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
object"list"YesObject
dataarray of ModelInfoResponseYesData

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:

StatusDescriptionBody
200The models this key may call, in the OpenAI listing shapeapplication/json ModelListResponse
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
object"list"YesObject
dataarray of ModelInfoResponseYesData

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):

FieldTypeRequiredDescription
modelstringYesModel
messagesarray of objectYesMessages
frequency_penaltynumber or nullNoFrequency Penalty
logit_biasobject or nullNoLogit Bias
logprobsboolean or nullNoLogprobs
top_logprobsinteger or nullNoTop Logprobs
max_tokensinteger or nullNoMax Tokens
ninteger or nullNoN
presence_penaltynumber or nullNoPresence Penalty
response_formatobject or nullNoResponse Format
seedinteger or nullNoSeed
service_tierstring or nullNoService Tier
stopstring or array of string or nullNoStop
stream_optionsobject or nullNoStream Options
temperaturenumber or nullNoTemperature
top_pnumber or nullNoTop P
toolsarray of object or nullNoTools
tool_choicestring or object or nullNoTool Choice
parallel_tool_callsboolean or nullNoParallel Tool Calls
function_callstring or object or nullNoFunction Call
functionsarray of object or nullNoFunctions
userstring or nullNoUser
streamboolean or nullNoStream
metadataobject or nullNoMetadata
guardrailsarray of string or nullNoGuardrails
cachingboolean or nullNoCaching
num_retriesinteger or nullNoNum Retries
context_window_fallback_dictobject or nullNoContext Window Fallback Dict
fallbacksarray of string or nullNoFallbacks
prompt_idstring or nullNoStored prompt to render into the messages, by id
prompt_variablesobject or nullNoValues for the stored prompt's variables
prompt_versioninteger or nullNoVersion of the stored prompt to use. Leave out for the latest
prompt_environmentstring or nullNoEnvironment label of the stored prompt to use, such as production
vector_store_idsarray of string or nullNoVector stores to search and add to the context before the model call
thinkingobject or nullNoExtended thinking for models that support it, e.g. {"type": "enabled"}
top_kinteger or nullNoSample only from the top k tokens, for providers that support it
cacheobject or nullNoPer-request cache controls such as ttl, no-cache or use-cache
context_fitboolean or "middle_out" or object or nullNoHow to fit a prompt that is longer than the context window
providerobject or nullNoProvider preferences for this request, such as sort, only or ignore
max_tool_callsinteger or nullNoMost server tool calls the gateway runs for this request
structured_output_repairenum: "off", "repair", "retry", "repair_and_retry" or nullNoRepair or re-ask when a JSON reply fails its schema
structured_output_max_retriesinteger or nullNoMost 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:

StatusDescriptionBody
200The completion in the OpenAI chat completion shape, or a stream of chat.completion.chunk events.application/json object
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
createdintegerYesCreated
modelstring or nullNoModel
objectstringYesObject
system_fingerprintstring or nullNoSystem Fingerprint
choicesarray of objectYesChoices

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:

NameInTypeRequiredDescription
response_idpathstringYes

Example request:

curl -X GET "http://localhost:4000/openai/v1/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The stored response objectapplication/json ResponsesAPIResponse
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsopenai__types__responses__response__IncompleteDetails or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray 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 CustomToolCallOutputItemYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or nullNoTool Choice
toolsarray 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 nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textResponseTextConfigParam or object or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageResponseAPIUsage or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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:

NameInTypeRequiredDescription
response_idpathstringYes

Example request:

curl -X DELETE "http://localhost:4000/openai/v1/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The response was deletedapplication/json DeleteResponseResult
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstring or nullYesId
objectstring or nullYesObject
deletedboolean or nullYesDeleted

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:

NameInTypeRequiredDescription
response_idpathstringYes

Example request:

curl -X GET "http://localhost:4000/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The stored response objectapplication/json ResponsesAPIResponse
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsopenai__types__responses__response__IncompleteDetails or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray 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 CustomToolCallOutputItemYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or nullNoTool Choice
toolsarray 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 nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textResponseTextConfigParam or object or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageResponseAPIUsage or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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:

NameInTypeRequiredDescription
response_idpathstringYes

Example request:

curl -X DELETE "http://localhost:4000/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The response was deletedapplication/json DeleteResponseResult
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstring or nullYesId
objectstring or nullYesObject
deletedboolean or nullYesDeleted

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:

NameInTypeRequiredDescription
response_idpathstringYes

Example request:

curl -X GET "http://localhost:4000/v1/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The stored response objectapplication/json ResponsesAPIResponse
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsopenai__types__responses__response__IncompleteDetails or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray 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 CustomToolCallOutputItemYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or ToolChoiceAllowedParam or ToolChoiceTypesParam or ToolChoiceFunctionParam or ToolChoiceMcpParam or ToolChoiceCustomParam or ToolChoiceApplyPatchParam or ToolChoiceShellParam or nullNoTool Choice
toolsarray 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 nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textResponseTextConfigParam or object or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageResponseAPIUsage or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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:

NameInTypeRequiredDescription
response_idpathstringYes

Example request:

curl -X DELETE "http://localhost:4000/v1/responses/response_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The response was deletedapplication/json DeleteResponseResult
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstring or nullYesId
objectstring or nullYesObject
deletedboolean or nullYesDeleted

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:

NameInTypeRequiredDescription
response_idpathstringYes

Example request:

curl -X GET "http://localhost:4000/openai/v1/responses/response_id-123/input_items" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The input items of the responseapplication/json ResponseItemList
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
dataarray 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 ResponseCustomToolCallOutputItemYesData
first_idstringYesFirst Id
has_morebooleanYesHas More
last_idstringYesLast Id
object"list"YesObject

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:

NameInTypeRequiredDescription
response_idpathstringYes

Example request:

curl -X GET "http://localhost:4000/responses/response_id-123/input_items" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The input items of the responseapplication/json ResponseItemList
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
dataarray 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 ResponseCustomToolCallOutputItemYesData
first_idstringYesFirst Id
has_morebooleanYesHas More
last_idstringYesLast Id
object"list"YesObject

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:

NameInTypeRequiredDescription
response_idpathstringYes

Example request:

curl -X GET "http://localhost:4000/v1/responses/response_id-123/input_items" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The input items of the responseapplication/json ResponseItemList
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
dataarray 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 ResponseCustomToolCallOutputItemYesData
first_idstringYesFirst Id
has_morebooleanYesHas More
last_idstringYesLast Id
object"list"YesObject

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):

FieldTypeRequiredDescription
modelstringYesModel
inputstring or array of objectYesInput
instructionsstring or nullNoInstructions
previous_response_idstring or nullNoPrevious 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:

StatusDescriptionBody
200A response object whose output holds compaction items that replace the earlier turns.application/json object
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsobject or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray of objectYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or object or nullNoTool Choice
toolsarray of object or nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textobject or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageobject or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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):

FieldTypeRequiredDescription
modelstringYesModel
inputstring or array of objectYesInput
instructionsstring or nullNoInstructions
previous_response_idstring or nullNoPrevious 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:

StatusDescriptionBody
200A response object whose output holds compaction items that replace the earlier turns.application/json object
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsobject or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray of objectYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or object or nullNoTool Choice
toolsarray of object or nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textobject or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageobject or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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):

FieldTypeRequiredDescription
modelstringYesModel
inputstring or array of objectYesInput
instructionsstring or nullNoInstructions
previous_response_idstring or nullNoPrevious 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:

StatusDescriptionBody
200A response object whose output holds compaction items that replace the earlier turns.application/json object
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsobject or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray of objectYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or object or nullNoTool Choice
toolsarray of object or nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textobject or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageobject or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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):

FieldTypeRequiredDescription
modelstringYesModel
inputstring or array of objectYesInput
instructionsstring or nullNoInstructions
toolsarray of object or nullNoTools

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:

StatusDescriptionBody
200The number of input tokens the request would use.application/json object
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
object"response.input_tokens"NoObject
input_tokensintegerYesInput 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):

FieldTypeRequiredDescription
modelstringYesModel
inputstring or array of objectYesInput
instructionsstring or nullNoInstructions
toolsarray of object or nullNoTools

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:

StatusDescriptionBody
200The number of input tokens the request would use.application/json object
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
object"response.input_tokens"NoObject
input_tokensintegerYesInput 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):

FieldTypeRequiredDescription
modelstringYesModel
inputstring or array of objectYesInput
instructionsstring or nullNoInstructions
toolsarray of object or nullNoTools

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:

StatusDescriptionBody
200The number of input tokens the request would use.application/json object
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
object"response.input_tokens"NoObject
input_tokensintegerYesInput 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:

NameInTypeRequiredDescription
response_idpathstringYes

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:

StatusDescriptionBody
200The cancelled response object.application/json object
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsobject or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray of objectYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or object or nullNoTool Choice
toolsarray of object or nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textobject or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageobject or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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:

NameInTypeRequiredDescription
response_idpathstringYes

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:

StatusDescriptionBody
200The cancelled response object.application/json object
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsobject or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray of objectYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or object or nullNoTool Choice
toolsarray of object or nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textobject or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageobject or nullNo
userstring or nullNoUser
storeboolean or nullNoStore

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:

NameInTypeRequiredDescription
response_idpathstringYes

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:

StatusDescriptionBody
200The cancelled response object.application/json object
400The 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
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The 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
408The provider did not answer before the request timed out.application/json ProxyError
413The 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. Docsapplication/json object
422The 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 errorapplication/json ProxyError or HTTPValidationError
429Too 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 errorapplication/json ProxyError
500The 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
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The 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. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
created_atintegerYesCreated At
errorobject or nullNoError
incomplete_detailsobject or nullNo
instructionsstring or nullNoInstructions
metadataobject or nullNoMetadata
modelstring or nullNoModel
objectstring or nullNoObject
outputarray of objectYesOutput
parallel_tool_callsboolean or nullNoParallel Tool Calls
temperaturenumber or nullNoTemperature
tool_choiceenum: "none", "auto", "required" or object or nullNoTool Choice
toolsarray of object or nullNoTools
top_pnumber or nullNoTop P
max_output_tokensinteger or nullNoMax Output Tokens
previous_response_idstring or nullNoPrevious Response Id
reasoningobject or nullNoReasoning
statusstring or nullNoStatus
textobject or nullNoText
truncationenum: "auto", "disabled" or nullNoTruncation
usageobject or nullNo
userstring or nullNoUser
storeboolean or nullNoStore