Skip to main content

Search API

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

MethodPathSummary
POST/searchRun a web search through a search tool
POST/v1/searchRun a web search through a search tool
POST/search/{search_tool_name}Run a web search through a search tool
POST/v1/search/{search_tool_name}Run a web search through a search tool
GET/search/toolsList the search tools the key may use
GET/v1/search/toolsList the search tools the key may use

Endpoints​

POST /search​

Run a web search through a search tool

Run a web search through one of the search tools registered on the gateway.

Name the tool in the path, /v1/search/{search_tool_name}, or in the body as search_tool_name. The body carries query (a string or a list of strings), max_results (1 to 20), search_domain_filter, max_tokens_per_page and country. Every provider answers with the same results list of title, url and snippet, with date and last_updated when the provider returns them.

The caller's key must be allowed to use the tool, the query is logged, and the cost per query comes from the provider's price in the price map.

curl -X POST "http://localhost:4000/v1/search/web-search" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "latest AI gateway release notes", "max_results": 5, "search_domain_filter": ["arxiv.org"], "country": "US"}'

Docs

Parameters:

NameInTypeRequiredDescription
search_tool_namequerystring or nullNo

Request body (application/json, object):

FieldTypeRequiredDescription
querystring or array of stringYesQuery
max_resultsinteger or nullNoMax Results
search_domain_filterarray of string or nullNoSearch Domain Filter
max_tokens_per_pageinteger or nullNoMax Tokens Per Page
countrystring or nullNoCountry
search_tool_namestring or nullNoSearch Tool Name

Example request:

curl -X POST "http://localhost:4000/search" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "latest AI gateway release notes",
"max_results": 5,
"search_domain_filter": [
"arxiv.org"
],
"country": "US"
}'

Responses:

StatusDescriptionBody
200The results the search tool returned, in one shape for every provider.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
resultsarray of objectYesResults
objectstringNoObject

POST /v1/search​

Run a web search through a search tool

Run a web search through one of the search tools registered on the gateway.

Name the tool in the path, /v1/search/{search_tool_name}, or in the body as search_tool_name. The body carries query (a string or a list of strings), max_results (1 to 20), search_domain_filter, max_tokens_per_page and country. Every provider answers with the same results list of title, url and snippet, with date and last_updated when the provider returns them.

The caller's key must be allowed to use the tool, the query is logged, and the cost per query comes from the provider's price in the price map.

curl -X POST "http://localhost:4000/v1/search/web-search" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "latest AI gateway release notes", "max_results": 5, "search_domain_filter": ["arxiv.org"], "country": "US"}'

Docs

Parameters:

NameInTypeRequiredDescription
search_tool_namequerystring or nullNo

Request body (application/json, object):

FieldTypeRequiredDescription
querystring or array of stringYesQuery
max_resultsinteger or nullNoMax Results
search_domain_filterarray of string or nullNoSearch Domain Filter
max_tokens_per_pageinteger or nullNoMax Tokens Per Page
countrystring or nullNoCountry
search_tool_namestring or nullNoSearch Tool Name

Example request:

curl -X POST "http://localhost:4000/v1/search" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "latest AI gateway release notes",
"max_results": 5,
"search_domain_filter": [
"arxiv.org"
],
"country": "US"
}'

Responses:

StatusDescriptionBody
200The results the search tool returned, in one shape for every provider.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
resultsarray of objectYesResults
objectstringNoObject

POST /search/{search_tool_name}​

Run a web search through a search tool

Run a web search through one of the search tools registered on the gateway.

Name the tool in the path, /v1/search/{search_tool_name}, or in the body as search_tool_name. The body carries query (a string or a list of strings), max_results (1 to 20), search_domain_filter, max_tokens_per_page and country. Every provider answers with the same results list of title, url and snippet, with date and last_updated when the provider returns them.

The caller's key must be allowed to use the tool, the query is logged, and the cost per query comes from the provider's price in the price map.

curl -X POST "http://localhost:4000/v1/search/web-search" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "latest AI gateway release notes", "max_results": 5, "search_domain_filter": ["arxiv.org"], "country": "US"}'

Docs

Parameters:

NameInTypeRequiredDescription
search_tool_namepathstring or nullYes

Request body (application/json, object):

FieldTypeRequiredDescription
querystring or array of stringYesQuery
max_resultsinteger or nullNoMax Results
search_domain_filterarray of string or nullNoSearch Domain Filter
max_tokens_per_pageinteger or nullNoMax Tokens Per Page
countrystring or nullNoCountry
search_tool_namestring or nullNoSearch Tool Name

Example request:

curl -X POST "http://localhost:4000/search/search_tool_name-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "latest AI gateway release notes",
"max_results": 5,
"search_domain_filter": [
"arxiv.org"
],
"country": "US"
}'

Responses:

StatusDescriptionBody
200The results the search tool returned, in one shape for every provider.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
resultsarray of objectYesResults
objectstringNoObject

POST /v1/search/{search_tool_name}​

Run a web search through a search tool

Run a web search through one of the search tools registered on the gateway.

Name the tool in the path, /v1/search/{search_tool_name}, or in the body as search_tool_name. The body carries query (a string or a list of strings), max_results (1 to 20), search_domain_filter, max_tokens_per_page and country. Every provider answers with the same results list of title, url and snippet, with date and last_updated when the provider returns them.

The caller's key must be allowed to use the tool, the query is logged, and the cost per query comes from the provider's price in the price map.

curl -X POST "http://localhost:4000/v1/search/web-search" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "latest AI gateway release notes", "max_results": 5, "search_domain_filter": ["arxiv.org"], "country": "US"}'

Docs

Parameters:

NameInTypeRequiredDescription
search_tool_namepathstring or nullYes

Request body (application/json, object):

FieldTypeRequiredDescription
querystring or array of stringYesQuery
max_resultsinteger or nullNoMax Results
search_domain_filterarray of string or nullNoSearch Domain Filter
max_tokens_per_pageinteger or nullNoMax Tokens Per Page
countrystring or nullNoCountry
search_tool_namestring or nullNoSearch Tool Name

Example request:

curl -X POST "http://localhost:4000/v1/search/search_tool_name-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "latest AI gateway release notes",
"max_results": 5,
"search_domain_filter": [
"arxiv.org"
],
"country": "US"
}'

Responses:

StatusDescriptionBody
200The results the search tool returned, in one shape for every provider.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
resultsarray of objectYesResults
objectstringNoObject

GET /search/tools​

List the search tools the key may use

Lists the search tools the calling key may use, with the provider behind each one and its description, so you know which search_tool_name to send to the search route. Tools the key, its team or its user is not granted are left out, the same grants the search route enforces. Nothing is changed.

Example request:

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

Responses:

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

Response fields (200):

FieldTypeRequiredDescription
object"list"YesAlways list
dataarray of objectYesThe search tools the calling key may use

GET /v1/search/tools​

List the search tools the key may use

Lists the search tools the calling key may use, with the provider behind each one and its description, so you know which search_tool_name to send to the search route. Tools the key, its team or its user is not granted are left out, the same grants the search route enforces. Nothing is changed.

Example request:

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

Responses:

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

Response fields (200):

FieldTypeRequiredDescription
object"list"YesAlways list
dataarray of objectYesThe search tools the calling key may use