Skip to content
TokenGauge
Menu

How-to

How to Switch From OpenRouter to SayGM: A Migration Checklist

For most codebases the change is a base URL, a key and the model ID strings. This checklist covers each step, the code diffs, and how to confirm nothing broke.

Updated 9 Oct 2026 · 8 min read · First published 4 Oct 2026

Summary

  • Audit model IDs first. SayGM lists about 65 models.
  • Change the base URL and key. The OpenAI, Anthropic and Gemini SDKs stay.
  • Drop vendor prefixes: anthropic/claude-sonnet-5 becomes claude-sonnet-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)/[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>

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

03

Step 2: Change the base URL

OpenAI SDK

Most OpenRouter code uses the OpenAI client. Keep it and change two fields.

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, consider moving those calls to the Anthropic SDK. SayGM passes the native Messages API through, so features that a translation layer drops keep working.

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

Cursor, Cline and Claude Code only need a URL and key. 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.

OpenRouterSayGM
anthropic/claude-opus-5claude-opus-5
anthropic/claude-sonnet-5claude-sonnet-5
anthropic/claude-haiku-4.5claude-haiku-4.5
openai/gpt-5.5gpt-5.5
TypeScript
const toSaygmModel = (id: string) => id.replace(/^[a-z-]+\//, "").split(":")[0];

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
async function complete(body: ChatRequest) {  try {    return await saygm.chat.completions.create(body);  } catch (error) {    return await openrouter.chat.completions.create({ ...body, model: "anthropic/" + body.model });  }}

The prefix mapping above only covers Claude. Keep an explicit lookup table if you route several vendors.

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 October 2026 snapshot and move each epoch.

Current SayGM pricing (opens in a new tab)