Skip to main content

Gemini agents API

This page documents the 5 gateway endpoints tagged gemini_agents 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/v1beta/agentsList managed Gemini agents
POST/v1beta/agentsCreate a managed Gemini agent
GET/v1beta/agents/{name}Get a managed Gemini agent
DELETE/v1beta/agents/{name}Delete a managed Gemini agent
GET/v1beta/agents/{name}/versionsList the versions of a managed Gemini agent

Endpoints​

GET /v1beta/agents​

List managed Gemini agents

Lists the custom agents in your Gemini project, one page at a time. It changes nothing.

A proxy admin may rely on the gateway's own Gemini key. Any other key must bring its own Gemini key in spanway_params_template, otherwise the answer is 401, so nobody can use the operator's Google project by accident. On this route send it as a JSON encoded spanway_params_template query parameter, for example ?spanway_params_template={"api_key":"AIza-example"} URL encoded. A plain api_key query parameter is ignored, so a key never sits in a URL that access logs record.

Docs

Example request:

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

Responses:

StatusDescriptionBody
200One page of the agents in the Gemini project.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
agentsarray of objectNoAgents
next_page_tokenstring or nullNoNext Page Token

POST /v1beta/agents​

Create a managed Gemini agent

Creates a named custom agent in your Gemini project, built on a Google base agent with your own instructions and files, which you can then call through the Interactions API. It is passed to Google unchanged in the Gemini managed agents shape, and it is separate from the gateway's own agent registry at /v1/agents.

A proxy admin may rely on the gateway's own Gemini key. Any other key must bring its own Gemini key in spanway_params_template, otherwise the answer is 401, so nobody can use the operator's Google project by accident. On this route put it in the spanway_params_template field of the body.

Docs

Request body (application/json, object):

FieldTypeRequiredDescription
base_agentstringYesBase Agent
base_environmentobject or nullNoBase Environment
instructionsstring or nullNoInstructions
namestringYesName
spanway_params_templateobject or nullNoSpanway Params Template

Example request:

curl -X POST "http://localhost:4000/v1beta/agents" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"base_agent": "waverunner",
"base_environment": {
"sources": [
{
"source": "gs://my-bucket/slides-skill",
"target": "/.agents/skills/slides-skill",
"type": "gcs"
}
],
"type": "remote"
},
"instructions": "You are a helpful assistant that creates slides.",
"name": "my-custom-slides-agent"
}'

Responses:

StatusDescriptionBody
200The agent as the provider returns 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 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
base_agentstring or nullNoBase Agent
instructionsstring or nullNoInstructions
namestringYesName

GET /v1beta/agents/{name}​

Get a managed Gemini agent

Shows one custom agent in your Gemini project, with its base agent and instructions. It changes nothing.

A proxy admin may rely on the gateway's own Gemini key. Any other key must bring its own Gemini key in spanway_params_template, otherwise the answer is 401, so nobody can use the operator's Google project by accident. On this route send it as a JSON encoded spanway_params_template query parameter, for example ?spanway_params_template={"api_key":"AIza-example"} URL encoded. A plain api_key query parameter is ignored, so a key never sits in a URL that access logs record.

Docs

Parameters:

NameInTypeRequiredDescription
namepathstringYes

Example request:

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

Responses:

StatusDescriptionBody
200The agent as the provider returns 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 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
base_agentstring or nullNoBase Agent
instructionsstring or nullNoInstructions
namestringYesName

DELETE /v1beta/agents/{name}​

Delete a managed Gemini agent

Deletes a custom agent from your Gemini project, for good.

A proxy admin may rely on the gateway's own Gemini key. Any other key must bring its own Gemini key in spanway_params_template, otherwise the answer is 401, so nobody can use the operator's Google project by accident. On this route send it as a JSON encoded spanway_params_template query parameter, for example ?spanway_params_template={"api_key":"AIza-example"} URL encoded. A plain api_key query parameter is ignored, so a key never sits in a URL that access logs record.

Docs

Parameters:

NameInTypeRequiredDescription
namepathstringYes

Example request:

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

Responses:

StatusDescriptionBody
200The agent 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
deletedbooleanNoDeleted
namestringYesName

GET /v1beta/agents/{name}/versions​

List the versions of a managed Gemini agent

Lists the saved versions of a custom agent in your Gemini project, one page at a time. It changes nothing.

A proxy admin may rely on the gateway's own Gemini key. Any other key must bring its own Gemini key in spanway_params_template, otherwise the answer is 401, so nobody can use the operator's Google project by accident. On this route send it as a JSON encoded spanway_params_template query parameter, for example ?spanway_params_template={"api_key":"AIza-example"} URL encoded. A plain api_key query parameter is ignored, so a key never sits in a URL that access logs record.

Docs

Parameters:

NameInTypeRequiredDescription
namepathstringYes

Example request:

curl -X GET "http://localhost:4000/v1beta/agents/name-123/versions" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200One page of the versions of the agent.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
agent_versionsarray of objectNoAgent Versions
next_page_tokenstring or nullNoNext Page Token