# Gemini compatible API

## POST /v1beta/models/{model}:generateContent

`POST /v1beta/models/{model}:generateContent` · operation `createGeminiContent`

Gemini GenerateContent. Requires gemini_generate_content, route:generate_content and an alias with generate_content capability. On Gemini targets the gateway replaces only the URL model segment and authenticates upstream with x-goog-api-key; body and response remain native and usageMetadata is captured. A file part's slice (documentMetadata, spreadsheetMetadata, videoMetadata, mediaResolution) passes through; with gemini_file_defaults (T199) the alias's models[].file_defaults fills the file parts that name none (a file part without mimeType is then refused with 422 file_type_required) and the answer carries the header X-Gateway-File-Defaults with the value applied (a body that repeats a member is then refused with 400). On another provider the request is translated through the canonical Chat Completions format (ADR 0172), with X-Gateway-Translation headers and 422 unsupported_translation for fields with no equivalent. The gateway key may also come in x-goog-api-key, never in the URL (?key= answers 400); alt=sse answers 400 here.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Gateway-Timeout-Ms` | header | string, max length 8, pattern `^[0-9]+$` | One decimal integer from 1 to 86400000 milliseconds. With request_timeout_header enabled it can only lower the total deadline, or every independent stream clock (including an otherwise disabled idle clock). Ignored when the header flag is disabled. Never forwarded upstream. |
| `X-Gateway-Tags` | header | string, max length 2048 | Optional explicit JSON string map for model inference only. With usage_tag_defaults, finite defaults come from the authenticated team and explicit values override matching names; an absent header or an empty JSON object preserves defaults. One header, at most 2 KiB and eight pairs; finite configured enum. Requires usage_tags and authentication/model/team/RPM admission. Never forwarded or added to logs/traces/metric labels/cache identity. Not supported for MCP or models inventory. Tags do not authorize access or establish financial attribution. |
| `X-Gateway-End-User` | header | string, min length 1, max length 128 | Optional client-declared end user (1–128 printable characters) recorded under end_user_tracking. Takes precedence over the OpenAI user body field. Untrusted metadata: never authorization, routing, cache identity or a log/metric label. Required when the key's or its team's require block sets end_user (attribution_requirements): a request without it answers 400 missing_attribution before any provider call. |
| `X-Gateway-Session-Id` | header | string, min length 1, max length 128 | Optional client-declared session or agent-run ID (1–128 printable characters) recorded under session_tracking to group requests in logs. Untrusted metadata: never authorization, routing or cache identity. |
| `X-Gateway-Agent-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional client-declared agent that made this request (1–128 printable characters), kept with the session's agent graph. Asserted, never authentication; ignored with the flag off; an invalid or repeated value answers 400 invalid_agent_context. |
| `X-Gateway-Turn-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional client-declared turn this request belongs to (1–128 printable characters). Asserted; same rules as X-Gateway-Agent-Id. |
| `X-Gateway-Parent-Session-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional session that spawned this one (a sub-agent run), 1–128 printable characters. Asserted; ignored when equal to X-Gateway-Session-Id; same rules as X-Gateway-Agent-Id. |
| `X-Gateway-Feedback-Key` | header | string, min length 1, max length 200, pattern `^[\x21-\x7E]{1,200}$` | evaluation_results (T186.003). Optional external ID (a ticket or incident number) that feedback results join on with join_key: 1–200 printable ASCII characters without spaces, one value. Stored on the request log row and the request span; never a usage tag, a metric label or an analytics dimension. Ignored with the flag off; an invalid or repeated value answers 400 invalid_feedback_key. |
| `X-Gateway-Prompt-Render` | header | string, max length 512, pattern `^gpr_` | prompt_tracking (T186.013). The render token the published-prompt render answered: the request records that prompt and revision as rendered. Attribution only, never a refusal: a token of another team, a forged one, one past prompt_tracking.render_token_ttl, or a team whose plan lacks prompt_tracking records nothing and the answer carries X-Gateway-Prompt-Tracking (other_team, invalid_signature, malformed, expired, not_entitled, entitlement_unavailable). With X-Gateway-Prompt-Id and X-Gateway-Prompt-Revision they must name the token's prompt and revision (400 invalid_prompt_declaration); two tokens answer 400 invalid_prompt_render. Ignored with the flag off. |
| `X-Gateway-Prompt-Id` | header | string, pattern `^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$` | prompt_tracking (T186.013). The registry prompt the client built the request from, recorded as declared: a claim, never authorization, and only on the rows of the key's own team. Read while prompt_tracking.declared_headers is true (default); one value; an invalid one answers 400 invalid_prompt_declaration. |
| `X-Gateway-Prompt-Revision` | header | string, pattern `^[1-9][0-9]?$\|^100$` | prompt_tracking (T186.013). The revision (1-100) of X-Gateway-Prompt-Id; optional, recorded as declared. |
| `model` | path | string, required | Public gateway model alias |
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |

**Request body** (required)

- `application/json`: object
  - `contents` (array of object, required, min items 1)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Native Gemini JSON response | — |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `429` | Gateway RPM, key or team concurrency cap (concurrency_limit_exceeded, T135) or applicable token/USD quota ceiling reached; the request was not forwarded upstream. | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `502` | Provider unavailable | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Local concurrency limit reached | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `default` | Provider status, content type and body passed through after model alias replacement. | `application/json`: object<br/>`application/octet-stream`: string (binary) |


## POST /v1beta/models/{model}:streamGenerateContent

`POST /v1beta/models/{model}:streamGenerateContent` · operation `streamGeminiContent`

Gemini streamGenerateContent over SSE. Requires gemini_generate_content and route:generate_content. Native on Gemini targets, translated through the canonical format on others (ADR 0172); a stream that fails after the first byte ends with an error object, never a finishReason. Requires ?alt=sse (400 otherwise; other query parameters are ignored, ?key= is refused). The gateway never retries after first response byte.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Gateway-Timeout-Ms` | header | string, max length 8, pattern `^[0-9]+$` | One decimal integer from 1 to 86400000 milliseconds. With request_timeout_header enabled it can only lower the total deadline, or every independent stream clock (including an otherwise disabled idle clock). Ignored when the header flag is disabled. Never forwarded upstream. |
| `X-Gateway-Tags` | header | string, max length 2048 | Optional explicit JSON string map for model inference only. With usage_tag_defaults, finite defaults come from the authenticated team and explicit values override matching names; an absent header or an empty JSON object preserves defaults. One header, at most 2 KiB and eight pairs; finite configured enum. Requires usage_tags and authentication/model/team/RPM admission. Never forwarded or added to logs/traces/metric labels/cache identity. Not supported for MCP or models inventory. Tags do not authorize access or establish financial attribution. |
| `X-Gateway-End-User` | header | string, min length 1, max length 128 | Optional client-declared end user (1–128 printable characters) recorded under end_user_tracking. Takes precedence over the OpenAI user body field. Untrusted metadata: never authorization, routing, cache identity or a log/metric label. Required when the key's or its team's require block sets end_user (attribution_requirements): a request without it answers 400 missing_attribution before any provider call. |
| `X-Gateway-Session-Id` | header | string, min length 1, max length 128 | Optional client-declared session or agent-run ID (1–128 printable characters) recorded under session_tracking to group requests in logs. Untrusted metadata: never authorization, routing or cache identity. |
| `X-Gateway-Agent-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional client-declared agent that made this request (1–128 printable characters), kept with the session's agent graph. Asserted, never authentication; ignored with the flag off; an invalid or repeated value answers 400 invalid_agent_context. |
| `X-Gateway-Turn-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional client-declared turn this request belongs to (1–128 printable characters). Asserted; same rules as X-Gateway-Agent-Id. |
| `X-Gateway-Parent-Session-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional session that spawned this one (a sub-agent run), 1–128 printable characters. Asserted; ignored when equal to X-Gateway-Session-Id; same rules as X-Gateway-Agent-Id. |
| `X-Gateway-Feedback-Key` | header | string, min length 1, max length 200, pattern `^[\x21-\x7E]{1,200}$` | evaluation_results (T186.003). Optional external ID (a ticket or incident number) that feedback results join on with join_key: 1–200 printable ASCII characters without spaces, one value. Stored on the request log row and the request span; never a usage tag, a metric label or an analytics dimension. Ignored with the flag off; an invalid or repeated value answers 400 invalid_feedback_key. |
| `X-Gateway-Prompt-Render` | header | string, max length 512, pattern `^gpr_` | prompt_tracking (T186.013). The render token the published-prompt render answered: the request records that prompt and revision as rendered. Attribution only, never a refusal: a token of another team, a forged one, one past prompt_tracking.render_token_ttl, or a team whose plan lacks prompt_tracking records nothing and the answer carries X-Gateway-Prompt-Tracking (other_team, invalid_signature, malformed, expired, not_entitled, entitlement_unavailable). With X-Gateway-Prompt-Id and X-Gateway-Prompt-Revision they must name the token's prompt and revision (400 invalid_prompt_declaration); two tokens answer 400 invalid_prompt_render. Ignored with the flag off. |
| `X-Gateway-Prompt-Id` | header | string, pattern `^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$` | prompt_tracking (T186.013). The registry prompt the client built the request from, recorded as declared: a claim, never authorization, and only on the rows of the key's own team. Read while prompt_tracking.declared_headers is true (default); one value; an invalid one answers 400 invalid_prompt_declaration. |
| `X-Gateway-Prompt-Revision` | header | string, pattern `^[1-9][0-9]?$\|^100$` | prompt_tracking (T186.013). The revision (1-100) of X-Gateway-Prompt-Id; optional, recorded as declared. |
| `model` | path | string, required | Public gateway model alias |
| `alt` | query | `"sse"`, required |  |
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |

**Request body** (required)

- `application/json`: object
  - `contents` (array of object, required, min items 1)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Native Gemini SSE events | `text/event-stream`: string |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `429` | Gateway RPM, key or team concurrency cap (concurrency_limit_exceeded, T135) or applicable token/USD quota ceiling reached; the request was not forwarded upstream. | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `502` | Provider unavailable | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Local concurrency limit reached | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `default` | Provider status, content type and body passed through after model alias replacement. | `application/json`: object<br/>`application/octet-stream`: string (binary) |


## POST /v1beta/interactions

`POST /v1beta/interactions` · operation `createGeminiInteraction`

Gemini Interactions API (T199), as Google documents it (client.interactions.create). Requires the gemini_interactions flag, key scope route:interactions and an alias with the interactions capability alone, targeting the Gemini API (Vertex AI and every other protocol are refused by configuration). The gateway key goes in Authorization: Bearer or x-goog-api-key, never in ?key=. The body passes through with only model replaced by the target model, so every documented field works as the provider documents it, the file slice (processing.page_options, processing.spreadsheet_options, resolution) included; with gemini_file_defaults the alias's models[].file_defaults fills the document, image and video blocks that name none. Refused before any call: agent, agent_config, environment and environment_id unless gemini_interactions_agents is on (422 agents_disabled; with it, agent names a gateway alias whose target is the provider's agent, and model is omitted), webhook_config (422 webhook_unsupported), background true with store false or stream true (422 background_unsupported), a stored interaction on an alias with several targets (422 stateless_fallback_needed; send store false), a body that repeats a member (400) and, when organizations share the provider project, a Files API uri, a file search tool, a continuation_token or an environment_id (422 provider_state_not_isolated). Guardrails check the system instruction, the input texts and tool results, and the text of the answer; with an output guardrail a streamed answer is checked whole and delivered as stream events, and an enforcing one sends store false and refuses store true, previous_interaction_id and background (400 guardrail_output_unsupported). background true answers the interaction in_progress with its gateway ID, read later with GET. A stored interaction (store omitted or true) answers with a gateway ID signed to the key that created it; previous_interaction_id accepts that ID from the same key (404 interaction_not_found otherwise) and the call goes to the provider holding it; the provider's own ID is accepted only with one tenant. A request with store false and no previous_interaction_id falls back to the next target like any stateless call; any other is one send. A member spelled in lowerCamel answers 400 member_spelling; with organizations a file search tool, a store name or a continuation_token answers 422 provider_state_not_isolated; an alias with file_defaults refuses a block without mime_type (422 file_type_required); a provider answer that cannot be read to sign its ID answers 502 invalid_provider_response. The answer is valued from usage (total_input_tokens, total_output_tokens plus total_thought_tokens as output, total_cached_tokens as cache reads, input_tokens_by_modality and output_tokens_by_modality by modality); hosted tools, tool-use tokens, grounding and agents leave the cost unknown. A budget or token ceiling (quota_native_protocols) admits text input, function tools, an inline PDF with a closed page_image range and a required generation_config.max_output_tokens, and settles on the usage of the answer or of the final stream event; a background interaction needs quota_background_responses and settles when it ends; continuations, agents and hosted tools answer 422 quota_profile_unsupported.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Gateway-Tags` | header | string, max length 2048 | Optional explicit JSON string map for model inference only. With usage_tag_defaults, finite defaults come from the authenticated team and explicit values override matching names; an absent header or an empty JSON object preserves defaults. One header, at most 2 KiB and eight pairs; finite configured enum. Requires usage_tags and authentication/model/team/RPM admission. Never forwarded or added to logs/traces/metric labels/cache identity. Not supported for MCP or models inventory. Tags do not authorize access or establish financial attribution. |
| `X-Gateway-End-User` | header | string, min length 1, max length 128 | Optional client-declared end user (1–128 printable characters) recorded under end_user_tracking. Takes precedence over the OpenAI user body field. Untrusted metadata: never authorization, routing, cache identity or a log/metric label. Required when the key's or its team's require block sets end_user (attribution_requirements): a request without it answers 400 missing_attribution before any provider call. |
| `X-Gateway-Session-Id` | header | string, min length 1, max length 128 | Optional client-declared session or agent-run ID (1–128 printable characters) recorded under session_tracking to group requests in logs. Untrusted metadata: never authorization, routing or cache identity. |
| `X-Gateway-Agent-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional client-declared agent that made this request (1–128 printable characters), kept with the session's agent graph. Asserted, never authentication; ignored with the flag off; an invalid or repeated value answers 400 invalid_agent_context. |
| `X-Gateway-Turn-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional client-declared turn this request belongs to (1–128 printable characters). Asserted; same rules as X-Gateway-Agent-Id. |
| `X-Gateway-Parent-Session-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional session that spawned this one (a sub-agent run), 1–128 printable characters. Asserted; ignored when equal to X-Gateway-Session-Id; same rules as X-Gateway-Agent-Id. |
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |

**Request body** (required)

- `application/json`: [GeminiInteractionRequest](/docs/api/schemas/g/#geminiinteractionrequest)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The provider's Interaction (JSON), or its event stream with stream true (interaction.created, step.start, step.delta, step.stop, interaction.completed with the usage, then done), relayed as received except for the interaction IDs, which are the gateway's signed IDs (int_gw1.…). X-Gateway-File-Defaults: applied when the alias's defaults changed a block. | `application/json`: [GeminiInteraction](/docs/api/schemas/g/#geminiinteraction)<br/>`text/event-stream`: string |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `413` | Request exceeds the configured body limit | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `415` | Only application/json is accepted | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `422` | Model does not support this operation | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `429` | Gateway RPM, key or team concurrency cap (concurrency_limit_exceeded, T135) or applicable token/USD quota ceiling reached; the request was not forwarded upstream. | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `502` | Provider unavailable | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Local concurrency limit reached | `application/json`: [Error](/docs/api/schemas/e/#error) |


## POST /v1/interactions

`POST /v1/interactions` · operation `createGeminiInteractionV1`

The stable-version path of POST /v1beta/interactions (T199): same contract, same upstream route.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Gateway-Tags` | header | string, max length 2048 | Optional explicit JSON string map for model inference only. With usage_tag_defaults, finite defaults come from the authenticated team and explicit values override matching names; an absent header or an empty JSON object preserves defaults. One header, at most 2 KiB and eight pairs; finite configured enum. Requires usage_tags and authentication/model/team/RPM admission. Never forwarded or added to logs/traces/metric labels/cache identity. Not supported for MCP or models inventory. Tags do not authorize access or establish financial attribution. |
| `X-Gateway-End-User` | header | string, min length 1, max length 128 | Optional client-declared end user (1–128 printable characters) recorded under end_user_tracking. Takes precedence over the OpenAI user body field. Untrusted metadata: never authorization, routing, cache identity or a log/metric label. Required when the key's or its team's require block sets end_user (attribution_requirements): a request without it answers 400 missing_attribution before any provider call. |
| `X-Gateway-Session-Id` | header | string, min length 1, max length 128 | Optional client-declared session or agent-run ID (1–128 printable characters) recorded under session_tracking to group requests in logs. Untrusted metadata: never authorization, routing or cache identity. |
| `X-Gateway-Agent-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional client-declared agent that made this request (1–128 printable characters), kept with the session's agent graph. Asserted, never authentication; ignored with the flag off; an invalid or repeated value answers 400 invalid_agent_context. |
| `X-Gateway-Turn-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional client-declared turn this request belongs to (1–128 printable characters). Asserted; same rules as X-Gateway-Agent-Id. |
| `X-Gateway-Parent-Session-Id` | header | string, min length 1, max length 128 | agent_sessions (T033.002). Optional session that spawned this one (a sub-agent run), 1–128 printable characters. Asserted; ignored when equal to X-Gateway-Session-Id; same rules as X-Gateway-Agent-Id. |
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |

**Request body** (required)

- `application/json`: [GeminiInteractionRequest](/docs/api/schemas/g/#geminiinteractionrequest)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The provider's Interaction (JSON), or its event stream with stream true (interaction.created, step.start, step.delta, step.stop, interaction.completed with the usage, then done), relayed as received except for the interaction IDs, which are the gateway's signed IDs (int_gw1.…). X-Gateway-File-Defaults: applied when the alias's defaults changed a block. | `application/json`: [GeminiInteraction](/docs/api/schemas/g/#geminiinteraction)<br/>`text/event-stream`: string |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `413` | Request exceeds the configured body limit | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `415` | Only application/json is accepted | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `422` | Model does not support this operation | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `429` | Gateway RPM, key or team concurrency cap (concurrency_limit_exceeded, T135) or applicable token/USD quota ceiling reached; the request was not forwarded upstream. | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `502` | Provider unavailable | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Local concurrency limit reached | `application/json`: [Error](/docs/api/schemas/e/#error) |


## Retrieve a stored interaction

`GET /v1beta/interactions/{id}` · operation `getGeminiInteraction`

Requires gemini_interactions and route:interactions (T199). The ID is signed and bound to the key that created it; another key, a tampered ID or the provider's own ID answers 404 interaction_not_found without calling the provider. Query parameters (stream, last_event_id, include_input) pass through, except key.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required | Gateway interaction ID returned by POST /v1beta/interactions (int_gw1.…) |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The provider's Interaction (JSON, or SSE with stream=true) with the gateway ID. No tokens are billed. | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Unknown interaction ID for this key, or gemini_interactions disabled | — |


## Delete a stored interaction

`DELETE /v1beta/interactions/{id}` · operation `deleteGeminiInteraction`

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required | Gateway interaction ID returned by POST /v1beta/interactions (int_gw1.…) |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Empty object, as the provider answers | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Unknown interaction ID for this key, or gemini_interactions disabled | — |
| `409` | background_interaction_pending: the background interaction's budget reservation is still open; cancel it or wait until it ends | — |


## Cancel an interaction

`POST /v1beta/interactions/{id}/cancel` · operation `cancelGeminiInteraction`

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The provider's Interaction with the gateway ID | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Unknown interaction ID for this key, or gemini_interactions disabled | — |


## Retrieve a stored interaction

`GET /v1/interactions/{id}` · operation `getGeminiInteractionV1`

Requires gemini_interactions and route:interactions (T199). The ID is signed and bound to the key that created it; another key, a tampered ID or the provider's own ID answers 404 interaction_not_found without calling the provider. Query parameters (stream, last_event_id, include_input) pass through, except key.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required | Gateway interaction ID returned by POST /v1beta/interactions (int_gw1.…) |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The provider's Interaction (JSON, or SSE with stream=true) with the gateway ID. No tokens are billed. | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Unknown interaction ID for this key, or gemini_interactions disabled | — |


## Delete a stored interaction

`DELETE /v1/interactions/{id}` · operation `deleteGeminiInteractionV1`

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required | Gateway interaction ID returned by POST /v1beta/interactions (int_gw1.…) |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Empty object, as the provider answers | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Unknown interaction ID for this key, or gemini_interactions disabled | — |
| `409` | background_interaction_pending: the background interaction's budget reservation is still open; cancel it or wait until it ends | — |


## Cancel an interaction

`POST /v1/interactions/{id}/cancel` · operation `cancelGeminiInteractionV1`

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The provider's Interaction with the gateway ID | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Unknown interaction ID for this key, or gemini_interactions disabled | — |

