Back to Home
Integration Guide7 min readSource: Admesh 技术团队

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.

Base URL and endpoint documentation →

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.

Admesh.ai Model Price List: Prices and Context Windows for 8 Enabled Models
Model Name and IDContext WindowEnter price / 1MOutput Price / 1MCache Hits / 1M
Claude Fable 5anthropic/claude-fable-5
1M$3.25 / 1M$16.25 / 1M$0.325 / 1M
Claude Fable 5.1anthropic/claude-fable-5-1
1M$3.25 / 1M$16.25 / 1M$0.08125 / 1M
Claude Haiku 4.5anthropic/claude-haiku-4-5-20251001
200K$0.325 / 1M$1.625 / 1M$0.0325 / 1M
Claude Haiku 5.5anthropic/claude-haiku-5-5
1M$0.0325 / 1M$0.1625 / 1M$0.00325 / 1M
Claude Opus 4.5anthropic/claude-opus-4-5-20251101
200K$1.625 / 1M$8.125 / 1M$0.1625 / 1M
Claude Opus 4.6anthropic/claude-opus-4-6
1M$1.625 / 1M$8.125 / 1M$0.1625 / 1M
Claude Opus 4.7anthropic/claude-opus-4-7
1M$1.625 / 1M$8.125 / 1M$0.1625 / 1M
Claude Opus 4.8anthropic/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

  1. Send the same batch of real requests to both the official API and the gateway.
  2. Compare three things: the response structure (whether fields match), the usage field (Token counting methodology), and streaming chunk behavior.
  3. Check error responses: deliberately send a request with a wrong parameter and confirm the error code format matches expectations.
  4. 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?
Usually not. The SDK call pattern, message structure, and streaming logic all stay the same. What needs to change is the Base URL, API Key, and model name—and the Base URL and model name should be kept in configuration.
Does it support ready-made tools like LangChain, Cursor, and NextChat?
Yes. As long as the tool allows a custom Base URL and OpenAI-compatible model names, it can connect. The documentation site has integration steps for clients such as Claude Code, Codex, Cursor, and Cherry Studio, with all verified configurations there.
Can I keep my original official account after migration?
Yes, and it's recommended to keep it for a while. During the dual-write comparison phase, both sides need to be callable; after the official switch, downgrade the official account to a backup as a fallback for extreme situations.

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.