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.5becomesclaude-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.
grep -rnoE "(anthropic|openai|google|moonshotai|deepseek|z-ai)/[a-z0-9.:-]+" src/ | sort -uCheck 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.
- 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.
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.
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.
| OpenRouter | SayGM |
|---|---|
anthropic/claude-opus-5.5 | claude-opus-5-5 |
anthropic/claude-sonnet-5.5 | claude-sonnet-5-5 |
anthropic/claude-haiku-5.5 | claude-haiku-5-5 |
openai/gpt-6.1-sol | gpt-6.1-sol |
google/gemini-3.8-flash | gemini-3.8-flash |
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.
| Check | How | Pass when |
|---|---|---|
| Streaming | Run a long streamed completion | Completes and returns usage counts |
| Tool calls | Replay a recorded tool-use conversation | Same schema round-trips |
| Prompt caching | Send the same system prompt twice | Second call reports cache hits |
| Errors | Send an invalid model ID | Your error handling still catches it |
| Spend | Run a known token volume | Dashboard 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.
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
- Move one low-risk service or a share of traffic first.
- Compare latency, error rates and output quality for a week.
- Compare spend against the same week on OpenRouter.
- 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)