AnyInt Docs
API Reference

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

RouteUse case
POST /gemini/v1beta/models/{model}:generateContentText generation and native function calling
POST /gemini/v1beta/models/{model}:streamGenerateContent?alt=sseStreaming generation
POST /gemini/v1beta/models/{image_model}:generateContentText-plus-image output

Authentication

Authorization: Bearer <ANYINT_API_KEY>

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

FieldTypeRequiredMeaningExample
contentsarrayYesConversation turns in Gemini-native format.[{"role":"user","parts":[...]}]
contents[].rolestringRecommendedMessage role. Use user for user prompts and model for prior model turns.user
contents[].partsarrayYesContent parts for the turn.[{"text":"Hello"}]
parts[].textstringFor text inputText prompt content.Explain AnyInt.
parts[].inlineDataobjectFor inline mediaInline media payload when supported by the model.{"mimeType":"image/png","data":"..."}
toolsarrayNoGemini-native tool declarations.[{"functionDeclarations":[...]}]
generationConfigobjectNoGeneration controls such as temperature, max output tokens, or image response modalities.{"temperature":0.7}
safetySettingsarrayNoGemini-compatible safety settings when supported by the selected model.[{"category":"...","threshold":"..."}]

Generation config fields

FieldTypeRequiredMeaningExample
temperaturenumberNoSampling randomness.0.7
topPnumberNoNucleus sampling value.1
topKintegerNoLimits sampling to top K tokens when supported.40
maxOutputTokensintegerNoMaximum generated tokens.512
stopSequencesarrayNoStop sequences that end generation.["END"]
responseModalitiesarrayImage generation onlyRequired for Gemini image output examples; include TEXT and IMAGE.["TEXT","IMAGE"]
curl https://gateway.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://gateway.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

FieldMeaning
candidates[]Incremental candidate outputs from the model
candidates[].content.parts[]Generated text or media parts, depending on the model
usageMetadataToken usage metadata when returned by the provider
finishReasonWhy generation stopped for the candidate

Function-calling example

Function declaration fields

FieldTypeRequiredMeaningExample
tools[].functionDeclarationsarrayYesFunctions the model may call.[{"name":"get_weather",...}]
namestringYesFunction name your application recognizes.get_current_temperature
descriptionstringRecommendedTells the model when to use the function.Gets the current temperature.
parametersobjectYesJSON-schema-like parameter description.{"type":"object","properties":{...}}
parameters.propertiesobjectUsuallyFunction argument fields.{"location":{"type":"string"}}
parameters.requiredarrayNoRequired argument names.["location"]
curl https://gateway.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://gateway.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"]
    }
  }'

Common mistakes

  • Forgetting alt=sse on the streaming route
  • Omitting role: "user" in contents[]
  • Calling bare /v1beta/... instead of the AnyInt /gemini/v1beta/... prefix
  • Omitting responseModalities on image generation
  • Sending OpenAI messages instead of Gemini contents[].parts[]

On this page