Assistants API
This page documents the 16 gateway endpoints tagged assistants 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 |
|---|---|---|
| GET | /assistants | List assistants |
| POST | /assistants | Create an assistant |
| GET | /v1/assistants | List assistants |
| POST | /v1/assistants | Create an assistant |
| DELETE | /assistants/{assistant_id} | Delete an assistant |
| DELETE | /v1/assistants/{assistant_id} | Delete an assistant |
| POST | /threads | Create a thread |
| POST | /v1/threads | Create a thread |
| GET | /threads/{thread_id} | Get a thread |
| GET | /v1/threads/{thread_id} | Get a thread |
| GET | /threads/{thread_id}/messages | List the messages of a thread |
| POST | /threads/{thread_id}/messages | Add a message to a thread |
| GET | /v1/threads/{thread_id}/messages | List the messages of a thread |
| POST | /v1/threads/{thread_id}/messages | Add a message to a thread |
| POST | /threads/{thread_id}/runs | Run an assistant on a thread |
| POST | /v1/threads/{thread_id}/runs | Run an assistant on a thread |
Endpoints
GET /assistants
List assistants
List the assistants stored with the provider. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Example request:
curl -X GET "http://localhost:4000/assistants" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One page of assistants, in the OpenAI list shape. | application/json SyncCursorPage_Assistant_ |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of Assistant | Yes | Data |
has_more | boolean or null | No | Has More |
POST /assistants
Create an assistant
Create an assistant, a saved set of instructions, model and tools that runs on threads. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
name | string or null | No | Name |
description | string or null | No | Description |
instructions | string or null | No | Instructions |
tools | array of object or null | No | Tools |
metadata | object or null | No | Metadata |
Example request:
curl -X POST "http://localhost:4000/assistants" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"name": "Support helper",
"instructions": "Answer support questions briefly.",
"tools": [
{
"type": "file_search"
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The assistant object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
description | string or null | No | Description |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string | Yes | Model |
name | string or null | No | Name |
object | "assistant" | Yes | Object |
tools | array of object | Yes | Tools |
response_format | "auto" or object or null | No | Response Format |
temperature | number or null | No | Temperature |
tool_resources | object or null | No | |
top_p | number or null | No | Top P |
GET /v1/assistants
List assistants
List the assistants stored with the provider. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Example request:
curl -X GET "http://localhost:4000/v1/assistants" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One page of assistants, in the OpenAI list shape. | application/json SyncCursorPage_Assistant_ |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of Assistant | Yes | Data |
has_more | boolean or null | No | Has More |
POST /v1/assistants
Create an assistant
Create an assistant, a saved set of instructions, model and tools that runs on threads. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
name | string or null | No | Name |
description | string or null | No | Description |
instructions | string or null | No | Instructions |
tools | array of object or null | No | Tools |
metadata | object or null | No | Metadata |
Example request:
curl -X POST "http://localhost:4000/v1/assistants" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"name": "Support helper",
"instructions": "Answer support questions briefly.",
"tools": [
{
"type": "file_search"
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The assistant object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
description | string or null | No | Description |
instructions | string or null | No | Instructions |
metadata | object or null | No | Metadata |
model | string | Yes | Model |
name | string or null | No | Name |
object | "assistant" | Yes | Object |
tools | array of object | Yes | Tools |
response_format | "auto" or object or null | No | Response Format |
temperature | number or null | No | Temperature |
tool_resources | object or null | No | |
top_p | number or null | No | Top P |
DELETE /assistants/{assistant_id}
Delete an assistant
Delete an assistant at the provider. Threads keep their messages, but no new run can use it. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
assistant_id | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/assistants/assistant_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The id of the deleted assistant. | application/json AssistantDeleted |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
deleted | boolean | Yes | Deleted |
object | "assistant.deleted" | Yes | Object |
DELETE /v1/assistants/{assistant_id}
Delete an assistant
Delete an assistant at the provider. Threads keep their messages, but no new run can use it. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
assistant_id | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/v1/assistants/assistant_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The id of the deleted assistant. | application/json AssistantDeleted |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
deleted | boolean | Yes | Deleted |
object | "assistant.deleted" | Yes | Object |
POST /threads
Create a thread
Start a thread, the conversation an assistant works on, optionally with its first messages. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
messages | array of object or null | No | Messages |
metadata | object or null | No | Metadata |
Example request:
curl -X POST "http://localhost:4000/threads" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": "How do I reset my password?"
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The thread object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
metadata | any or null | No | Metadata |
object | "thread" | Yes | Object |
POST /v1/threads
Create a thread
Start a thread, the conversation an assistant works on, optionally with its first messages. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
messages | array of object or null | No | Messages |
metadata | object or null | No | Metadata |
Example request:
curl -X POST "http://localhost:4000/v1/threads" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": "How do I reset my password?"
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The thread object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
metadata | any or null | No | Metadata |
object | "thread" | Yes | Object |
GET /threads/{thread_id}
Get a thread
Read one thread by its id. Nothing changes. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
thread_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/threads/thread_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The thread object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
metadata | any or null | No | Metadata |
object | "thread" | Yes | Object |
GET /v1/threads/{thread_id}
Get a thread
Read one thread by its id. Nothing changes. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
thread_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/v1/threads/thread_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The thread object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
created_at | integer | Yes | Created At |
metadata | any or null | No | Metadata |
object | "thread" | Yes | Object |
GET /threads/{thread_id}/messages
List the messages of a thread
List the messages of a thread, newest first, including the assistant's replies. Nothing changes. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
thread_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/threads/thread_id-123/messages" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One page of the thread's messages, in the OpenAI list shape. | application/json SyncCursorPage_Message_ |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of Message-Output | Yes | Data |
has_more | boolean or null | No | Has More |
POST /threads/{thread_id}/messages
Add a message to a thread
Add a message to a thread before running an assistant on it. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
thread_id | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
role | enum: "user", "assistant" | Yes | Role |
content | string or array of object | Yes | Content |
attachments | array of object or null | No | Attachments |
metadata | object or null | No | Metadata |
Example request:
curl -X POST "http://localhost:4000/threads/thread_id-123/messages" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"role": "user",
"content": "How do I reset my password?"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The message object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
assistant_id | string or null | No | Assistant Id |
attachments | array of object or null | No | Attachments |
completed_at | integer or null | No | Completed At |
content | array of object | Yes | Content |
created_at | integer | Yes | Created At |
incomplete_at | integer or null | No | Incomplete At |
incomplete_details | object or null | No | |
metadata | object or null | No | Metadata |
object | "thread.message" | Yes | Object |
role | enum: "user", "assistant" | Yes | Role |
run_id | string or null | No | Run Id |
status | enum: "in_progress", "incomplete", "completed" | Yes | Status |
thread_id | string | Yes | Thread Id |
GET /v1/threads/{thread_id}/messages
List the messages of a thread
List the messages of a thread, newest first, including the assistant's replies. Nothing changes. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
thread_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/v1/threads/thread_id-123/messages" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One page of the thread's messages, in the OpenAI list shape. | application/json SyncCursorPage_Message_ |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of Message-Output | Yes | Data |
has_more | boolean or null | No | Has More |
POST /v1/threads/{thread_id}/messages
Add a message to a thread
Add a message to a thread before running an assistant on it. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
thread_id | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
role | enum: "user", "assistant" | Yes | Role |
content | string or array of object | Yes | Content |
attachments | array of object or null | No | Attachments |
metadata | object or null | No | Metadata |
Example request:
curl -X POST "http://localhost:4000/v1/threads/thread_id-123/messages" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"role": "user",
"content": "How do I reset my password?"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The message object. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
assistant_id | string or null | No | Assistant Id |
attachments | array of object or null | No | Attachments |
completed_at | integer or null | No | Completed At |
content | array of object | Yes | Content |
created_at | integer | Yes | Created At |
incomplete_at | integer or null | No | Incomplete At |
incomplete_details | object or null | No | |
metadata | object or null | No | Metadata |
object | "thread.message" | Yes | Object |
role | enum: "user", "assistant" | Yes | Role |
run_id | string or null | No | Run Id |
status | enum: "in_progress", "incomplete", "completed" | Yes | Status |
thread_id | string | Yes | Thread Id |
POST /threads/{thread_id}/runs
Run an assistant on a thread
Start a run, which has an assistant read the thread and add its reply. Without stream the call waits until the run finishes and returns it, with stream set to true the events arrive as they happen. Then list the thread's messages to read the reply. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
thread_id | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
assistant_id | string | Yes | Assistant Id |
model | string or null | No | Model |
instructions | string or null | No | Instructions |
additional_instructions | string or null | No | Additional Instructions |
tools | array of object or null | No | Tools |
metadata | object or null | No | Metadata |
stream | boolean or null | No | Stream |
Example request:
curl -X POST "http://localhost:4000/threads/thread_id-123/runs" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"assistant_id": "asst_7c2d4e1f"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The run object. Poll it until status is completed, then read the thread's messages. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
assistant_id | string | Yes | Assistant Id |
cancelled_at | integer or null | No | Cancelled At |
completed_at | integer or null | No | Completed At |
created_at | integer | Yes | Created At |
expires_at | integer or null | No | Expires At |
failed_at | integer or null | No | Failed At |
incomplete_details | object or null | No | |
instructions | string | Yes | Instructions |
last_error | object or null | No | |
max_completion_tokens | integer or null | No | Max Completion Tokens |
max_prompt_tokens | integer or null | No | Max Prompt Tokens |
metadata | object or null | No | Metadata |
model | string | Yes | Model |
object | "thread.run" | Yes | Object |
parallel_tool_calls | boolean | Yes | Parallel Tool Calls |
required_action | object or null | No | |
response_format | "auto" or object or null | No | Response Format |
started_at | integer or null | No | Started At |
status | enum: "queued", "in_progress", "requires_action", "cancelling", "cancelled", "failed", "completed", "incomplete", ... | Yes | Status |
thread_id | string | Yes | Thread Id |
tool_choice | enum: "none", "auto", "required" or object or null | No | Tool Choice |
tools | array of object | Yes | Tools |
truncation_strategy | object or null | No | |
usage | object or null | No | |
temperature | number or null | No | Temperature |
top_p | number or null | No | Top P |
POST /v1/threads/{thread_id}/runs
Run an assistant on a thread
Start a run, which has an assistant read the thread and add its reply. Without stream the call waits until the run finishes and returns it, with stream set to true the events arrive as they happen. Then list the thread's messages to read the reply. Assistants, threads, messages and runs are stored by the provider named in assistant_settings of the gateway config, in the OpenAI Assistants format, and the gateway forwards the call with the credentials from that setting, so callers never hold the provider key. Any virtual key allowed to call LLM routes can call it, and the call is logged like any other request.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
thread_id | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
assistant_id | string | Yes | Assistant Id |
model | string or null | No | Model |
instructions | string or null | No | Instructions |
additional_instructions | string or null | No | Additional Instructions |
tools | array of object or null | No | Tools |
metadata | object or null | No | Metadata |
stream | boolean or null | No | Stream |
Example request:
curl -X POST "http://localhost:4000/v1/threads/thread_id-123/runs" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"assistant_id": "asst_7c2d4e1f"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The run object. Poll it until status is completed, then read the thread's messages. | application/json object |
| 400 | The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which. | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
assistant_id | string | Yes | Assistant Id |
cancelled_at | integer or null | No | Cancelled At |
completed_at | integer or null | No | Completed At |
created_at | integer | Yes | Created At |
expires_at | integer or null | No | Expires At |
failed_at | integer or null | No | Failed At |
incomplete_details | object or null | No | |
instructions | string | Yes | Instructions |
last_error | object or null | No | |
max_completion_tokens | integer or null | No | Max Completion Tokens |
max_prompt_tokens | integer or null | No | Max Prompt Tokens |
metadata | object or null | No | Metadata |
model | string | Yes | Model |
object | "thread.run" | Yes | Object |
parallel_tool_calls | boolean | Yes | Parallel Tool Calls |
required_action | object or null | No | |
response_format | "auto" or object or null | No | Response Format |
started_at | integer or null | No | Started At |
status | enum: "queued", "in_progress", "requires_action", "cancelling", "cancelled", "failed", "completed", "incomplete", ... | Yes | Status |
thread_id | string | Yes | Thread Id |
tool_choice | enum: "none", "auto", "required" or object or null | No | Tool Choice |
tools | array of object | Yes | Tools |
truncation_strategy | object or null | No | |
usage | object or null | No | |
temperature | number or null | No | Temperature |
top_p | number or null | No | Top P |