Skip to main content

Google Gemini Interactions API

This page explains how to call Google Gemini Interactions API through this platform.

Interactions is Gemini's native unified interface (text, multimodal, tools, agents). Request and success response bodies match the official Interactions API. The gateway forwards original JSON / SSE and does not convert to Chat Completions or generateContent.

Use an API token issued by this platform. Do not use a Google Gemini API key or a Vertex service account.

BASE_URL=https://open-api.fancyai.com
API_KEY=sk-your-system-token

Development:

BASE_URL=https://platform-dev-api.xxd.fans

Official SDKs only need a new base_url and key. Full field lists, step types, and tool declarations follow the official docs. This page covers paths, auth, and differences from calling Google directly.

Per-model try-it pages live under each Gabrielle Gemini model in the sidebar (OpenAI-compatible chat, native generateContent, and Interactions).

1. Endpoint overview

FeatureMethodPathSupported
Create interactionPOST/v1beta/interactionsYes
Create interaction (stable path)POST/v1/interactionsYes
Get interactionGET/v1beta/interactions/{id}No
Cancel background taskPOST/v1beta/interactions/{id}/cancelNo
Delete interactionDELETE/v1beta/interactions/{id}No

/v1/interactions and /v1beta/interactions behave the same; the gateway keeps the version the client chose. Prefer /v1beta/interactions to match the official SDK default.

Auth (any one):

Authorization: Bearer sk-your-system-token
x-goog-api-key: sk-your-system-token
GET /v1beta/interactions?key=sk-your-system-token

Official REST / google-genai often uses x-goog-api-key. Do not put a Google official key here.

Optional headers (forwarded upstream as-is):

Api-Revision: 2026-05-20
x-goog-api-client: google-genai-sdk/...

Api-Revision selects the official schema version. Google currently recommends 2026-05-20. See Interactions breaking changes.

2. Create an interaction

POST /v1beta/interactions
Content-Type: application/json

Gateway checks: body must be JSON; model or agent is required; input is required. Other fields are forwarded unchanged.

Channel selection uses model. If model is absent, it uses agent. If the backend has a model mapping, only the model field in the body is rewritten before the upstream call.

2.1 Common fields

FieldTypeRequiredNotes
modelstringEither model or agentModel name, for example gemini-3.8-flash. Must be enabled on this system
agentstringEither model or agentHosted agent, for example deep-research-preview-04-2026. Used for routing when model is absent
inputstring / object / arrayYesUser input. A string is simplest; it can also be a content / steps array
streambooleanNotrue returns SSE. You can also use ?alt=sse
system_instructionstringNoSystem instruction
generation_configobjectNoModel mode only. Examples: max_output_tokens, thinking_level, seed
toolsarrayNoTool declarations
response_formatobject / arrayNoJSON Schema constraint
previous_interaction_idstringNoMulti-turn: previous interaction id
storebooleanNoWhether Google stores the interaction for official GET. This system has no GET route
backgroundbooleanNoBackground execution. This system has no query / cancel routes. Do not use

thinking_level values: minimal, low, medium, high.

input examples:

"input": "Introduce the Interactions API in one sentence"
"input": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image",
"data": "<base64>",
"mime_type": "image/jpeg"
}
]

2.2 Streaming

Use either:

  • Body: "stream": true
  • URL: POST /v1beta/interactions?alt=sse

Response Content-Type is text/event-stream. The gateway forwards frames as-is, including event: lines. It does not rewrite them to Chat Completions data: {...}.

Common events:

event_typeMeaning
interaction.createdCreated, usually includes id
interaction.status_updateStatus change
step.start / step.delta / step.stopStep start, delta, end
interaction.completedFinished; usage is usually here
errorUpstream error event

Clients should read until interaction.completed or the connection closes.

3. Request examples

3.1 Sync text

curl -X POST "${BASE_URL}/v1beta/interactions" \
-H "x-goog-api-key: ${API_KEY}" \
-H "Content-Type: application/json" \
-H "Api-Revision: 2026-05-20" \
-d '{
"model": "gemini-3.8-flash",
"input": "Introduce the Gemini Interactions API in one sentence"
}'

3.2 Streaming text

curl -N -X POST "${BASE_URL}/v1beta/interactions" \
-H "x-goog-api-key: ${API_KEY}" \
-H "Content-Type: application/json" \
-H "Api-Revision: 2026-05-20" \
-d '{
"model": "gemini-3.8-flash",
"input": "Write a four-line poem",
"stream": true
}'

SSE fragment:

event: step.delta
data: {"event_type":"step.delta","index":0,"delta":{"type":"text","text":"Hello"}}

event: interaction.completed
data: {"event_type":"interaction.completed","event_id":"evt_123","interaction":{"id":"v1_...","status":"completed","usage":{...}}}

3.3 Python SDK

Point the official SDK at this platform. The path remains /v1beta/interactions.

from google import genai

client = genai.Client(
api_key="sk-your-system-token",
http_options={"base_url": "https://open-api.fancyai.com"},
)

interaction = client.interactions.create(
model="gemini-3.8-flash",
input="Introduce the Gemini Interactions API in one sentence",
)
print(interaction.id, interaction.status)
print(interaction.outputs)

Streaming:

stream = client.interactions.create(
model="gemini-3.8-flash",
input="Write a four-line poem",
stream=True,
)

for event in stream:
if getattr(event, "event_type", None) == "step.delta":
delta = getattr(event, "delta", None)
if delta is not None and getattr(delta, "type", None) == "text":
print(delta.text, end="", flush=True)

JavaScript:

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({
apiKey: "sk-your-system-token",
httpOptions: { baseUrl: "https://open-api.fancyai.com" },
});

const interaction = await client.interactions.create({
model: "gemini-3.8-flash",
input: "Introduce the Gemini Interactions API in one sentence",
});
console.log(interaction.id, interaction.status);

3.4 Image models

The protocol supports image models such as gemini-3.1-flash-image and gemini-3-pro-image. Prefer flash image models for streaming images. gemini-3-pro-image streams often emit thinking without a finished image.

curl -N -X POST "${BASE_URL}/v1beta/interactions" \
-H "x-goog-api-key: ${API_KEY}" \
-H "Content-Type: application/json" \
-H "Api-Revision: 2026-05-20" \
-d '{
"model": "gemini-3.1-flash-image",
"input": "An orange cat sitting on a windowsill in afternoon sunlight, photorealistic",
"stream": true
}'

Enabled model names are those listed in the console. Do not assume every name in Google's docs is configured here.

4. Success response

On non-stream success, the body is the official Interaction object. The gateway does not rewrite it. Typical fields:

FieldNotes
idInteraction ID
objectUsually "interaction"
statuscompleted, in_progress, requires_action, failed
model / agentUpstream model or agent
stepsOutput steps. POST success usually has output steps only; the full timeline (including user_input) needs official GET, which this system does not provide
usageToken usage, snake_case
created / updatedTimestamps

Example:

{
"id": "v1_ChdPU0F4YWFtNkFwS2kxZThQZ05lbXdROBIXT1NBeGFhbTZBcEtpMWU4UGdOZW13UTg",
"object": "interaction",
"status": "completed",
"model": "gemini-3.8-flash",
"created": "2025-11-26T12:22:47Z",
"updated": "2025-11-26T12:22:47Z",
"steps": [
{
"type": "model_output",
"content": [
{
"type": "text",
"text": "The Interactions API is Gemini's unified native interface."
}
]
}
],
"usage": {
"total_input_tokens": 12,
"total_output_tokens": 40,
"total_thought_tokens": 80,
"total_cached_tokens": 0,
"total_tool_use_tokens": 0,
"total_tokens": 132,
"input_tokens_by_modality": [
{ "modality": "text", "tokens": 12 }
]
}
}

When status is requires_action, send tool results with another POST /interactions (or continue with previous_interaction_id). This system only relays; it does not run tools.

5. Errors

Gateway or channel errors are not always official Interactions error objects. They may use the same OpenAI-style wrapper as other Gemini native relays:

{
"error": {
"message": "...",
"type": "...",
"code": "..."
}
}

HTTP status still follows upstream when possible (4xx / 5xx). Do not parse gateway failures only as official error.code.

During streaming, upstream may also push an SSE frame with event_type error. That frame reaches the client unchanged.

6. Billing

The system bills from upstream usage:

  • Non-stream: usage in the response body
  • Stream: interaction.completed (or usage on the event)

Mapping:

Billing itemUpstream field
Prompttotal_input_tokens + total_tool_use_tokens
Completiontotal_output_tokens + total_thought_tokens
Reasoningtotal_thought_tokens
Image / audiotokens where modality is image / audio in *_tokens_by_modality

Prices follow the model's ratio / billing expression in the console.

7. Differences from calling Google directly

ItemThis systemDirect Google
Create POST /interactionsYes; success JSON / SSE is passed throughYes
GET /interactions/{id}NoStatus, full steps, resume after disconnect
POST /interactions/{id}/cancelNoCancel a running background task
DELETE /interactions/{id}NoDelete the server-side record
background: trueDo not use. You cannot query or cancel after createLong-running agents / deep research
Multi-turn previous_interaction_idForwarded, but must hit the same upstream key. Multi-key load balancing can 404Same project key is enough
Error bodyGateway failures may be OpenAI-styleOfficial error object
Model nameMust be enabled and configured on a channel; mapping may rewrite itOfficial model list

store and background are Google server-side features. Even with store: true, this system has no query endpoint.

background is for tasks that run on Google's side: create returns id immediately, then poll GET. Deep research and multi-step agents often exceed ~60s HTTP timeouts. Use sync or SSE ("stream": true) instead, and give the client a long enough timeout.

8. Recommendations

  • Chat, streaming text, and streaming images: POST plus optional "stream": true.
  • Client timeouts should exceed upstream runtime; thinking and image models can take much longer than plain text.
  • Do not retry the same request after tens of seconds with no response; that can double-bill.
  • For multi-turn, send needed steps back in the next input. Do not rely on GET history from this system.
  • Full schema: Interactions API.