Gemini Compatible API
AnyInt exposes Gemini-compatible routes under the /gemini/v1beta prefix. Treat these as provider-native routes and validate them in your environment before production use.
AnyInt exposes Gemini-compatible routes under the /gemini/v1beta prefix. These routes use Gemini-native contents[].parts[] request bodies rather than OpenAI messages.
Published routes
| Route | Use case |
|---|---|
POST /gemini/v1beta/models/{model}:generateContent | Text generation and native function calling |
POST /gemini/v1beta/models/{model}:streamGenerateContent?alt=sse | Streaming generation |
POST /gemini/v1beta/models/{image_model}:generateContent | Text-plus-image output |
Authentication
Authorization: Bearer <ANYINT_API_KEY>Gemini-style x-goog-api-key authentication is accepted by some gateway clients, but the documented AnyInt contract uses Authorization: Bearer. Use Bearer unless your integration has already verified the alternate header.
When to use Gemini-compatible routes
- You want to keep Gemini-native
contents[].parts[]payloads - You need
streamGenerateContent?alt=sse - You want Gemini-native
tools.functionDeclarations - You want the published Gemini image-generation route instead of a generic chat wrapper
If you want one uniform SDK integration, start with the OpenAI Compatible API instead.
Text generation example
Request fields
| Field | Type | Required | Meaning | Example |
|---|---|---|---|---|
contents | array | Yes | Conversation turns in Gemini-native format. | [{"role":"user","parts":[...]}] |
contents[].role | string | Recommended | Message role. Use user for user prompts and model for prior model turns. | user |
contents[].parts | array | Yes | Content parts for the turn. | [{"text":"Hello"}] |
parts[].text | string | For text input | Text prompt content. | Explain AnyInt. |
parts[].inlineData | object | For small inline media bytes | Gemini-native inline media part. Use it when the media starts as a local file and the encoded request body stays within gateway and model limits. | {"mimeType":"image/png","data":"..."} |
parts[].fileData | object | For uploaded or public media files | Gemini-native file reference. Use a public HTTPS URL in fileUri; do not send local filesystem paths. | {"mimeType":"video/mp4","fileUri":"https://your-domain.com/sample.mp4"} |
tools | array | No | Gemini-native tool declarations. | [{"functionDeclarations":[...]}] |
generationConfig | object | No | Generation controls such as temperature, max output tokens, or image response modalities. | {"temperature":0.7} |
safetySettings | array | No | Gemini-compatible safety settings when supported by the selected model. | [{"category":"...","threshold":"..."}] |
Generation config fields
| Field | Type | Required | Meaning | Example |
|---|---|---|---|---|
temperature | number | No | Sampling randomness. | 0.7 |
topP | number | No | Nucleus sampling value. | 1 |
topK | integer | No | Limits sampling to top K tokens when supported. | 40 |
maxOutputTokens | integer | No | Maximum generated tokens. | 512 |
stopSequences | array | No | Stop sequences that end generation. | ["END"] |
responseModalities | array | Image generation only | Required for Gemini image output examples; include TEXT and IMAGE. | ["TEXT","IMAGE"] |
curl https://api.anyint.ai/gemini/v1beta/models/gemini-3-flash-preview:generateContent \
-H "Authorization: Bearer $ANYINT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{"text": "How does AnyInt help multi-provider teams?"}
]
}
]
}'The minimum published request body is contents with at least one content item and one text part.
Streaming example
curl "https://api.anyint.ai/gemini/v1beta/models/gemini-3-flash-preview:streamGenerateContent?alt=sse" \
-H "Authorization: Bearer $ANYINT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{"text": "Stream a short answer about API gateways."}
]
}
]
}'The alt=sse query parameter is required on the published streaming route.
Streaming response behavior
| Field | Meaning |
|---|---|
candidates[] | Incremental candidate outputs from the model |
candidates[].content.parts[] | Generated text or media parts, depending on the model |
usageMetadata | Token usage metadata when returned by the provider |
finishReason | Why generation stopped for the candidate |
Video or file input
For Gemini-native media understanding, use fileData.fileUri with a URL that the model provider can fetch directly. The URL should return the media bytes, not an HTML share page, and should not require cookies, login, or private network access.
For long video or large media analysis, prefer streamGenerateContent?alt=sse so your client receives partial events while the provider is still processing the file.
curl "https://api.anyint.ai/gemini/v1beta/models/gemini-3.1-pro-preview:streamGenerateContent?alt=sse" \
-H "Authorization: Bearer $ANYINT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Describe the visible scene at 00:00, 00:30, and 01:00. If you cannot access the video, say so."
},
{
"fileData": {
"mimeType": "video/mp4",
"fileUri": "https://your-domain.com/sample.mp4"
}
}
]
}
],
"generationConfig": {
"maxOutputTokens": 4096
}
}'For local video files, upload the file to object storage or another public HTTPS location first, then pass the URL in fileData.fileUri. Do not pass a local path such as /tmp/sample.mp4.
When you first add media input to an integration, make a small verification request that asks for visible timestamps or objects you can independently check. A well-formed JSON response alone does not prove the provider actually processed the media file.
Function-calling example
Function declaration fields
| Field | Type | Required | Meaning | Example |
|---|---|---|---|---|
tools[].functionDeclarations | array | Yes | Functions the model may call. | [{"name":"get_weather",...}] |
name | string | Yes | Function name your application recognizes. | get_current_temperature |
description | string | Recommended | Tells the model when to use the function. | Gets the current temperature. |
parameters | object | Yes | JSON-schema-like parameter description. | {"type":"object","properties":{...}} |
parameters.properties | object | Usually | Function argument fields. | {"location":{"type":"string"}} |
parameters.required | array | No | Required argument names. | ["location"] |
curl https://api.anyint.ai/gemini/v1beta/models/gemini-3-flash-preview:generateContent \
-H "Authorization: Bearer $ANYINT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{"text": "What is the temperature in London?"}
]
}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_current_temperature",
"description": "Gets the current temperature for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name, e.g. San Francisco"
}
},
"required": ["location"]
}
}
]
}
]
}'This is the published Gemini-native tool pattern. It is the right choice when you want the model to emit function arguments using functionDeclarations rather than OpenAI-style tools.
Image generation example
The published image-generation schema requires generationConfig.responseModalities to include both TEXT and IMAGE.
curl https://api.anyint.ai/gemini/v1beta/models/gemini-3.1-flash-image-preview:generateContent \
-H "Authorization: Bearer $ANYINT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{"text": "Generate a cinematic poster for an AI music launch."}
]
}
],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"]
}
}'Image input guidance
For customer-facing image input today, prefer OpenAI Compatible API with messages[].content[] blocks and image_url. That path is the documented multimodal chat shape and works with image-capable models through the OpenAI-compatible route.
If your application already uses Gemini-native request bodies, /gemini/v1beta also supports inline image bytes through contents[].parts[].inlineData:
IMAGE_DATA="$(base64 -i ./reference.png | tr -d '\n')"
curl https://api.anyint.ai/gemini/v1beta/models/gemini-3.1-flash-image-preview:generateContent \
-H "Authorization: Bearer $ANYINT_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"contents\": [
{
\"role\": \"user\",
\"parts\": [
{
\"text\": \"Use this reference image and describe the product style in one sentence.\"
},
{
\"inlineData\": {
\"mimeType\": \"image/png\",
\"data\": \"$IMAGE_DATA\"
}
}
]
}
]
}"Use the Gemini-style inlineData field name in new integrations. Do not send local filesystem paths through fileData.fileUri; upload the file first, use a public HTTPS file URL, or use inlineData for small inline media.
Do not assume a /gemini/v1/... route or a raw Google API payload is supported by AnyInt unless it is listed on this page.
Common mistakes
- Forgetting
alt=sseon the streaming route - Omitting
role: "user"incontents[] - Calling bare
/v1beta/...instead of the AnyInt/gemini/v1beta/...prefix - Calling
/gemini/v1/models/...instead of the published/gemini/v1beta/models/...route - Omitting
responseModalitieson image generation - Sending OpenAI
messagesinstead of Geminicontents[].parts[] - Sending local filesystem paths in
fileData.fileUri - Sending a video share page, signed-in URL, or blocked private URL instead of a direct media URL
- Sending bare base64 without the
inlineData.mimeTypeandinlineData.datawrapper
Related pages
Anthropic Compatible API
Use this family when your application already speaks Anthropic's Messages API or when you need message-block semantics that are different from OpenAI chat completions.
Kling video
Create Kling video tasks through AnyInt's OpenAI-style video route. Use the Transtreams native routes only when you need provider-native payload control.