Google AI Studio logo
Google AI Studio

Gemini 3.1 Pro Preview (AI Studio)

Google AI Studio preview multimodal model with a 1M context window and 64K output for advanced reasoning and high-quality generation

Category Text Model ID gemini-3.1-pro-preview
Context Window1M input / 64K output tokens
Knowledge CutoffJanuary 2025
Pricing (<=200K)Input $2 / M tokens; Output $12 / M tokens

Pricing & Specs

💰 Pricing

Input$2 / M tokens
Output$12 / M tokens

⚙️ Specs

Context Window1M input / 64K output tokens
Knowledge CutoffJanuary 2025
Pricing (<=200K)Input $2 / M tokens; Output $12 / M tokens
Pricing (>200K)Input $4 / M tokens; Output $18 / M tokens
ProviderGoogle AI Studio

API Examples

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="your-api-key",
    base_url="https://api.xairouter.com/v1"
)

response = client.chat.completions.create(
    model="gemini-3.1-pro-preview",
    messages=[
        {"role": "user", "content": "Explain the principles of quantum entanglement"}
    ]
)

print(response.choices[0].message.content)

cURL (OpenAI API)

curl https://api.xairouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gemini-3.1-pro-preview",
    "messages": [
      {"role": "user", "content": "Explain the principles of quantum entanglement"}
    ]
  }'

Developer Assist

# Install the latest version
npm install -g @google/gemini-cli@latest

# Note: Choose ONE of the following configurations, do NOT use both!

# ===== Pay-as-you-go Configuration =====
export GOOGLE_GEMINI_BASE_URL="https://api.xairouter.com"
export GEMINI_API_KEY="sk-Xvs..."

# ===== Monthly Subscription Configuration =====
# export CODE_ASSIST_ENDPOINT="https://api.xairouter.com"
# export GOOGLE_CLOUD_ACCESS_TOKEN="sk-Xvs..."
# export GOOGLE_GENAI_USE_GCA="true"

# Optional: Specify model version
export GEMINI_MODEL="gemini-3.1-pro-preview"

# Launch Gemini CLI
gemini