Skip to content
TokenGauge
Menu

How-to

How to Switch From OpenRouter to SayGM: A Migration Checklist

For GPT and open models the change is a base URL, a key and the model ID strings. Claude and Gemini calls also move to their native SDKs. This checklist covers each step, the code diffs, and how to confirm nothing broke.

Published 4 Oct 2026 · Updated 11 Nov 2026 · 8 min read

Summary

  • Audit model IDs first. SayGM lists about 65 models.
  • Change the base URL and key. GPT and open models stay on the OpenAI SDK; Claude calls move to the Anthropic SDK and Gemini calls to the Gemini SDK.
  • Drop vendor prefixes and use hyphens in Claude IDs: anthropic/claude-sonnet-5.5 becomes claude-sonnet-5-5.
  • Verify streaming, tool calls, caching and spend before shipping.
  • Keep OpenRouter behind a fallback for any model SayGM does not list.

01

Before you start

List every model ID the codebase calls. OpenRouter IDs carry a vendor prefix, which makes them easy to find.

Shell
grep -rnoE "(anthropic|openai|google|moonshotai|deepseek|z-ai)/[a-z0-9.:-]+" src/ | sort -u

Check each result against the SayGM models page. If a model is missing, keep OpenRouter for that model and move the rest.

02

Step 1: Account and key

Sign in to SayGM, load credits and generate an API key. There is no fee on the credit purchase. Store the key and base URL as environment variables.

.env
- OPENROUTER_API_KEY=sk-or-...+ SAYGM_API_KEY=sk-saygm-...+ SAYGM_BASE_URL=<SayGM base URL from docs>+ SAYGM_ANTHROPIC_BASE_URL=<SayGM Anthropic endpoint from docs>

The exact endpoints for the OpenAI, Anthropic and Gemini APIs are in the SayGM docs, linked from saygm.com (opens in a new tab).

03

Step 2: Change the base URL

OpenAI SDK

Most OpenRouter code uses the OpenAI client. Keep it for GPT and open models and change two fields. SayGM serves Claude only on the Anthropic Messages API and Gemini only on generateContent, so those calls move to the native SDKs.

TypeScript
const client = new OpenAI({-  baseURL: "https://openrouter.ai/api/v1",-  apiKey: process.env.OPENROUTER_API_KEY,+  baseURL: process.env.SAYGM_BASE_URL,+  apiKey: process.env.SAYGM_API_KEY,});

Anthropic SDK

If you called Claude through OpenRouter's OpenAI-shaped API, move those calls to the Anthropic SDK. SayGM passes the native Messages API through, so features that a translation layer drops keep working. Gemini calls move to the Gemini SDK the same way, pointed at SayGM's Gemini endpoint.

Python
from anthropic import Anthropic client = Anthropic(    base_url=os.environ["SAYGM_ANTHROPIC_BASE_URL"],    api_key=os.environ["SAYGM_API_KEY"],)

Editors and agents

Cline and Claude Code only need a URL and key. Cursor does too, but it always sends Claude and Gemini to their makers, so it reaches only SayGM's GPT and open models, and SayGM advises Ask or Chat mode over Agent mode. See the setup notes for Cursor, Cline and Claude Code.

04

Step 3: Map model IDs

SayGM uses the model name without a vendor prefix. Remove any OpenRouter routing suffix as well. Claude IDs use hyphens where OpenRouter uses dots. Other vendors keep the dots.

OpenRouterSayGM
anthropic/claude-opus-5.5claude-opus-5-5
anthropic/claude-sonnet-5.5claude-sonnet-5-5
anthropic/claude-haiku-5.5claude-haiku-5-5
openai/gpt-6.1-solgpt-6.1-sol
google/gemini-3.8-flashgemini-3.8-flash
TypeScript
const toSaygmModel = (id: string) => {  const [vendor, rest] = id.split("/");  const name = rest.split(":")[0];  return vendor === "anthropic" ? name.replaceAll(".", "-") : name;};

05

Step 4: Verify

Run these checks in staging with real prompts.

CheckHowPass when
StreamingRun a long streamed completionCompletes and returns usage counts
Tool callsReplay a recorded tool-use conversationSame schema round-trips
Prompt cachingSend the same system prompt twiceSecond call reports cache hits
ErrorsSend an invalid model IDYour error handling still catches it
SpendRun a known token volumeDashboard spend matches the rate card

06

Step 5: Keep a fallback

Two options. Use a SayGM cascade model, which falls through to the next model when a call fails. Or keep OpenRouter as a second client and retry there in your own code.

TypeScript
const openrouterIds: Record<string, string> = {  "gpt-6.1-sol": "openai/gpt-6.1-sol",  "deepseek-v4.1-flash": "deepseek/deepseek-v4.1-flash",}; async function complete(body: ChatRequest) {  try {    return await saygm.chat.completions.create(body);  } catch (error) {    return await openrouter.chat.completions.create({ ...body, model: openrouterIds[body.model] ?? body.model });  }}

Keep an explicit lookup table like the one above. The vendor prefix cannot be read from a SayGM ID, and Claude's dot and hyphen rule differs, so a string rule is easy to get wrong in the reverse direction. This client covers GPT and open models; Claude calls on the Anthropic SDK need their own fallback.

07

Rolling it out

  1. Move one low-risk service or a share of traffic first.
  2. Compare latency, error rates and output quality for a week.
  3. Compare spend against the same week on OpenRouter.
  4. Move the remaining traffic. Keep the fallback in place.

For a sense of the saving before you start, the calculator on the index page prices any model at your volume.

Prices in this guide are a November 2026 snapshot and move regularly.

Visit SayGM (opens in a new tab)