Skip to main content

Interactions API

The Interactions API is Google's format for stateful, agent oriented conversations. An interaction is created with a model or a server side agent, can run in the background, and can be fetched or cancelled later by id. The gateway serves this format at /v1beta/interactions (and /interactions) for Gemini models and agents, and translates it for other providers, so clients built for Interactions can use the whole gateway catalogue with virtual keys, budgets and logging.

Scenario​

A research team runs a deep research agent that can take several minutes per task. Their tool creates an interaction in the background with the agent's name, polls the interaction id until it is complete, and cancels it when the user gives up. The gateway bills each run to the team's key and keeps the whole history of the interaction in the logs.

Steps​

  1. Register a Gemini model. In the Admin UI open Models + Endpoints (/ui/models-and-endpoints), click Add Model, pick Gemini as the Provider, choose the model, set the Public Model Name to gemini-3.8-flash and click Add Model.

  2. Create an interaction.

    curl -X POST http://localhost:4000/v1beta/interactions \
    -H "Authorization: Bearer $SPANWAY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "model": "gemini-3.8-flash",
    "input": "Summarize the latest release notes in three bullet points."
    }'

    Provide model for a model interaction, or agent for an agent interaction such as a deep research agent. input is a string or a list of content parts, and stream: true streams events. Other fields such as tools, system_instruction and generation_config follow the Google specification.

  3. Read or cancel it. Take id from the answer.

    curl http://localhost:4000/v1beta/interactions/int_7c2d4e1f -H "Authorization: Bearer $SPANWAY_API_KEY"
    curl -X POST http://localhost:4000/v1beta/interactions/int_7c2d4e1f/cancel -H "Authorization: Bearer $SPANWAY_API_KEY"
  4. Try it in the browser. Open Playground (/ui/playground), set Endpoint Type to /v1beta/interactions, pick the model and send a message. Then open Logs (/ui/logs) to see the interaction with its id and cost.

Expected result​

{
"id": "int_7c2d4e1f",
"object": "interaction",
"model": "gemini-3.8-flash",
"status": "completed",
"outputs": [{"type": "text", "text": "The release adds leaked key reporting and routing headers."}],
"usage": {"total_tokens": 182}
}

A background interaction answers first with status in_progress and empty outputs, and the GET call returns the outputs once it finishes. A cancelled interaction reports status cancelled.

Endpoints​

MethodPathSummary
POST/v1beta/interactionsCreate an interaction
GET/v1beta/interactions/{interaction_id}Get an interaction
DELETE/v1beta/interactions/{interaction_id}Delete an interaction
POST/v1beta/interactions/{interaction_id}/cancelCancel a running interaction

Interaction ids returned by the gateway are tied to the deployment that created them, so follow-up calls are routed back to the same provider account.

Agents​

Agent interactions call server side agents offered by the provider. The agent name goes in agent, and the gateway records usage and cost for the run like any other call. Because agents can run for minutes, create them with background: true and poll the interaction id, or stream. Named custom agents are created with the Gemini managed agents routes.

Gateway features​

Keys, budgets, guardrails and cost tracking apply. Interactions are logged with their id, so the Logs page can show the full history of a multi-turn interaction. For the simpler single-turn Gemini format, see generateContent.

Errors​

StatusWhat it meansFix
400 INVALID_ARGUMENTNeither model nor agent is set, or input is missing.Send one of model or agent and an input.
401 UNAUTHENTICATEDThe key is missing, wrong or expired.Use a live key from Virtual Keys.
403 PERMISSION_DENIEDThe key may not use the model or agent, or a guardrail blocked the input.Add the model to the key, or read the guardrail result in Logs.
404 NOT_FOUND on GET or cancelThe interaction id is unknown or belongs to another provider account.Use the id the gateway returned.
429 RESOURCE_EXHAUSTEDBudget or rate limit reached.Raise the limit on the key or team.

Providers​

The gateway's endpoint support matrix marks 106 provider integrations as supporting this endpoint:

AI21, AI21 Chat, AI/ML API, Amazon Nova, Anthropic, Anthropic Text, AssemblyAI (assemblyai), Auto Router (auto_router), Azure, Azure AI, Azure AI Foundry Agents, Azure Text, Baseten, AWS - Bedrock, Bytez, Cerebras, Clarifai, Cloudflare AI Workers, Codestral, Cohere, Cohere Chat, CometAPI, CompactifAI, Crusoe (crusoe), Cursor BYOK, Custom, Custom OpenAI (custom_openai), Dashscope, Databricks, DataRobot, Deepgram, DeepInfra, Deepseek, Docker Model Runner, ElevenLabs, Empower, Fal AI, Featherless AI, Fireworks AI, FriendliAI, Galadriel, Google AI Studio - Gemini, GitHub Models, GitHub Copilot, GMI Cloud, GradientAI, Groq AI, Heroku, Hosted VLLM, Huggingface, Hyperbolic, Inception (inception), Lambda AI, LangGraph, Lemonade, Llamafile, LM Studio, Manus, Maritalk, Meta - Llama API, Mistral AI API, Moonshot, Morph, Nebius AI Studio, NLP Cloud, Novita AI (novita), Nscale, Nvidia NIM, OCI, Ollama, Ollama Chat, Oobabooga (oobabooga), OpenAI, OpenRouter, OVHCloud AI Endpoints, Perplexity AI, Petals, Predibase, PublicAI, Qianwen AI Platform, QwenCloud, RAGFlow, Replicate, AWS - Sagemaker, Sagemaker Chat, Sambanova, SAP Generative AI Hub, Scaleway, Snowflake, Spanway Proxy, Text Completion Codestral, Text Completion OpenAI, Together AI, Triton, V0, Venice.ai, Vercel AI Gateway, Google - Vertex AI, Vertex AI Agent Engine, VLLM, Volcengine, WandB Inference, IBM - Watsonx.ai, Watsonx Text, xAI, Z.AI (Zhipu AI).