Skip to main content

Google genai endpoints API

This page documents the 14 gateway endpoints tagged google genai endpoints 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/models/{model_name}:generateContentGenerate content (Gemini generateContent format)
POST/v1beta/models/{model_name}:generateContentGenerate content (Gemini generateContent format)
POST/models/{model_name}:streamGenerateContentStream content (Gemini streamGenerateContent format)
POST/v1beta/models/{model_name}:streamGenerateContentStream content (Gemini streamGenerateContent format)
POST/models/{model_name}:countTokensCount the tokens of a generateContent request
POST/v1beta/models/{model_name}:countTokensCount the tokens of a generateContent request
POST/interactionsCreate an interaction
POST/v1beta/interactionsCreate an interaction
GET/interactions/{interaction_id}Get an interaction
DELETE/interactions/{interaction_id}Delete an interaction
GET/v1beta/interactions/{interaction_id}Get an interaction
DELETE/v1beta/interactions/{interaction_id}Delete an interaction
POST/interactions/{interaction_id}/cancelCancel a running interaction
POST/v1beta/interactions/{interaction_id}/cancelCancel a running interaction

Endpoints​

POST /models/{model_name}:generateContent​

Generate content (Gemini generateContent format)

Sends a Gemini generateContent request to the model named in the path and returns the answer in the same Gemini shape, so tools built on the Google GenAI SDK can point at the gateway unchanged. The public model name may stand for a Gemini model or a model from any other provider, and the gateway translates the request and the answer. Any key allowed to use that model may call it, and the call counts against the key's budget and rate limits.

Send the virtual key in the x-goog-api-key header, the key query parameter or an Authorization: Bearer header.

Docs

Parameters:

NameInTypeRequiredDescription
model_namepathstringYes

Request body (application/json, object):

FieldTypeRequiredDescription
contentsarray of objectYesContents
systemInstructionobjectNoSystemInstructions
toolsobjectNoTools
toolConfigobjectNoToolConfig
safetySettingsarray of objectNoSafetysettings
generationConfigobjectNoGenerateContentGenerationConfig
cachedContentstringNoCachedcontent

Example request:

curl -X POST "http://localhost:4000/models/model_name-123:generateContent" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Explain a model group in one sentence."
}
]
}
],
"generationConfig": {
"temperature": 0.2,
"maxOutputTokens": 200
}
}'

Responses:

StatusDescriptionBody
200The generateContent response. The streaming route sends the same shape as server-sent 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
candidatesarray of objectNoCandidates
promptFeedbackobjectNoPromptFeedback
usageMetadataobjectYesUsageMetadata
responseIdstringNoResponseid

POST /v1beta/models/{model_name}:generateContent​

Generate content (Gemini generateContent format)

Sends a Gemini generateContent request to the model named in the path and returns the answer in the same Gemini shape, so tools built on the Google GenAI SDK can point at the gateway unchanged. The public model name may stand for a Gemini model or a model from any other provider, and the gateway translates the request and the answer. Any key allowed to use that model may call it, and the call counts against the key's budget and rate limits.

Send the virtual key in the x-goog-api-key header, the key query parameter or an Authorization: Bearer header.

Docs

Parameters:

NameInTypeRequiredDescription
model_namepathstringYes

Request body (application/json, object):

FieldTypeRequiredDescription
contentsarray of objectYesContents
systemInstructionobjectNoSystemInstructions
toolsobjectNoTools
toolConfigobjectNoToolConfig
safetySettingsarray of objectNoSafetysettings
generationConfigobjectNoGenerateContentGenerationConfig
cachedContentstringNoCachedcontent

Example request:

curl -X POST "http://localhost:4000/v1beta/models/model_name-123:generateContent" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Explain a model group in one sentence."
}
]
}
],
"generationConfig": {
"temperature": 0.2,
"maxOutputTokens": 200
}
}'

Responses:

StatusDescriptionBody
200The generateContent response. The streaming route sends the same shape as server-sent 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
candidatesarray of objectNoCandidates
promptFeedbackobjectNoPromptFeedback
usageMetadataobjectYesUsageMetadata
responseIdstringNoResponseid

POST /models/{model_name}:streamGenerateContent​

Stream content (Gemini streamGenerateContent format)

The streaming form of generateContent. Partial answers arrive as server-sent events, each in the generateContent shape, until the model finishes. Access, budgets and rate limits work as for generateContent.

Docs

Parameters:

NameInTypeRequiredDescription
model_namepathstringYes

Request body (application/json, object):

FieldTypeRequiredDescription
contentsarray of objectYesContents
systemInstructionobjectNoSystemInstructions
toolsobjectNoTools
toolConfigobjectNoToolConfig
safetySettingsarray of objectNoSafetysettings
generationConfigobjectNoGenerateContentGenerationConfig
cachedContentstringNoCachedcontent

Example request:

curl -X POST "http://localhost:4000/models/model_name-123:streamGenerateContent" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Explain a model group in one sentence."
}
]
}
],
"generationConfig": {
"temperature": 0.2,
"maxOutputTokens": 200
}
}'

Responses:

StatusDescriptionBody
200The generateContent response. The streaming route sends the same shape as server-sent 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
candidatesarray of objectNoCandidates
promptFeedbackobjectNoPromptFeedback
usageMetadataobjectYesUsageMetadata
responseIdstringNoResponseid

POST /v1beta/models/{model_name}:streamGenerateContent​

Stream content (Gemini streamGenerateContent format)

The streaming form of generateContent. Partial answers arrive as server-sent events, each in the generateContent shape, until the model finishes. Access, budgets and rate limits work as for generateContent.

Docs

Parameters:

NameInTypeRequiredDescription
model_namepathstringYes

Request body (application/json, object):

FieldTypeRequiredDescription
contentsarray of objectYesContents
systemInstructionobjectNoSystemInstructions
toolsobjectNoTools
toolConfigobjectNoToolConfig
safetySettingsarray of objectNoSafetysettings
generationConfigobjectNoGenerateContentGenerationConfig
cachedContentstringNoCachedcontent

Example request:

curl -X POST "http://localhost:4000/v1beta/models/model_name-123:streamGenerateContent" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Explain a model group in one sentence."
}
]
}
],
"generationConfig": {
"temperature": 0.2,
"maxOutputTokens": 200
}
}'

Responses:

StatusDescriptionBody
200The generateContent response. The streaming route sends the same shape as server-sent 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
candidatesarray of objectNoCandidates
promptFeedbackobjectNoPromptFeedback
usageMetadataobjectYesUsageMetadata
responseIdstringNoResponseid

POST /models/{model_name}:countTokens​

Count the tokens of a generateContent request

Counts how many tokens a generateContent request would use with the model named in the path, without calling the model for an answer, so you can check a prompt against the context window or estimate its cost. Any key allowed to use that model may call it, and it changes nothing.

Docs

Parameters:

NameInTypeRequiredDescription
model_namepathstringYes

Request body (application/json, object):

FieldTypeRequiredDescription
contentsarray of objectYesContents
system_instructionobjectNoSystemInstructions
toolsobjectNoTools
toolConfigobjectNoToolConfig
safetySettingsarray of objectNoSafetysettings
generationConfigobjectNoGenerationConfig
cachedContentstringNoCachedcontent
labelsobjectNoLabels
serviceTierstringNoServicetier

Example request:

curl -X POST "http://localhost:4000/models/model_name-123:countTokens" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Explain a model group in one sentence."
}
]
}
]
}'

Responses:

StatusDescriptionBody
200The token count of the requestapplication/json TokenCountDetailsResponse
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
totalTokensintegerYesTotaltokens
promptTokensDetailsarray of PromptTokensDetailsYesPrompttokensdetails

POST /v1beta/models/{model_name}:countTokens​

Count the tokens of a generateContent request

Counts how many tokens a generateContent request would use with the model named in the path, without calling the model for an answer, so you can check a prompt against the context window or estimate its cost. Any key allowed to use that model may call it, and it changes nothing.

Docs

Parameters:

NameInTypeRequiredDescription
model_namepathstringYes

Request body (application/json, object):

FieldTypeRequiredDescription
contentsarray of objectYesContents
system_instructionobjectNoSystemInstructions
toolsobjectNoTools
toolConfigobjectNoToolConfig
safetySettingsarray of objectNoSafetysettings
generationConfigobjectNoGenerationConfig
cachedContentstringNoCachedcontent
labelsobjectNoLabels
serviceTierstringNoServicetier

Example request:

curl -X POST "http://localhost:4000/v1beta/models/model_name-123:countTokens" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Explain a model group in one sentence."
}
]
}
]
}'

Responses:

StatusDescriptionBody
200The token count of the requestapplication/json TokenCountDetailsResponse
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
totalTokensintegerYesTotaltokens
promptTokensDetailsarray of PromptTokensDetailsYesPrompttokensdetails

POST /interactions​

Create an interaction

Starts an interaction in the shape of the Google Interactions API, either with a model (send model) or with a Google agent such as deep research (send agent). Any key allowed to use that model may call it, and the call counts against the key's budget and rate limits.

Docs

Request body (application/json, object):

FieldTypeRequiredDescription
modelstringYesThe name of the Model used for generating the interaction.
streamboolean or nullNoInput only. Whether the interaction will be streamed.
storeboolean or nullNoInput only. Whether to store the response and request for later retrieval.
idstring or nullNoOutput only. A unique identifier for the interaction completion.
statusenum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued" or nullNoOutput only. The status of the interaction.
createdstring or nullNoOutput only. The time at which the response was created in ISO 8601 format
updatedstring or nullNoOutput only. The time at which the response was last updated in ISO 8601 format
outputsarray of object or nullNoOutput only. Responses from the model.
system_instructionstring or nullNoSystem instruction for the interaction.
toolsarray of object or nullNoA list of tool declarations the model may call during interaction.
backgroundboolean or nullNoWhether to run the model interaction in the background.
usageobject or nullNoOutput only. Statistics on the interaction request's token usage.
response_modalitiesarray of enum: "text", "image", "audio" or nullNoThe requested modalities of the response (TEXT, IMAGE, AUDIO).
response_formatany or nullNoEnforces that the generated response is a JSON object that complies with
response_mime_typestring or nullNoThe mime type of the response. This is required if response_format is set.
previous_interaction_idstring or nullNoThe ID of the previous interaction, if any.
inputstring or array of object or objectYesThe inputs for the interaction.
generation_configobject or nullNoInput only. Configuration parameters for the model interaction.

Example request:

curl -X POST "http://localhost:4000/interactions" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"input": "Summarize the latest release notes in three bullet points."
}'

Responses:

StatusDescriptionBody
200The interaction with its status and outputs.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
modelstring or nullNoThe name of the Model used for generating the interaction.
agentstring or nullNoThe name of the Agent used for generating the interaction.
idstringYesOutput only. A unique identifier for the interaction completion.
statusenum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued"YesOutput only. The status of the interaction.
createdstring or nullNoOutput only. The time at which the response was created in ISO 8601 format
updatedstring or nullNoOutput only. The time at which the response was last updated in ISO 8601 format
outputsarray of object or nullNoOutput only. Responses from the model.
system_instructionstring or nullNoSystem instruction for the interaction.
toolsarray of object or nullNoA list of tool declarations the model may call during interaction.
backgroundboolean or nullNoWhether to run the model interaction in the background.
object"interaction"NoOutput only. The object type of the interaction. Always set to interaction.
usageobject or nullNoOutput only. Statistics on the interaction request's token usage.
response_modalitiesarray of enum: "text", "image", "audio" or nullNoThe requested modalities of the response (TEXT, IMAGE, AUDIO).
response_formatany or nullNoEnforces that the generated response is a JSON object that complies with
response_mime_typestring or nullNoThe mime type of the response. This is required if response_format is set.
previous_interaction_idstring or nullNoThe ID of the previous interaction, if any.
inputstring or array of object or object or nullNoThe inputs for the interaction.
generation_configobject or nullNoInput only. Configuration parameters for the model interaction.
agent_configobject or nullNoConfiguration for the agent.

POST /v1beta/interactions​

Create an interaction

Starts an interaction in the shape of the Google Interactions API, either with a model (send model) or with a Google agent such as deep research (send agent). Any key allowed to use that model may call it, and the call counts against the key's budget and rate limits.

Docs

Request body (application/json, object):

FieldTypeRequiredDescription
modelstringYesThe name of the Model used for generating the interaction.
streamboolean or nullNoInput only. Whether the interaction will be streamed.
storeboolean or nullNoInput only. Whether to store the response and request for later retrieval.
idstring or nullNoOutput only. A unique identifier for the interaction completion.
statusenum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued" or nullNoOutput only. The status of the interaction.
createdstring or nullNoOutput only. The time at which the response was created in ISO 8601 format
updatedstring or nullNoOutput only. The time at which the response was last updated in ISO 8601 format
outputsarray of object or nullNoOutput only. Responses from the model.
system_instructionstring or nullNoSystem instruction for the interaction.
toolsarray of object or nullNoA list of tool declarations the model may call during interaction.
backgroundboolean or nullNoWhether to run the model interaction in the background.
usageobject or nullNoOutput only. Statistics on the interaction request's token usage.
response_modalitiesarray of enum: "text", "image", "audio" or nullNoThe requested modalities of the response (TEXT, IMAGE, AUDIO).
response_formatany or nullNoEnforces that the generated response is a JSON object that complies with
response_mime_typestring or nullNoThe mime type of the response. This is required if response_format is set.
previous_interaction_idstring or nullNoThe ID of the previous interaction, if any.
inputstring or array of object or objectYesThe inputs for the interaction.
generation_configobject or nullNoInput only. Configuration parameters for the model interaction.

Example request:

curl -X POST "http://localhost:4000/v1beta/interactions" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"input": "Summarize the latest release notes in three bullet points."
}'

Responses:

StatusDescriptionBody
200The interaction with its status and outputs.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
modelstring or nullNoThe name of the Model used for generating the interaction.
agentstring or nullNoThe name of the Agent used for generating the interaction.
idstringYesOutput only. A unique identifier for the interaction completion.
statusenum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued"YesOutput only. The status of the interaction.
createdstring or nullNoOutput only. The time at which the response was created in ISO 8601 format
updatedstring or nullNoOutput only. The time at which the response was last updated in ISO 8601 format
outputsarray of object or nullNoOutput only. Responses from the model.
system_instructionstring or nullNoSystem instruction for the interaction.
toolsarray of object or nullNoA list of tool declarations the model may call during interaction.
backgroundboolean or nullNoWhether to run the model interaction in the background.
object"interaction"NoOutput only. The object type of the interaction. Always set to interaction.
usageobject or nullNoOutput only. Statistics on the interaction request's token usage.
response_modalitiesarray of enum: "text", "image", "audio" or nullNoThe requested modalities of the response (TEXT, IMAGE, AUDIO).
response_formatany or nullNoEnforces that the generated response is a JSON object that complies with
response_mime_typestring or nullNoThe mime type of the response. This is required if response_format is set.
previous_interaction_idstring or nullNoThe ID of the previous interaction, if any.
inputstring or array of object or object or nullNoThe inputs for the interaction.
generation_configobject or nullNoInput only. Configuration parameters for the model interaction.
agent_configobject or nullNoConfiguration for the agent.

GET /interactions/{interaction_id}​

Get an interaction

Shows one interaction with its status and outputs, for example to poll a long running agent interaction until it completes. Any valid key may call it, and it changes nothing.

Docs

Parameters:

NameInTypeRequiredDescription
interaction_idpathstringYes

Example request:

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

Responses:

StatusDescriptionBody
200The interaction with its status and outputs.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
modelstring or nullNoThe name of the Model used for generating the interaction.
agentstring or nullNoThe name of the Agent used for generating the interaction.
idstringYesOutput only. A unique identifier for the interaction completion.
statusenum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued"YesOutput only. The status of the interaction.
createdstring or nullNoOutput only. The time at which the response was created in ISO 8601 format
updatedstring or nullNoOutput only. The time at which the response was last updated in ISO 8601 format
outputsarray of object or nullNoOutput only. Responses from the model.
system_instructionstring or nullNoSystem instruction for the interaction.
toolsarray of object or nullNoA list of tool declarations the model may call during interaction.
backgroundboolean or nullNoWhether to run the model interaction in the background.
object"interaction"NoOutput only. The object type of the interaction. Always set to interaction.
usageobject or nullNoOutput only. Statistics on the interaction request's token usage.
response_modalitiesarray of enum: "text", "image", "audio" or nullNoThe requested modalities of the response (TEXT, IMAGE, AUDIO).
response_formatany or nullNoEnforces that the generated response is a JSON object that complies with
response_mime_typestring or nullNoThe mime type of the response. This is required if response_format is set.
previous_interaction_idstring or nullNoThe ID of the previous interaction, if any.
inputstring or array of object or object or nullNoThe inputs for the interaction.
generation_configobject or nullNoInput only. Configuration parameters for the model interaction.
agent_configobject or nullNoConfiguration for the agent.

DELETE /interactions/{interaction_id}​

Delete an interaction

Deletes a stored interaction and its outputs at the provider, for good. Any valid key may call it.

Docs

Parameters:

NameInTypeRequiredDescription
interaction_idpathstringYes

Example request:

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

Responses:

StatusDescriptionBody
200The interaction was deleted.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
successbooleanNoSuccess
idstring or nullNoId

GET /v1beta/interactions/{interaction_id}​

Get an interaction

Shows one interaction with its status and outputs, for example to poll a long running agent interaction until it completes. Any valid key may call it, and it changes nothing.

Docs

Parameters:

NameInTypeRequiredDescription
interaction_idpathstringYes

Example request:

curl -X GET "http://localhost:4000/v1beta/interactions/interaction_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The interaction with its status and outputs.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
modelstring or nullNoThe name of the Model used for generating the interaction.
agentstring or nullNoThe name of the Agent used for generating the interaction.
idstringYesOutput only. A unique identifier for the interaction completion.
statusenum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued"YesOutput only. The status of the interaction.
createdstring or nullNoOutput only. The time at which the response was created in ISO 8601 format
updatedstring or nullNoOutput only. The time at which the response was last updated in ISO 8601 format
outputsarray of object or nullNoOutput only. Responses from the model.
system_instructionstring or nullNoSystem instruction for the interaction.
toolsarray of object or nullNoA list of tool declarations the model may call during interaction.
backgroundboolean or nullNoWhether to run the model interaction in the background.
object"interaction"NoOutput only. The object type of the interaction. Always set to interaction.
usageobject or nullNoOutput only. Statistics on the interaction request's token usage.
response_modalitiesarray of enum: "text", "image", "audio" or nullNoThe requested modalities of the response (TEXT, IMAGE, AUDIO).
response_formatany or nullNoEnforces that the generated response is a JSON object that complies with
response_mime_typestring or nullNoThe mime type of the response. This is required if response_format is set.
previous_interaction_idstring or nullNoThe ID of the previous interaction, if any.
inputstring or array of object or object or nullNoThe inputs for the interaction.
generation_configobject or nullNoInput only. Configuration parameters for the model interaction.
agent_configobject or nullNoConfiguration for the agent.

DELETE /v1beta/interactions/{interaction_id}​

Delete an interaction

Deletes a stored interaction and its outputs at the provider, for good. Any valid key may call it.

Docs

Parameters:

NameInTypeRequiredDescription
interaction_idpathstringYes

Example request:

curl -X DELETE "http://localhost:4000/v1beta/interactions/interaction_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The interaction was deleted.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
successbooleanNoSuccess
idstring or nullNoId

POST /interactions/{interaction_id}/cancel​

Cancel a running interaction

Stops an interaction that is still running, for example a deep research agent you no longer need, and returns it with the status cancelled. Any valid key may call it.

Docs

Parameters:

NameInTypeRequiredDescription
interaction_idpathstringYes

Request body (application/json, object):

Example request:

curl -X POST "http://localhost:4000/interactions/interaction_id-123/cancel" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'

Responses:

StatusDescriptionBody
200The cancelled interaction.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
modelstring or nullNoThe name of the Model used for generating the interaction.
agentstring or nullNoThe name of the Agent used for generating the interaction.
idstringYesOutput only. A unique identifier for the interaction completion.
statusenum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued"YesOutput only. The status of the interaction.
createdstring or nullNoOutput only. The time at which the response was created in ISO 8601 format
updatedstring or nullNoOutput only. The time at which the response was last updated in ISO 8601 format
outputsarray of object or nullNoOutput only. Responses from the model.
system_instructionstring or nullNoSystem instruction for the interaction.
toolsarray of object or nullNoA list of tool declarations the model may call during interaction.
backgroundboolean or nullNoWhether to run the model interaction in the background.
object"interaction"NoOutput only. The object type of the interaction. Always set to interaction.
usageobject or nullNoOutput only. Statistics on the interaction request's token usage.
response_modalitiesarray of enum: "text", "image", "audio" or nullNoThe requested modalities of the response (TEXT, IMAGE, AUDIO).
response_formatany or nullNoEnforces that the generated response is a JSON object that complies with
response_mime_typestring or nullNoThe mime type of the response. This is required if response_format is set.
previous_interaction_idstring or nullNoThe ID of the previous interaction, if any.
inputstring or array of object or object or nullNoThe inputs for the interaction.
generation_configobject or nullNoInput only. Configuration parameters for the model interaction.
agent_configobject or nullNoConfiguration for the agent.

POST /v1beta/interactions/{interaction_id}/cancel​

Cancel a running interaction

Stops an interaction that is still running, for example a deep research agent you no longer need, and returns it with the status cancelled. Any valid key may call it.

Docs

Parameters:

NameInTypeRequiredDescription
interaction_idpathstringYes

Request body (application/json, object):

Example request:

curl -X POST "http://localhost:4000/v1beta/interactions/interaction_id-123/cancel" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'

Responses:

StatusDescriptionBody
200The cancelled interaction.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
modelstring or nullNoThe name of the Model used for generating the interaction.
agentstring or nullNoThe name of the Agent used for generating the interaction.
idstringYesOutput only. A unique identifier for the interaction completion.
statusenum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued"YesOutput only. The status of the interaction.
createdstring or nullNoOutput only. The time at which the response was created in ISO 8601 format
updatedstring or nullNoOutput only. The time at which the response was last updated in ISO 8601 format
outputsarray of object or nullNoOutput only. Responses from the model.
system_instructionstring or nullNoSystem instruction for the interaction.
toolsarray of object or nullNoA list of tool declarations the model may call during interaction.
backgroundboolean or nullNoWhether to run the model interaction in the background.
object"interaction"NoOutput only. The object type of the interaction. Always set to interaction.
usageobject or nullNoOutput only. Statistics on the interaction request's token usage.
response_modalitiesarray of enum: "text", "image", "audio" or nullNoThe requested modalities of the response (TEXT, IMAGE, AUDIO).
response_formatany or nullNoEnforces that the generated response is a JSON object that complies with
response_mime_typestring or nullNoThe mime type of the response. This is required if response_format is set.
previous_interaction_idstring or nullNoThe ID of the previous interaction, if any.
inputstring or array of object or object or nullNoThe inputs for the interaction.
generation_configobject or nullNoInput only. Configuration parameters for the model interaction.
agent_configobject or nullNoConfiguration for the agent.