Developer Dashboard

Google Gemini API Guide ​

AvalAI provides Google Gemini models through a shared API key and multiple request formats. Use the new flagship gemini-3.7-flash for coding, agents, web development, complex document analysis, and workflow automation.

Gemini 3.7 Flash at a Glance ​

PropertyDetails
Model IDgemini-3.7-flash
Input context1,048,576 tokens
Maximum output65,536 tokens
InputsText, image, video, audio, PDF
OutputText
Endpointsv1beta/, v1/chat/completions, v1/messages, partial v1/responses
Promotional pricing$0.75 input, $0.075 cached input, $3.75 output per 1M tokens through December 31, 2026
Standard pricing$1.50 input, $0.15 cached input, $7.50 output per 1M tokens after December 31, 2026

Choose an API Format ​

  • Use v1/chat/completions for OpenAI-compatible applications and the broadest migration compatibility.
  • Use v1/messages with the Anthropic SDK or an Anthropic-compatible request format.
  • Use native Gemini v1beta/ for Gemini-specific request fields and tools.
  • Use v1/responses only after verifying that every parameter and tool required by your workflow is supported.

OpenAI-Compatible Example ​

bash
curl https://api.avalai.ir/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AVALAI_API_KEY" \
  -d '{
    "model": "gemini-3.7-flash",
    "messages": [{"role": "user", "content": "Review this architecture and return a phased implementation plan."}]
  }'
python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AVALAI_API_KEY"],
    base_url="https://api.avalai.ir/v1",
)

response = client.chat.completions.create(
    model="gemini-3.7-flash",
    messages=[
        {
            "role": "user",
            "content": "Review this architecture and return a phased implementation plan.",
        }
    ],
)

print(response.choices[0].message.content)
javascript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.AVALAI_API_KEY,
  baseURL: "https://api.avalai.ir/v1",
});

const response = await client.chat.completions.create({
  model: "gemini-3.7-flash",
  messages: [
    {
      role: "user",
      content: "Review this architecture and return a phased implementation plan.",
    },
  ],
});

console.log(response.choices[0].message.content);

Native Gemini Example ​

bash
curl https://api.avalai.ir/v1beta/models/gemini-3.7-flash:generateContent \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AVALAI_API_KEY" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [{"text": "Design a reliable tool-using incident triage agent."}]
      }
    ]
  }'

Production Guidance ​

  • Keep API keys on the server and load them from environment variables.
  • Evaluate representative prompts, tools, and multimodal inputs before moving production traffic.
  • Add retries with backoff for transient failures and observe the documented rate limits.
  • Validate structured outputs in application code even when using a response schema.
  • Forecast long-running workloads using the standard Gemini 3.7 Flash rates that begin after December 31, 2026.