Documentation

Gemini

How to use GATE/0 with Google Gemini

GATE/0 is fully compatible with Google Gemini models, making integration seamless. Simply point your existing OpenAI client to GATE/0’s endpoint — no code changes required. You can enrich requests with custom labels to enable detailed tracking, cost allocation, and forecasting.

Whether you're using openai.ChatCompletion.create() or other endpoints, GATE/0 acts as a transparent proxy, preserving all functionality while adding powerful analytics and observability.

Set up your Google AI provider in GATE/0

  1. Retrieve your API key from Google AI Studio
  2. Add a new Google provider in GATE/0 here
  3. Copy your GATE/0 API key from here

Install OpenAI SDK

pip install openai
npm install openai

Configure the GATE/0 API key Set your GATE/0 API key as an environment variable:

export GATE0_API_KEY=your-gate0-api-key

Start using OpenAI SDK

import OpenAI from 'openai';

const openai = new OpenAI({
    baseURL: "https://gateway.gate.io/v1", // GATE0 cloud proxy URL
    apiKey: process.env.GATE0_API_KEY, // API key provided by GATE0
});

const chatCompletion = await openai.chat.completions.create({
    model: "google/gemini-2.0-flash", // Model name with provider prefix
    messages: [{ role: 'user', content: "Hello, how are you?" }],
    metadata: { // Custom labels
        "project":"alpha", 
        "client":"frontend", 
        "env":"prod"
    }
});

console.log(chatCompletion.choices);
from openai import OpenAI
import os

client = OpenAI(
    base_url="https://gateway.gate.io/v1", # GATE0 cloud proxy URL
    api_key=os.environ.get("GATE0_API_KEY"), # API key provided by GATE0
)

completion = client.chat.completions.create(
  model="google/gemini-2.0-flash", # Model name with provider prefix
  messages=[
    {"role": "user", "content": "Hello, how are you?"}
  ],
  extra_body={
    "metadata": { # Custom labels
        "project":"alpha", 
        "client":"frontend", 
        "env":"prod"
    }
  }
)
print(completion.choices[0].message)

Explanation of the implementation

  1. An instance of OpenAI is created with the base URL set to https://gateway.gate0.io/v1, using your GATE0 API key instead of the default OpenAI key.
  2. A prefixed model name google/gemini-2.0-flash is used.
  3. Custom labels are included to allocate and track costs more effectively.