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>

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

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 small inline media bytesGemini-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[].fileDataobjectFor uploaded or public media filesGemini-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"}
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://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

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

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

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://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=sse on the streaming route
  • Omitting role: "user" in contents[]
  • Calling bare /v1beta/... instead of the AnyInt /gemini/v1beta/... prefix
  • Calling /gemini/v1/models/... instead of the published /gemini/v1beta/models/... route
  • Omitting responseModalities on image generation
  • Sending OpenAI messages instead of Gemini contents[].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.mimeType and inlineData.data wrapper

On this page