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 (фрагмент)
Цены взяты из текущей конфигурации Admesh, в долларах США за миллион токенов. Полный список — в каталоге моделей.
| Название и ID модели | Контекстное окно | Цена ввода / 1M | Цена вывода / 1M | Попадания в кэш / 1 млн |
|---|---|---|---|---|
Claude Fable 5 anthropic/claude-fable-5 | 1M | $3.8 / 1M | $19.00 / 1M | $0.38 / 1M |
Claude Fable 5.1 anthropic/claude-fable-5-1 | 1M | $3.8 / 1M | $19.00 / 1M | $0.095 / 1M |
Claude Fable 5.2 anthropic/claude-fable-5-2 | — | $0.88 / 1M | $4.4 / 1M | $0.022 / 1M |
Claude Haiku 4.5 (latest) anthropic/claude-haiku-4-5 | 200K | $0.11 / 1M | $0.55 / 1M | $0.011 / 1M |
Claude Haiku 4.5 anthropic/claude-haiku-4-5-20251001 | 200K | $0.11 / 1M | $0.55 / 1M | $0.011 / 1M |
Claude Haiku 5.5 anthropic/claude-haiku-5-5 | 1M | $0.011 / 1M | $0.055 / 1M | $0.0011 / 1M |
Claude Opus 4.5 (latest) anthropic/claude-opus-4-5 | 200K | $0.55 / 1M | $2.75 / 1M | $0.055 / 1M |
Claude Opus 4.5 anthropic/claude-opus-4-5-20251101 | 200K | $0.55 / 1M | $2.75 / 1M | $0.055 / 1M |
Выше указаны стандартные цены за единицу для публичных каналов; тарификация выполняется по фактическому расходу токенов. Посмотреть полный каталог моделей
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.
Частые вопросы
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?
Источники
Вызывайте эти модели через один шлюз
Admesh предоставляет единый API, совместимый с OpenAI: один Base URL и один ключ для Claude, GPT, DeepSeek и других моделей. Новым аккаунтам доступен пробный кредит без срока действия.
