Skip to main content

Files API

This page documents the 15 gateway endpoints tagged files in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.

MethodPathSummary
GET/filesList files
POST/filesUpload a file
GET/v1/filesList files
POST/v1/filesUpload a file
GET/{provider}/v1/filesList files
POST/{provider}/v1/filesUpload a file
GET/files/{file_id}/contentDownload the contents of a file
GET/v1/files/{file_id}/contentDownload the contents of a file
GET/{provider}/v1/files/{file_id}/contentDownload the contents of a file
GET/files/{file_id}Read the details of a file
DELETE/files/{file_id}Delete a file
GET/v1/files/{file_id}Read the details of a file
DELETE/v1/files/{file_id}Delete a file
GET/{provider}/v1/files/{file_id}Read the details of a file
DELETE/{provider}/v1/files/{file_id}Delete a file

Endpoints​

GET /files​

List files

Lists uploaded files one page at a time, optionally narrowed by purpose, with limit and after for paging. With managed files only the caller's own files are listed, and target_model_names picks the model whose files to list. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call. Nothing is changed.

Parameters:

NameInTypeRequiredDescription
providerquerystring or nullNo
target_model_namesquerystring or nullNo
purposequerystring or nullNo
limitqueryinteger or nullNo
afterquerystring or nullNo

Example request:

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

Responses:

StatusDescriptionBody
200One page of files the caller may see.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
object"list"NoObject
dataarray of objectNoData
first_idstring or nullNoFirst Id
last_idstring or nullNoLast Id
has_morebooleanNoHas More

POST /files​

Upload a file

Uploads a file for later use by the batch, fine-tuning, assistants or other APIs, for example a JSONL file of requests to run as a batch. Send it as multipart form data with the file and its purpose. With managed files on, target_model_names uploads it once for each named model and returns one gateway file id that works for all of them. Batch files are checked against the configured size limit, the models they name and the batch guardrails before they reach the provider. expires_after[anchor] and expires_after[seconds] ask the provider to delete the file later. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call.

Parameters:

NameInTypeRequiredDescription
providerquerystring or nullNo

Request body (multipart/form-data, object):

FieldTypeRequiredDescription
filestringYesThe file to upload.
purposestringYesWhy the file is uploaded, for example batch, fine-tune, assistants or user_data.
custom_llm_providerstringNoProvider to upload to when managed files are off.
target_model_namesstringNoComma separated model groups the managed file is uploaded for.
target_storagestringNoA storage backend configured on the gateway to keep the file in instead of the provider.
passthroughbooleanNoUpload the bytes unchanged for a native Vertex AI batch.
expires_after[anchor]stringNoWhat the expiry counts from, created_at. Send it together with expires_after[seconds].
expires_after[seconds]integerNoHow many seconds after the anchor the provider deletes the file.
spanway_metadata[key]stringNoMetadata to log with the upload, one field per key, such as spanway_metadata[ticket].

Example request:

curl -X POST "http://localhost:4000/files" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-F file="@file.bin" \
-F purpose="value"

Responses:

StatusDescriptionBody
200The file object. With managed files the id is a gateway id that maps to the provider files behind it.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The upload is larger than general_settings.max_file_size_mb. Nothing was sent to the provider.application/json ProxyError
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
bytesintegerYesBytes
created_atintegerYesCreated At
filenamestringYesFilename
object"file"YesObject
purposeenum: "assistants", "assistants_output", "batch", "batch_output", "fine-tune", "fine-tune-results", "vision", "user_data", ...YesPurpose
statusenum: "uploaded", "processed", "error", "pending" or nullNoStatus
expires_atinteger or nullNoExpires At
status_detailsstring or nullNoStatus Details
spanway_batch_guardrailobject or nullNo
spanway_details_fallbackboolean or nullNoSpanway Details Fallback

GET /v1/files​

List files

Lists uploaded files one page at a time, optionally narrowed by purpose, with limit and after for paging. With managed files only the caller's own files are listed, and target_model_names picks the model whose files to list. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call. Nothing is changed.

Parameters:

NameInTypeRequiredDescription
providerquerystring or nullNo
target_model_namesquerystring or nullNo
purposequerystring or nullNo
limitqueryinteger or nullNo
afterquerystring or nullNo

Example request:

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

Responses:

StatusDescriptionBody
200One page of files the caller may see.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
object"list"NoObject
dataarray of objectNoData
first_idstring or nullNoFirst Id
last_idstring or nullNoLast Id
has_morebooleanNoHas More

POST /v1/files​

Upload a file

Uploads a file for later use by the batch, fine-tuning, assistants or other APIs, for example a JSONL file of requests to run as a batch. Send it as multipart form data with the file and its purpose. With managed files on, target_model_names uploads it once for each named model and returns one gateway file id that works for all of them. Batch files are checked against the configured size limit, the models they name and the batch guardrails before they reach the provider. expires_after[anchor] and expires_after[seconds] ask the provider to delete the file later. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call.

Parameters:

NameInTypeRequiredDescription
providerquerystring or nullNo

Request body (multipart/form-data, object):

FieldTypeRequiredDescription
filestringYesThe file to upload.
purposestringYesWhy the file is uploaded, for example batch, fine-tune, assistants or user_data.
custom_llm_providerstringNoProvider to upload to when managed files are off.
target_model_namesstringNoComma separated model groups the managed file is uploaded for.
target_storagestringNoA storage backend configured on the gateway to keep the file in instead of the provider.
passthroughbooleanNoUpload the bytes unchanged for a native Vertex AI batch.
expires_after[anchor]stringNoWhat the expiry counts from, created_at. Send it together with expires_after[seconds].
expires_after[seconds]integerNoHow many seconds after the anchor the provider deletes the file.
spanway_metadata[key]stringNoMetadata to log with the upload, one field per key, such as spanway_metadata[ticket].

Example request:

curl -X POST "http://localhost:4000/v1/files" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-F file="@file.bin" \
-F purpose="value"

Responses:

StatusDescriptionBody
200The file object. With managed files the id is a gateway id that maps to the provider files behind it.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The upload is larger than general_settings.max_file_size_mb. Nothing was sent to the provider.application/json ProxyError
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
bytesintegerYesBytes
created_atintegerYesCreated At
filenamestringYesFilename
object"file"YesObject
purposeenum: "assistants", "assistants_output", "batch", "batch_output", "fine-tune", "fine-tune-results", "vision", "user_data", ...YesPurpose
statusenum: "uploaded", "processed", "error", "pending" or nullNoStatus
expires_atinteger or nullNoExpires At
status_detailsstring or nullNoStatus Details
spanway_batch_guardrailobject or nullNo
spanway_details_fallbackboolean or nullNoSpanway Details Fallback

GET /{provider}/v1/files​

List files

Lists uploaded files one page at a time, optionally narrowed by purpose, with limit and after for paging. With managed files only the caller's own files are listed, and target_model_names picks the model whose files to list. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call. Nothing is changed.

Parameters:

NameInTypeRequiredDescription
providerpathstring or nullYes
target_model_namesquerystring or nullNo
purposequerystring or nullNo
limitqueryinteger or nullNo
afterquerystring or nullNo

Example request:

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

Responses:

StatusDescriptionBody
200One page of files the caller may see.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
object"list"NoObject
dataarray of objectNoData
first_idstring or nullNoFirst Id
last_idstring or nullNoLast Id
has_morebooleanNoHas More

POST /{provider}/v1/files​

Upload a file

Uploads a file for later use by the batch, fine-tuning, assistants or other APIs, for example a JSONL file of requests to run as a batch. Send it as multipart form data with the file and its purpose. With managed files on, target_model_names uploads it once for each named model and returns one gateway file id that works for all of them. Batch files are checked against the configured size limit, the models they name and the batch guardrails before they reach the provider. expires_after[anchor] and expires_after[seconds] ask the provider to delete the file later. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call.

Parameters:

NameInTypeRequiredDescription
providerpathstring or nullYes

Request body (multipart/form-data, object):

FieldTypeRequiredDescription
filestringYesThe file to upload.
purposestringYesWhy the file is uploaded, for example batch, fine-tune, assistants or user_data.
custom_llm_providerstringNoProvider to upload to when managed files are off.
target_model_namesstringNoComma separated model groups the managed file is uploaded for.
target_storagestringNoA storage backend configured on the gateway to keep the file in instead of the provider.
passthroughbooleanNoUpload the bytes unchanged for a native Vertex AI batch.
expires_after[anchor]stringNoWhat the expiry counts from, created_at. Send it together with expires_after[seconds].
expires_after[seconds]integerNoHow many seconds after the anchor the provider deletes the file.
spanway_metadata[key]stringNoMetadata to log with the upload, one field per key, such as spanway_metadata[ticket].

Example request:

curl -X POST "http://localhost:4000/provider-123/v1/files" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-F file="@file.bin" \
-F purpose="value"

Responses:

StatusDescriptionBody
200The file object. With managed files the id is a gateway id that maps to the provider files behind it.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The upload is larger than general_settings.max_file_size_mb. Nothing was sent to the provider.application/json ProxyError
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
bytesintegerYesBytes
created_atintegerYesCreated At
filenamestringYesFilename
object"file"YesObject
purposeenum: "assistants", "assistants_output", "batch", "batch_output", "fine-tune", "fine-tune-results", "vision", "user_data", ...YesPurpose
statusenum: "uploaded", "processed", "error", "pending" or nullNoStatus
expires_atinteger or nullNoExpires At
status_detailsstring or nullNoStatus Details
spanway_batch_guardrailobject or nullNo
spanway_details_fallbackboolean or nullNoSpanway Details Fallback

GET /files/{file_id}/content​

Download the contents of a file

Downloads the bytes of an uploaded or generated file, for example the output of a finished batch job. With managed files the id is the gateway's file id and the caller must own it, and a per key download limit applies when one is configured. Send provider, or call the provider prefixed path, when managed files are off. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call.

Parameters:

NameInTypeRequiredDescription
file_idpathstringYes
providerquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/files/file_id-123/content" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The file's bytes, with the content type the provider reports, for example a JSONL batch output.application/octet-stream string
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

GET /v1/files/{file_id}/content​

Download the contents of a file

Downloads the bytes of an uploaded or generated file, for example the output of a finished batch job. With managed files the id is the gateway's file id and the caller must own it, and a per key download limit applies when one is configured. Send provider, or call the provider prefixed path, when managed files are off. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call.

Parameters:

NameInTypeRequiredDescription
file_idpathstringYes
providerquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/v1/files/file_id-123/content" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The file's bytes, with the content type the provider reports, for example a JSONL batch output.application/octet-stream string
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

GET /{provider}/v1/files/{file_id}/content​

Download the contents of a file

Downloads the bytes of an uploaded or generated file, for example the output of a finished batch job. With managed files the id is the gateway's file id and the caller must own it, and a per key download limit applies when one is configured. Send provider, or call the provider prefixed path, when managed files are off. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call.

Parameters:

NameInTypeRequiredDescription
file_idpathstringYes
providerpathstring or nullYes

Example request:

curl -X GET "http://localhost:4000/provider-123/v1/files/file_id-123/content" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The file's bytes, with the content type the provider reports, for example a JSONL batch output.application/octet-stream string
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

GET /files/{file_id}​

Read the details of a file

Returns the details of one file, such as its name, size, purpose and processing status, without its contents. With managed files the id is the gateway's file id and the caller must own it. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call. Nothing is changed.

Parameters:

NameInTypeRequiredDescription
file_idpathstringYes
providerquerystring or nullNo

Example request:

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

Responses:

StatusDescriptionBody
200The file object.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
bytesintegerYesBytes
created_atintegerYesCreated At
filenamestringYesFilename
object"file"YesObject
purposeenum: "assistants", "assistants_output", "batch", "batch_output", "fine-tune", "fine-tune-results", "vision", "user_data", ...YesPurpose
statusenum: "uploaded", "processed", "error", "pending" or nullNoStatus
expires_atinteger or nullNoExpires At
status_detailsstring or nullNoStatus Details
spanway_batch_guardrailobject or nullNo
spanway_details_fallbackboolean or nullNoSpanway Details Fallback

DELETE /files/{file_id}​

Delete a file

Deletes a file so it can no longer be used or downloaded. With managed files the id is the gateway's file id and the caller must own the file. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call. This cannot be undone.

Parameters:

NameInTypeRequiredDescription
file_idpathstringYes
providerquerystring or nullNo

Example request:

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

Responses:

StatusDescriptionBody
200Confirmation that the file was deleted.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
deletedbooleanYesDeleted
object"file"YesObject

GET /v1/files/{file_id}​

Read the details of a file

Returns the details of one file, such as its name, size, purpose and processing status, without its contents. With managed files the id is the gateway's file id and the caller must own it. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call. Nothing is changed.

Parameters:

NameInTypeRequiredDescription
file_idpathstringYes
providerquerystring or nullNo

Example request:

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

Responses:

StatusDescriptionBody
200The file object.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
bytesintegerYesBytes
created_atintegerYesCreated At
filenamestringYesFilename
object"file"YesObject
purposeenum: "assistants", "assistants_output", "batch", "batch_output", "fine-tune", "fine-tune-results", "vision", "user_data", ...YesPurpose
statusenum: "uploaded", "processed", "error", "pending" or nullNoStatus
expires_atinteger or nullNoExpires At
status_detailsstring or nullNoStatus Details
spanway_batch_guardrailobject or nullNo
spanway_details_fallbackboolean or nullNoSpanway Details Fallback

DELETE /v1/files/{file_id}​

Delete a file

Deletes a file so it can no longer be used or downloaded. With managed files the id is the gateway's file id and the caller must own the file. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call. This cannot be undone.

Parameters:

NameInTypeRequiredDescription
file_idpathstringYes
providerquerystring or nullNo

Example request:

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

Responses:

StatusDescriptionBody
200Confirmation that the file was deleted.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
deletedbooleanYesDeleted
object"file"YesObject

GET /{provider}/v1/files/{file_id}​

Read the details of a file

Returns the details of one file, such as its name, size, purpose and processing status, without its contents. With managed files the id is the gateway's file id and the caller must own it. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call. Nothing is changed.

Parameters:

NameInTypeRequiredDescription
file_idpathstringYes
providerpathstring or nullYes

Example request:

curl -X GET "http://localhost:4000/provider-123/v1/files/file_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The file object.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
bytesintegerYesBytes
created_atintegerYesCreated At
filenamestringYesFilename
object"file"YesObject
purposeenum: "assistants", "assistants_output", "batch", "batch_output", "fine-tune", "fine-tune-results", "vision", "user_data", ...YesPurpose
statusenum: "uploaded", "processed", "error", "pending" or nullNoStatus
expires_atinteger or nullNoExpires At
status_detailsstring or nullNoStatus Details
spanway_batch_guardrailobject or nullNo
spanway_details_fallbackboolean or nullNoSpanway Details Fallback

DELETE /{provider}/v1/files/{file_id}​

Delete a file

Deletes a file so it can no longer be used or downloaded. With managed files the id is the gateway's file id and the caller must own the file. Any key that may call the provider or model may call it, and the request is logged and tracked like any other call. This cannot be undone.

Parameters:

NameInTypeRequiredDescription
file_idpathstringYes
providerpathstring or nullYes

Example request:

curl -X DELETE "http://localhost:4000/provider-123/v1/files/file_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Confirmation that the file was deleted.application/json object
400The request is invalid, for example a missing or unsupported parameter, a prompt longer than the model's context window, content a guardrail or the provider refused, or no deployment that satisfies the data policy of the key, team or organization (No deployment of model 'gpt-5.5' satisfies the data policy: ...). error.message says which.application/json ProxyError
401No valid key was sent, or the key has expired or is blocked.application/json ProxyError
403The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403.application/json ProxyError
404The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...).application/json ProxyError
408The provider did not answer before the request timed out.application/json ProxyError
413The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docsapplication/json object
422The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError or HTTPValidationError
429Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an errorapplication/json ProxyError
500The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing.application/json ProxyError
502The provider, or a proxy in front of it, answered with something that is not a valid response.application/json ProxyError
503The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
deletedbooleanYesDeleted
object"file"YesObject