SandBase Gemini API
Google Gemini-compatible GenerateContent and Interactions APIs
Google Gemini-compatible GenerateContent and Interactions APIs
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/sandbase-ai:sandbase-ai-gemini-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: SandBase Gemini API
description: 'SandBase is an agent-native platform for connecting Agents to the real world.
Use one account and one key to call Models, ready-made APIs, and Agents.
## Authentication
Public API requests require a SandBase API key. Use `Authorization: Bearer sk-YOUR_KEY` by default.
Anthropic Messages and Google Gemini-compatible operations also document their native SDK-compatible key locations.
## SDK Compatibility
- **LLM Gateway** (`/v1/chat/completions`): Use OpenAI SDK with `base_url="https://api.sandbase.ai/v1"`
- **Embeddings** (`/v1/embeddings`): Use OpenAI SDK with `base_url="https://api.sandbase.ai/v1"`
- **Images** (`/v1/images/generations`, `/v1/images/edits`): Use OpenAI SDK with `base_url="https://api.sandbase.ai/v1"`
- **Anthropic Messages** (`/v1/messages`): Use Anthropic SDK with `base_url="https://api.sandbase.ai"`
- **Google Gemini GenerateContent** (`/v1beta/models/{model}:generateContent`): Configure the Google Gen AI SDK to use `https://api.sandbase.ai`
- **Agents and Sessions** (`/v1/agents`, `/v1/agents/sessions`): Follow the OpenAI Agents protocol (`OpenAI-Beta: agents=v1` is optional) plus the documented SandBase extensions
- **Agents platform resources** (`/v1/agents*`, `/v1/mcp-connections*`, `/v1/secrets*`, `/v1/skills*`): Accept `Authorization: Bearer` or `X-API-Key` and return the `AgentsError` envelope'
version: 1.0.0
x-sandbase-session-contract:
status: active
feature: Agents platform Sessions
description: A Session (ses_*) runs one saved Agent version in a SandBase-hosted environment. Sessions are created directly with POST /v1/agents/sessions. Internal runtime identities are never exposed.
contact:
name: SandBase
url: https://www.sandbase.ai
license:
name: Proprietary
servers:
- url: https://api.sandbase.ai
description: Production
security:
- BearerAuth: []
tags:
- name: Gemini
description: Google Gemini-compatible GenerateContent and Interactions APIs
paths:
/v1beta/models/{model}:generateContent:
post:
operationId: generateGeminiContent
tags:
- Gemini
summary: Generate content with the Google Gemini protocol
description: 'Accepts a Google Gemini GenerateContent request and returns a Gemini-compatible response. A bare model name,
such as gemini-3.5-flash, is normalized to the SandBase catalog name google/gemini-3.5-flash. This endpoint
also accepts x-goog-api-key and the key query parameter for Google SDK compatibility, although headers are safer.
Models with a native passthrough mapping preserve provider-defined request and response fields, including image
response modalities. Other mappings may use the translated capability subset documented in the schema below.'
security:
- GoogleApiKey: []
- BearerAuth: []
- GoogleQueryApiKey: []
parameters:
- $ref: '#/components/parameters/GeminiModel'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiGenerateContentRequest'
responses:
'200':
description: Gemini GenerateContent response
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiGenerateContentResponse'
'400':
description: Invalid JSON or a request rejected by the selected native or translated mapping
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'401':
description: Missing, invalid, revoked, or expired API key
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'402':
description: Organization balance and credit are exhausted
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'403':
description: API Key spending limit reached, organization disabled, or upstream permission rejected
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'404':
description: Model, method, or upstream resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'429':
description: Provider rate limit exceeded
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'500':
description: Prediction lifecycle or provider error
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'502':
description: Upstream response failed or could not be processed
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'503':
description: Routing failed or all provider candidates were unavailable
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'504':
description: Upstream request timed out
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
/v1beta/models/{model}:streamGenerateContent:
post:
operationId: streamGeminiContent
tags:
- Gemini
summary: Stream content with the Google Gemini protocol
description: Returns a streamed JSON array by default. Add alt=sse to receive Server-Sent Events instead.
security:
- GoogleApiKey: []
- BearerAuth: []
- GoogleQueryApiKey: []
parameters:
- $ref: '#/components/parameters/GeminiModel'
- name: alt
in: query
schema:
type: string
enum:
- sse
description: Set to sse for Server-Sent Events. Any other or omitted value uses the Google-compatible streamed JSON array.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiGenerateContentRequest'
responses:
'200':
description: Gemini response frames
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/GeminiGenerateContentResponse'
text/event-stream:
schema:
type: string
description: SSE data frames containing Gemini GenerateContentResponse objects.
'400':
description: Invalid JSON or an input field that SandBase cannot safely translate
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'401':
description: Missing, invalid, revoked, or expired API key
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'402':
description: Organization balance and credit are exhausted
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'403':
description: API Key spending limit reached, organization disabled, or upstream permission rejected
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'404':
description: Model, method, or upstream resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'429':
description: Provider rate limit exceeded before streaming starts
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'500':
description: Prediction lifecycle or provider error before streaming starts
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'502':
description: Upstream stream could not be translated
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'503':
description: Routing failed or all provider candidates were unavailable
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'504':
description: Upstream request timed out before streaming starts
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
/v1beta/interactions:
post:
operationId: createGeminiInteraction
tags:
- Gemini
summary: Create a Google Gemini Interaction
description: 'Proxies the Google Interactions protocol while routing the logical model through SandBase. Successful requests
always return HTTP 200. Check status: an in_progress response is pollable and is not a completed result.
Set stream=true for SSE, or background=true for a durable background submission; they cannot both be true.'
security:
- GoogleApiKey: []
- BearerAuth: []
- GoogleQueryApiKey: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiInteractionRequest'
responses:
'200':
description: Current or terminal Interaction, or an Interaction event stream
headers:
Location:
schema:
type: string
description: Polling path when the returned Interaction is still in_progress. This convenience header may be omitted for a terminal response.
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiInteraction'
text/event-stream:
schema:
type: string
description: Google Interactions SSE events ending with a done event and data [DONE]. In-stream failures use an error event after headers are written.
'400':
description: Invalid JSON, missing model, unsupported Agent interaction, incompatible background and stream settings, stale conversation affinity, or upstream request rejection
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'401':
description: Missing, invalid, revoked, or expired API key
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'402':
description: Organization balance and credit are exhausted
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'403':
description: API Key spending limit reached, organization disabled, or upstream permission rejected
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'404':
description: Logical model or usable provider was not found
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'422':
description: Upstream rejected otherwise valid Interaction fields
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'429':
description: Provider rate limit exceeded after failover attempts
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'500':
description: Prediction lifecycle or internal persistence failed
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'502':
description: Upstream response exceeded the gateway size limit
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'503':
description: Routing, upstream connection, or durable background handoff failed
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'504':
description: Upstream request timed out after failover attempts
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
/v1beta/interactions/{id}:
get:
operationId: getGeminiInteraction
tags:
- Gemini
summary: Get a Google Gemini Interaction
description: 'Retrieves the Interaction created by the same SandBase API key. Non-terminal responses omit partial output and
usage. When upstream media has expired, a terminal fallback can preserve structure and metadata without the
original media bytes; download terminal media promptly rather than treating this endpoint as durable storage.'
security:
- GoogleApiKey: []
- BearerAuth: []
- GoogleQueryApiKey: []
parameters:
- name: id
in: path
required: true
schema:
type: string
minLength: 1
description: Upstream Interaction ID returned by POST. It is not a SandBase prediction ID.
responses:
'200':
description: Current or terminal Interaction
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiInteraction'
'400':
description: Empty Interaction ID
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'401':
description: Missing, invalid, revoked, or expired API key
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'402':
description: Organization balance and credit are exhausted
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'403':
description: API Key spending limit reached or organization disabled
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'404':
description: Interaction is unknown, expired, or not owned by the current API key
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'500':
description: Organization admission lookup failed
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'502':
description: Upstream Interaction response exceeded the gateway size limit
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
'503':
description: Affinity storage, provider lookup, credentials, or upstream retrieval is temporarily unavailable
content:
application/json:
schema:
$ref: '#/components/schemas/GeminiError'
components:
schemas:
GeminiInteractionModalityUsage:
type: object
required:
- modality
- tokens
additionalProperties: true
properties:
modality:
type: string
tokens:
type: integer
minimum: 0
GeminiInteractionRequest:
type: object
required:
- model
- input
additionalProperties: true
description: 'Google Interactions request. Except for fields used for routing and lifecycle control, fields are forwarded to
the selected upstream. Agent interactions are not supported. background and stream cannot both be true.
'
properties:
model:
type: string
minLength: 1
description: Logical SandBase model name. The response echoes this name instead of an upstream model identifier.
input:
description: Google Interactions input; it can be text, an object, or an array of typed input items.
stream:
type: boolean
default: false
description: Requests an SSE event stream when the selected model supports it.
background:
type: boolean
default: false
description: Requests durable background execution and an immediately pollable in_progress Interaction.
previous_interaction_id:
type: string
description: Previous Interaction ID. SandBase keeps the request on the same upstream provider when the mapping is still available.
store:
type: boolean
description: Forwarded upstream. Stored upstream state may be required for previous_interaction_id.
system_instruction:
type: string
tools:
type: array
items:
type: object
additionalProperties: true
generation_config:
type: object
additionalProperties: true
response_format:
oneOf:
- type: object
additionalProperties: true
- type: array
items: {}
response_modalities:
type: array
items:
type: string
GeminiGenerateContentRequest:
type: object
additionalProperties: true
description: Google Gemini GenerateContent request. Native passthrough mappings preserve provider-defined fields; translated mappings use the documented capability subset.
properties:
contents:
type: array
items:
$ref: '#/components/schemas/GeminiContent'
systemInstruction:
$ref: '#/components/schemas/GeminiContent'
generationConfig:
type: object
additionalProperties: true
properties:
temperature:
type: number
topP:
type: number
topK:
type: integer
maxOutputTokens:
type: integer
stopSequences:
type: array
items:
type: string
candidateCount:
type: integer
description: Translated mappings accept only 1 when supplied; native passthrough mappings preserve the provider request.
seed:
type: integer
presencePenalty:
type: number
frequencyPenalty:
type: number
responseMimeType:
type: string
enum:
- text/plain
- application/json
- text/x.enum
responseSchema:
type: object
additionalProperties: true
responseModalities:
type: array
items:
type: string
description: Native image mappings support provider image modalities. Other translated mappings may support TEXT only.
thinkingConfig:
type: object
additionalProperties: true
tools:
type: array
items:
type: object
additionalProperties: true
toolConfig:
type: object
additionalProperties: true
safetySettings:
type: array
items:
type: object
additionalProperties: true
cachedContent:
type: string
description: Passed through when the selected provider supports Gemini context caching.
GeminiError:
type: object
required:
- error
properties:
error:
type: object
required:
- code
- message
- status
additionalProperties: true
properties:
code:
type: integer
message:
type: string
status:
type: string
description: Google canonical error status, such as INVALID_ARGUMENT, UNAUTHENTICATED, PERMISSION_DENIED, NOT_FOUND, RESOURCE_EXHAUSTED, INTERNAL, UNAVAILABLE, or DEADLINE_EXCEEDED.
GeminiGenerateContentResponse:
type: object
additionalProperties: true
properties:
candidates:
type: array
items:
type: object
additionalProperties: true
properties:
content:
$ref: '#/components/schemas/GeminiContent'
finishReason:
type: string
index:
type: integer
safetyRatings:
type: array
items:
type: object
additionalProperties: true
usageMetadata:
type: object
additionalProperties: true
properties:
promptTokenCount:
type: integer
minimum: 0
candidatesTokenCount:
type: integer
minimum: 0
totalTokenCount:
type: integer
minimum: 0
cachedContentTokenCount:
type: integer
minimum: 0
thoughtsTokenCount:
type: integer
minimum: 0
promptFeedback:
type: object
additionalProperties: true
modelVersion:
type: string
responseId:
type: string
GeminiInteraction:
type: object
required:
- id
- object
- model
- status
additionalProperties: true
properties:
id:
type: string
description: Upstream Interaction ID used by GET and previous_interaction_id.
object:
type: string
const: interaction
model:
type: string
description: Logical SandBase model name supplied by the client.
role:
type: string
status:
type: string
enum:
- in_progress
- requires_action
- completed
- failed
- cancelled
- incomplete
created:
type: string
updated:
type: string
steps:
type: array
description: Polymorphic Google Interaction steps. Unknown step and content types are preserved.
items:
type: object
additionalProperties: true
usage:
$ref: '#/components/schemas/GeminiInteractionUsage'
GeminiInteractionUsage:
type: object
additionalProperties: true
properties:
total_input_tokens:
type: integer
minimum: 0
total_output_tokens:
type: integer
minimum: 0
total_cached_tokens:
type: integer
minimum: 0
total_thought_tokens:
type: integer
minimum: 0
total_tool_use_tokens:
type: integer
minimum: 0
total_tokens:
type: integer
minimum: 0
input_tokens_by_modality:
type: array
items:
$ref: '#/components/schemas/GeminiInteractionModalityUsage'
output_tokens_by_modality:
type: array
items:
$ref: '#/components/schemas/GeminiInteractionModalityUsage'
GeminiContent:
type: object
additionalProperties: true
properties:
role:
type: string
enum:
- user
- model
parts:
type: array
items:
type: object
additionalProperties: true
description: Text, image inlineData, public HTTP(S) image fileData, functionCall, or functionResponse part.
parameters:
GeminiModel:
name: model
in: path
required: true
schema:
type: string
minLength: 1
description: Bare Gemini model name, such as gemini-3.5-flash. SandBase adds the google/ catalog prefix.
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: SandBase API key. Treat the complete credential as an opaque secret.
AnthropicApiKey:
type: apiKey
in: header
name: x-api-key
description: Supported only by `POST /v1/messages` for Anthropic SDK compatibility
GoogleApiKey:
type: apiKey
in: header
name: x-goog-api-key
description: Supported by Google Gemini-compatible endpoints. Takes precedence over the other key locations.
GoogleQueryApiKey:
type: apiKey
in: query
name: key
description: Google SDK compatibility fallback. Prefer x-goog-api-key or Authorization because URLs can be logged.
WebhookApiKey:
type: apiKey
in: header
name: X-API-Key
description: Accepted by the webhook Events API (/events/webhooks*). Authorization Bearer takes precedence when both are sent.
AgentsApiKey:
type: apiKey
in: header
name: X-API-Key
description: Accepted only by Agents platform resources (/v1/agents*, /v1/mcp-connections*, /v1/secrets*, /v1/skills*). If Authorization is also sent, both must carry the same key.