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-5becomesclaude-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.
grep -rnoE "(anthropic|openai|google|moonshotai|deepseek)/[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>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.
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.
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.
| OpenRouter | SayGM |
|---|---|
anthropic/claude-opus-5 | claude-opus-5 |
anthropic/claude-sonnet-5 | claude-sonnet-5 |
anthropic/claude-haiku-4.5 | claude-haiku-4.5 |
openai/gpt-5.5 | gpt-5.5 |
const toSaygmModel = (id: string) => id.replace(/^[a-z-]+\//, "").split(":")[0];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.
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
- 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 October 2026 snapshot and move each epoch.
Current SayGM pricing (opens in a new tab)