Migrating from Official SDKs to a Unified Gateway: Five Steps with Zero Refactoring Cost
For projects already built on the official OpenAI or Anthropic SDKs, how do you connect to a unified gateway without changing business logic? This article provides a step-by-step migration checklist, verification methods, and common rollback plans.
1. Extract the Base URL into configuration
If your code still hardcodes https://api.openai.com/v1, the first step isn't to change the address—it's to move it into an environment variable. This determines whether you can roll back at any time.
2. Switch to the gateway address and Key
There are only two pieces of information you need to remember for Admesh: the Base URL is https://api.admesh.ai/v1, and the Key is created in the console. The plaintext Key is shown only once at creation; afterward, only the prefix and last four characters are retained.
Admesh live rates (excerpt)
Prices come from the live Admesh configuration, in USD per million tokens. See the model catalog for the full list.
| Model Name and ID | Context Window | Enter price / 1M | Output Price / 1M | Cache Hits / 1M |
|---|---|---|---|---|
Claude Fable 5 anthropic/claude-fable-5 | 1M | $3.25 / 1M | $16.25 / 1M | $0.325 / 1M |
Claude Fable 5.1 anthropic/claude-fable-5-1 | 1M | $3.25 / 1M | $16.25 / 1M | $0.08125 / 1M |
Claude Haiku 4.5 anthropic/claude-haiku-4-5-20251001 | 200K | $0.325 / 1M | $1.625 / 1M | $0.0325 / 1M |
Claude Haiku 5.5 anthropic/claude-haiku-5-5 | 1M | $0.0325 / 1M | $0.1625 / 1M | $0.00325 / 1M |
Claude Opus 4.5 anthropic/claude-opus-4-5-20251101 | 200K | $1.625 / 1M | $8.125 / 1M | $0.1625 / 1M |
Claude Opus 4.6 anthropic/claude-opus-4-6 | 1M | $1.625 / 1M | $8.125 / 1M | $0.1625 / 1M |
Claude Opus 4.7 anthropic/claude-opus-4-7 | 1M | $1.625 / 1M | $8.125 / 1M | $0.1625 / 1M |
Claude Opus 4.8 anthropic/claude-opus-4-8 | 1M | $1.625 / 1M | $8.125 / 1M | $0.1625 / 1M |
The above are the standard unit prices for public channels; billing is based on actual token usage. View the complete model catalog
3. Change model names to namespace/model
The gateway uses public model names in the namespace/model format (for example anthropic/…, openai/…, deepseek/…, qwen/…). The complete list is based on /v1/models or the model catalog in the console; the documentation site also has a [model list](https://docs.admesh.ai/zh/docs/api-reference/models) explanation.
Don't hardcode model names in your code—put them in configuration, so changing models is just a config change.
4. Dual-write comparison
- Send the same batch of real requests to both the official API and the gateway.
- Compare three things: the response structure (whether fields match), the
usagefield (Token counting methodology), and streaming chunk behavior. - Check error responses: deliberately send a request with a wrong parameter and confirm the error code format matches expectations.
- Record the differences in latency and cost between the two sides as a baseline for later optimization.
5. Canary rollout and rollback
- Switch non-critical traffic first (internal tools, low-risk tasks) and observe for a week.
- Monitor three metrics: error rate, P95 latency, and cost per request.
- Keep the rollback plan simple: change the environment variable back to the official address—no code changes needed.
- Once stability is confirmed, migrate your main workload and update the team's documentation and alerting configuration accordingly.
What about the native Anthropic protocol?
Some code directly uses Anthropic's Messages API shape (/v1/messages, required max_tokens, a separate system field). Admesh also provides an [Anthropic-compatible endpoint](https://docs.admesh.ai/zh/docs/api-reference/anthropic-compatible), so these projects don't need to be rewritten in OpenAI style—just change the Base URL and Key.
FAQ
Does migration require changing business code?
Does it support ready-made tools like LangChain, Cursor, and NextChat?
Can I keep my original official account after migration?
References
Call these models through one gateway
Admesh provides a unified OpenAI-compatible API: one Base URL and one key for Claude, GPT, DeepSeek and more. New accounts get trial credit that never expires.
