Skip to main content

/interactions

FeatureSupportedNotes
Logging✅Works across all integrations
Streaming✅
Loadbalancing✅Between supported models
Supported LLM providersAll LiteLLM supported CHAT COMPLETION providersopenai, anthropic, bedrock, vertex_ai, gemini, azure, azure_ai etc.

LiteLLM Python SDK Usage​

Quick Start​

Create Interaction
import litellm
import os

os.environ["GEMINI_API_KEY"] = "your-api-key"

response = litellm.interactions.create(
model="gemini/gemini-3.8-flash",
input="Tell me a short joke about programming."
)

print(response.outputs[-1].text)

Async Usage​

Async Create Interaction
import litellm
import os
import asyncio

os.environ["GEMINI_API_KEY"] = "your-api-key"

async def main():
response = await litellm.interactions.acreate(
model="gemini/gemini-3.8-flash",
input="Tell me a short joke about programming."
)
print(response.outputs[-1].text)

asyncio.run(main())

Streaming​

Streaming Interaction
import litellm
import os

os.environ["GEMINI_API_KEY"] = "your-api-key"

response = litellm.interactions.create(
model="gemini/gemini-3.8-flash",
input="Write a 3 paragraph story about a robot.",
stream=True
)

for chunk in response:
print(chunk)

LiteLLM AI Gateway (Proxy) Usage​

Setup​

Add this to your litellm proxy config.yaml:

config.yaml
model_list:
- model_name: gemini-flash
litellm_params:
model: gemini/gemini-3.8-flash
api_key: os.environ/GEMINI_API_KEY

Start litellm:

litellm --config /path/to/config.yaml

# RUNNING on http://0.0.0.0:4000

Test Request​

Create Interaction
curl -X POST "http://localhost:4000/v1beta/interactions" \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.8-flash",
"input": "Tell me a short joke about programming."
}'

Streaming:

Streaming Interaction
curl -N -X POST "http://localhost:4000/v1beta/interactions" \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.8-flash",
"input": "Write a 3 paragraph story about a robot.",
"stream": true
}'

Get Interaction:

Get Interaction by ID
curl "http://localhost:4000/v1beta/interactions/{interaction_id}" \
-H "Authorization: Bearer $LITELLM_API_KEY"

Request/Response Format​

Request Parameters​

ParameterTypeRequiredDescription
modelstringYesModel to use (e.g., gemini/gemini-2.5-flash)
inputstringYesThe input text for the interaction
streambooleanNoEnable streaming responses
toolsarrayNoTools available to the model
system_instructionstringNoSystem instructions for the model
generation_configobjectNoGeneration configuration
previous_interaction_idstringNoID of previous interaction for context
continuation_tokenstringNoToken from an interaction that ended with status: "requires_continuation", to resume that long decode yourself

Response Format​

{
"id": "interaction_abc123",
"object": "interaction",
"model": "gemini-3.8-flash",
"status": "completed",
"created": "2025-01-15T10:30:00Z",
"updated": "2025-01-15T10:30:05Z",
"role": "model",
"outputs": [
{
"type": "text",
"text": "Why do programmers prefer dark mode? Because light attracts bugs!"
}
],
"usage": {
"total_input_tokens": 10,
"total_output_tokens": 15,
"total_tokens": 25
}
}

Long decode (answers past Google's per-request output cap)​

A foreground Interactions request to a model that supports long decode (for example gemini/gemini-4-argon) stops at Google's per-request cap, 32,768 output tokens when not streaming and 65,536 when streaming, with status: "requires_continuation" and a continuation_token. LiteLLM passes both through unchanged, exactly as Google returns them, and does not continue the decode for you. To get the rest of the answer, send the request again with previous_interaction_id set to that interaction's id and continuation_token set to that token, and repeat until the status is no longer requires_continuation. Each hop is its own request, with its own spend log, budget check and rate limit.

import litellm

request = {
"model": "gemini/gemini-4-argon",
"generation_config": {"max_output_tokens": 262144, "thinking_level": "high"},
}
response = litellm.interactions.create(input="Write a complete, rigorous proof of the prime number theorem.", **request)
steps = list(response.steps or [])
while response.status == "requires_continuation":
response = litellm.interactions.create(
previous_interaction_id=response.id,
continuation_token=response.continuation_token,
**request,
)
steps.extend(response.steps or [])
print(response.status) # "completed"
print("".join(c["text"] for step in steps for c in step.get("content", []) if c.get("type") == "text"))

Every hop re-reads the answer so far as input, so each hop's usage.total_input_tokens grows while usage.initial_input_tokens stays the size of your prompt. With store: false nothing is stored on Google's side, so resend input instead of previous_interaction_id. In streaming mode the interaction.completed event carries the same status and continuation_token.

Background requests (background: true) are continued by Google on its side and need no client hops.

Calling non-Interactions API endpoints (/interactions to /responses Bridge)​

LiteLLM allows you to call non-Interactions API models via a bridge to LiteLLM's /responses endpoint. This is useful for calling OpenAI, Anthropic, and other providers that don't natively support the Interactions API.

Python SDK Usage​

SDK Usage
import litellm
import os

# Set API key
os.environ["OPENAI_API_KEY"] = "your-openai-api-key"

# Non-streaming interaction
response = litellm.interactions.create(
model="gpt-6.1-sol",
input="Tell me a short joke about programming."
)

print(response.outputs[-1].text)

LiteLLM Proxy Usage​

Setup Config:

Example Configuration
model_list:
- model_name: openai-model
litellm_params:
model: gpt-6.1-sol
api_key: os.environ/OPENAI_API_KEY

Start Proxy:

Start LiteLLM Proxy
litellm --config /path/to/config.yaml

# RUNNING on http://0.0.0.0:4000

Make Request:

non-Interactions API Model Request
curl http://localhost:4000/v1beta/interactions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-d '{
"model": "openai-model",
"input": "Tell me a short joke about programming."
}'

Supported Providers​

ProviderLink to Usage
Google AI StudioUsage
All other LiteLLM providersBridge Usage