Integration Guide

Get Started with
X Router

Use the official @google/genai SDK as usual just point it to our gateway. Your budget is tracked automatically and thinking tokens are completely free.

1

Your Gateway URL

All requests are routed through this endpoint. Use it as your baseUrl in the SDK:

https://gemini-router.xmemlabs.workers.dev
2

Initialize the SDK

npm install @google/genai
const { GoogleGenAI } = require("@google/genai")

const ai = new GoogleGenAI({
  apiKey: "sm-gemini-your-key-here",
  httpOptions: {
    baseUrl: "https://gemini-router.xmemlabs.workers.dev"
  }
})

// That's it! Use the SDK exactly as normal
const response = await ai.models.generateContent({
  model: "gemini-2.5-flash",
  contents: "Explain quantum computing"
})
3

Supported Models & Pricing

Pricing per 1M tokensOther models → fallback $1.00 / $2.00
gemini-3.1-pro-previewMost Capable
$2.00 in$12.00 out
gemini-3.1-flash-lite-previewLightweight
$0.25 in$1.50 out
gemini-3.1-flash-live-previewReal-time
$1.00 in$4.00 out
gemini-3-flash-preview
$0.50 in$3.00 out
gemini-2.5-pro
$1.25 in$10.00 out
gemini-2.5-flashBest Value
$0.30 in$2.50 out
gemini-2.5-flash-liteCheapest
$0.10 in$0.40 out

🎁 Thinking Tokens are FREE

We only bill for prompt tokens and candidate (output) tokens. The internal reasoning tokens that models like gemini-2.5-flash use for chain-of-thought thinking are not counted toward your budget. You get smarter responses without paying extra.