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.
| Method | Path | Summary |
|---|---|---|
| POST | /models/{model_name}:generateContent | Generate content (Gemini generateContent format) |
| POST | /v1beta/models/{model_name}:generateContent | Generate content (Gemini generateContent format) |
| POST | /models/{model_name}:streamGenerateContent | Stream content (Gemini streamGenerateContent format) |
| POST | /v1beta/models/{model_name}:streamGenerateContent | Stream content (Gemini streamGenerateContent format) |
| POST | /models/{model_name}:countTokens | Count the tokens of a generateContent request |
| POST | /v1beta/models/{model_name}:countTokens | Count the tokens of a generateContent request |
| POST | /interactions | Create an interaction |
| POST | /v1beta/interactions | Create 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}/cancel | Cancel a running interaction |
| POST | /v1beta/interactions/{interaction_id}/cancel | Cancel 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_name | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
contents | array of object | Yes | Contents |
systemInstruction | object | No | SystemInstructions |
tools | object | No | Tools |
toolConfig | object | No | ToolConfig |
safetySettings | array of object | No | Safetysettings |
generationConfig | object | No | GenerateContentGenerationConfig |
cachedContent | string | No | Cachedcontent |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The generateContent response. The streaming route sends the same shape as server-sent events. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
candidates | array of object | No | Candidates |
promptFeedback | object | No | PromptFeedback |
usageMetadata | object | Yes | UsageMetadata |
responseId | string | No | Responseid |
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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_name | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
contents | array of object | Yes | Contents |
systemInstruction | object | No | SystemInstructions |
tools | object | No | Tools |
toolConfig | object | No | ToolConfig |
safetySettings | array of object | No | Safetysettings |
generationConfig | object | No | GenerateContentGenerationConfig |
cachedContent | string | No | Cachedcontent |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The generateContent response. The streaming route sends the same shape as server-sent events. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
candidates | array of object | No | Candidates |
promptFeedback | object | No | PromptFeedback |
usageMetadata | object | Yes | UsageMetadata |
responseId | string | No | Responseid |
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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_name | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
contents | array of object | Yes | Contents |
systemInstruction | object | No | SystemInstructions |
tools | object | No | Tools |
toolConfig | object | No | ToolConfig |
safetySettings | array of object | No | Safetysettings |
generationConfig | object | No | GenerateContentGenerationConfig |
cachedContent | string | No | Cachedcontent |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The generateContent response. The streaming route sends the same shape as server-sent events. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
candidates | array of object | No | Candidates |
promptFeedback | object | No | PromptFeedback |
usageMetadata | object | Yes | UsageMetadata |
responseId | string | No | Responseid |
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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_name | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
contents | array of object | Yes | Contents |
systemInstruction | object | No | SystemInstructions |
tools | object | No | Tools |
toolConfig | object | No | ToolConfig |
safetySettings | array of object | No | Safetysettings |
generationConfig | object | No | GenerateContentGenerationConfig |
cachedContent | string | No | Cachedcontent |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The generateContent response. The streaming route sends the same shape as server-sent events. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
candidates | array of object | No | Candidates |
promptFeedback | object | No | PromptFeedback |
usageMetadata | object | Yes | UsageMetadata |
responseId | string | No | Responseid |
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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_name | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
contents | array of object | Yes | Contents |
system_instruction | object | No | SystemInstructions |
tools | object | No | Tools |
toolConfig | object | No | ToolConfig |
safetySettings | array of object | No | Safetysettings |
generationConfig | object | No | GenerationConfig |
cachedContent | string | No | Cachedcontent |
labels | object | No | Labels |
serviceTier | string | No | Servicetier |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The token count of the request | application/json TokenCountDetailsResponse |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
totalTokens | integer | Yes | Totaltokens |
promptTokensDetails | array of PromptTokensDetails | Yes | Prompttokensdetails |
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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_name | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
contents | array of object | Yes | Contents |
system_instruction | object | No | SystemInstructions |
tools | object | No | Tools |
toolConfig | object | No | ToolConfig |
safetySettings | array of object | No | Safetysettings |
generationConfig | object | No | GenerationConfig |
cachedContent | string | No | Cachedcontent |
labels | object | No | Labels |
serviceTier | string | No | Servicetier |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The token count of the request | application/json TokenCountDetailsResponse |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
totalTokens | integer | Yes | Totaltokens |
promptTokensDetails | array of PromptTokensDetails | Yes | Prompttokensdetails |
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.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The name of the Model used for generating the interaction. |
stream | boolean or null | No | Input only. Whether the interaction will be streamed. |
store | boolean or null | No | Input only. Whether to store the response and request for later retrieval. |
id | string or null | No | Output only. A unique identifier for the interaction completion. |
status | enum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued" or null | No | Output only. The status of the interaction. |
created | string or null | No | Output only. The time at which the response was created in ISO 8601 format |
updated | string or null | No | Output only. The time at which the response was last updated in ISO 8601 format |
outputs | array of object or null | No | Output only. Responses from the model. |
system_instruction | string or null | No | System instruction for the interaction. |
tools | array of object or null | No | A list of tool declarations the model may call during interaction. |
background | boolean or null | No | Whether to run the model interaction in the background. |
usage | object or null | No | Output only. Statistics on the interaction request's token usage. |
response_modalities | array of enum: "text", "image", "audio" or null | No | The requested modalities of the response (TEXT, IMAGE, AUDIO). |
response_format | any or null | No | Enforces that the generated response is a JSON object that complies with |
response_mime_type | string or null | No | The mime type of the response. This is required if response_format is set. |
previous_interaction_id | string or null | No | The ID of the previous interaction, if any. |
input | string or array of object or object | Yes | The inputs for the interaction. |
generation_config | object or null | No | Input 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:
| Status | Description | Body |
|---|---|---|
| 200 | The interaction with its status and outputs. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string or null | No | The name of the Model used for generating the interaction. |
agent | string or null | No | The name of the Agent used for generating the interaction. |
id | string | Yes | Output only. A unique identifier for the interaction completion. |
status | enum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued" | Yes | Output only. The status of the interaction. |
created | string or null | No | Output only. The time at which the response was created in ISO 8601 format |
updated | string or null | No | Output only. The time at which the response was last updated in ISO 8601 format |
outputs | array of object or null | No | Output only. Responses from the model. |
system_instruction | string or null | No | System instruction for the interaction. |
tools | array of object or null | No | A list of tool declarations the model may call during interaction. |
background | boolean or null | No | Whether to run the model interaction in the background. |
object | "interaction" | No | Output only. The object type of the interaction. Always set to interaction. |
usage | object or null | No | Output only. Statistics on the interaction request's token usage. |
response_modalities | array of enum: "text", "image", "audio" or null | No | The requested modalities of the response (TEXT, IMAGE, AUDIO). |
response_format | any or null | No | Enforces that the generated response is a JSON object that complies with |
response_mime_type | string or null | No | The mime type of the response. This is required if response_format is set. |
previous_interaction_id | string or null | No | The ID of the previous interaction, if any. |
input | string or array of object or object or null | No | The inputs for the interaction. |
generation_config | object or null | No | Input only. Configuration parameters for the model interaction. |
agent_config | object or null | No | Configuration 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.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The name of the Model used for generating the interaction. |
stream | boolean or null | No | Input only. Whether the interaction will be streamed. |
store | boolean or null | No | Input only. Whether to store the response and request for later retrieval. |
id | string or null | No | Output only. A unique identifier for the interaction completion. |
status | enum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued" or null | No | Output only. The status of the interaction. |
created | string or null | No | Output only. The time at which the response was created in ISO 8601 format |
updated | string or null | No | Output only. The time at which the response was last updated in ISO 8601 format |
outputs | array of object or null | No | Output only. Responses from the model. |
system_instruction | string or null | No | System instruction for the interaction. |
tools | array of object or null | No | A list of tool declarations the model may call during interaction. |
background | boolean or null | No | Whether to run the model interaction in the background. |
usage | object or null | No | Output only. Statistics on the interaction request's token usage. |
response_modalities | array of enum: "text", "image", "audio" or null | No | The requested modalities of the response (TEXT, IMAGE, AUDIO). |
response_format | any or null | No | Enforces that the generated response is a JSON object that complies with |
response_mime_type | string or null | No | The mime type of the response. This is required if response_format is set. |
previous_interaction_id | string or null | No | The ID of the previous interaction, if any. |
input | string or array of object or object | Yes | The inputs for the interaction. |
generation_config | object or null | No | Input 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:
| Status | Description | Body |
|---|---|---|
| 200 | The interaction with its status and outputs. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string or null | No | The name of the Model used for generating the interaction. |
agent | string or null | No | The name of the Agent used for generating the interaction. |
id | string | Yes | Output only. A unique identifier for the interaction completion. |
status | enum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued" | Yes | Output only. The status of the interaction. |
created | string or null | No | Output only. The time at which the response was created in ISO 8601 format |
updated | string or null | No | Output only. The time at which the response was last updated in ISO 8601 format |
outputs | array of object or null | No | Output only. Responses from the model. |
system_instruction | string or null | No | System instruction for the interaction. |
tools | array of object or null | No | A list of tool declarations the model may call during interaction. |
background | boolean or null | No | Whether to run the model interaction in the background. |
object | "interaction" | No | Output only. The object type of the interaction. Always set to interaction. |
usage | object or null | No | Output only. Statistics on the interaction request's token usage. |
response_modalities | array of enum: "text", "image", "audio" or null | No | The requested modalities of the response (TEXT, IMAGE, AUDIO). |
response_format | any or null | No | Enforces that the generated response is a JSON object that complies with |
response_mime_type | string or null | No | The mime type of the response. This is required if response_format is set. |
previous_interaction_id | string or null | No | The ID of the previous interaction, if any. |
input | string or array of object or object or null | No | The inputs for the interaction. |
generation_config | object or null | No | Input only. Configuration parameters for the model interaction. |
agent_config | object or null | No | Configuration 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
interaction_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/interactions/interaction_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The interaction with its status and outputs. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string or null | No | The name of the Model used for generating the interaction. |
agent | string or null | No | The name of the Agent used for generating the interaction. |
id | string | Yes | Output only. A unique identifier for the interaction completion. |
status | enum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued" | Yes | Output only. The status of the interaction. |
created | string or null | No | Output only. The time at which the response was created in ISO 8601 format |
updated | string or null | No | Output only. The time at which the response was last updated in ISO 8601 format |
outputs | array of object or null | No | Output only. Responses from the model. |
system_instruction | string or null | No | System instruction for the interaction. |
tools | array of object or null | No | A list of tool declarations the model may call during interaction. |
background | boolean or null | No | Whether to run the model interaction in the background. |
object | "interaction" | No | Output only. The object type of the interaction. Always set to interaction. |
usage | object or null | No | Output only. Statistics on the interaction request's token usage. |
response_modalities | array of enum: "text", "image", "audio" or null | No | The requested modalities of the response (TEXT, IMAGE, AUDIO). |
response_format | any or null | No | Enforces that the generated response is a JSON object that complies with |
response_mime_type | string or null | No | The mime type of the response. This is required if response_format is set. |
previous_interaction_id | string or null | No | The ID of the previous interaction, if any. |
input | string or array of object or object or null | No | The inputs for the interaction. |
generation_config | object or null | No | Input only. Configuration parameters for the model interaction. |
agent_config | object or null | No | Configuration 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
interaction_id | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/interactions/interaction_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The interaction was deleted. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
success | boolean | No | Success |
id | string or null | No | Id |
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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
interaction_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/v1beta/interactions/interaction_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The interaction with its status and outputs. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string or null | No | The name of the Model used for generating the interaction. |
agent | string or null | No | The name of the Agent used for generating the interaction. |
id | string | Yes | Output only. A unique identifier for the interaction completion. |
status | enum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued" | Yes | Output only. The status of the interaction. |
created | string or null | No | Output only. The time at which the response was created in ISO 8601 format |
updated | string or null | No | Output only. The time at which the response was last updated in ISO 8601 format |
outputs | array of object or null | No | Output only. Responses from the model. |
system_instruction | string or null | No | System instruction for the interaction. |
tools | array of object or null | No | A list of tool declarations the model may call during interaction. |
background | boolean or null | No | Whether to run the model interaction in the background. |
object | "interaction" | No | Output only. The object type of the interaction. Always set to interaction. |
usage | object or null | No | Output only. Statistics on the interaction request's token usage. |
response_modalities | array of enum: "text", "image", "audio" or null | No | The requested modalities of the response (TEXT, IMAGE, AUDIO). |
response_format | any or null | No | Enforces that the generated response is a JSON object that complies with |
response_mime_type | string or null | No | The mime type of the response. This is required if response_format is set. |
previous_interaction_id | string or null | No | The ID of the previous interaction, if any. |
input | string or array of object or object or null | No | The inputs for the interaction. |
generation_config | object or null | No | Input only. Configuration parameters for the model interaction. |
agent_config | object or null | No | Configuration 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
interaction_id | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/v1beta/interactions/interaction_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The interaction was deleted. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
success | boolean | No | Success |
id | string or null | No | Id |
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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
interaction_id | path | string | Yes |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The cancelled interaction. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string or null | No | The name of the Model used for generating the interaction. |
agent | string or null | No | The name of the Agent used for generating the interaction. |
id | string | Yes | Output only. A unique identifier for the interaction completion. |
status | enum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued" | Yes | Output only. The status of the interaction. |
created | string or null | No | Output only. The time at which the response was created in ISO 8601 format |
updated | string or null | No | Output only. The time at which the response was last updated in ISO 8601 format |
outputs | array of object or null | No | Output only. Responses from the model. |
system_instruction | string or null | No | System instruction for the interaction. |
tools | array of object or null | No | A list of tool declarations the model may call during interaction. |
background | boolean or null | No | Whether to run the model interaction in the background. |
object | "interaction" | No | Output only. The object type of the interaction. Always set to interaction. |
usage | object or null | No | Output only. Statistics on the interaction request's token usage. |
response_modalities | array of enum: "text", "image", "audio" or null | No | The requested modalities of the response (TEXT, IMAGE, AUDIO). |
response_format | any or null | No | Enforces that the generated response is a JSON object that complies with |
response_mime_type | string or null | No | The mime type of the response. This is required if response_format is set. |
previous_interaction_id | string or null | No | The ID of the previous interaction, if any. |
input | string or array of object or object or null | No | The inputs for the interaction. |
generation_config | object or null | No | Input only. Configuration parameters for the model interaction. |
agent_config | object or null | No | Configuration 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.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
interaction_id | path | string | Yes |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The cancelled interaction. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string or null | No | The name of the Model used for generating the interaction. |
agent | string or null | No | The name of the Agent used for generating the interaction. |
id | string | Yes | Output only. A unique identifier for the interaction completion. |
status | enum: "in_progress", "requires_action", "completed", "failed", "cancelled", "incomplete", "budget_exceeded", "queued" | Yes | Output only. The status of the interaction. |
created | string or null | No | Output only. The time at which the response was created in ISO 8601 format |
updated | string or null | No | Output only. The time at which the response was last updated in ISO 8601 format |
outputs | array of object or null | No | Output only. Responses from the model. |
system_instruction | string or null | No | System instruction for the interaction. |
tools | array of object or null | No | A list of tool declarations the model may call during interaction. |
background | boolean or null | No | Whether to run the model interaction in the background. |
object | "interaction" | No | Output only. The object type of the interaction. Always set to interaction. |
usage | object or null | No | Output only. Statistics on the interaction request's token usage. |
response_modalities | array of enum: "text", "image", "audio" or null | No | The requested modalities of the response (TEXT, IMAGE, AUDIO). |
response_format | any or null | No | Enforces that the generated response is a JSON object that complies with |
response_mime_type | string or null | No | The mime type of the response. This is required if response_format is set. |
previous_interaction_id | string or null | No | The ID of the previous interaction, if any. |
input | string or array of object or object or null | No | The inputs for the interaction. |
generation_config | object or null | No | Input only. Configuration parameters for the model interaction. |
agent_config | object or null | No | Configuration for the agent. |