Migrating from OpenAI
If you already have an integration built on the OpenAI or Anthropic SDK, moving to MyTokenGate takes three changes: point the base URL at the MyTokenGate gateway, swap in your MyTokenGate API key, and use a MyTokenGate model id. The request and response formats stay the same, so the rest of your code keeps working.
Migrating an OpenAI integration
The gateway is OpenAI-compatible. Keep the openai SDK you already use and change only the base URL, the key, and the model.
Before:
from openai import OpenAI
client = OpenAI(
api_key="sk-your-openai-key",
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)After:
from openai import OpenAI
client = OpenAI(
base_url="https://gateway.mytokengate.com/v1",
api_key="tg-your-api-key",
)
response = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)The SDK appends /chat/completions to the base URL, so you set the base URL to https://gateway.mytokengate.com/v1 and nothing more.
The same request as a raw curl call:
curl https://gateway.mytokengate.com/v1/chat/completions \
-H "Authorization: Bearer tg-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [{"role": "user", "content": "Hello"}]
}'Node.js is the same idea: pass baseURL: "https://gateway.mytokengate.com/v1" and your tg- key to the openai client, then change the model.
Migrating a Claude / Anthropic integration
The gateway is also Anthropic-compatible for Claude models. Keep the anthropic SDK and change the base URL, the key, and the model.
Before:
from anthropic import Anthropic
client = Anthropic(
api_key="sk-ant-your-key",
)
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)After:
from anthropic import Anthropic
client = Anthropic(
base_url="https://gateway.mytokengate.com/v1",
api_key="tg-your-api-key",
)
message = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)The SDK appends /messages to the base URL, so the base URL stays https://gateway.mytokengate.com/v1.
For Claude models, use the native Anthropic protocol shown above rather than calling them through the OpenAI-style endpoint. The native path passes features like extended thinking through directly and avoids protocol conversion, so it gives the best compatibility. Cross-protocol calls work, but native is the recommended default.
Model name mapping
Change your old model names to the current MyTokenGate ids.
| Old model | MyTokenGate id | Protocol |
|---|---|---|
gpt-4o, older GPT | gpt-5.4 (everyday default) or gpt-5.6-sol (flagship) | OpenAI |
gpt-4o-mini | gpt-5.4-nano | OpenAI |
claude-3-*, claude-*-2025* | claude-sonnet-5 (balanced) or claude-opus-4-8 | Anthropic |
| Gemini models | gemini-3.1-pro-preview or gemini-3.5-flash | OpenAI |
This is a short list of common cases. For the full set of active models, ids, and pricing, see the Models Reference.
What stays the same
Because the gateway is protocol-compatible, everything else works the way it does in the original API:
- Request and response shapes are unchanged.
- Streaming works the same way.
- Function calling and tool use work the same way.
- JSON mode and structured output work the same way.
You do not rewrite your handling code. Point the client at the gateway and keep parsing responses as before.
Common pitfalls
- Do not include
/v1twice. Set the base URL tohttps://gateway.mytokengate.com/v1and let the SDK append/chat/completionsor/messages. Adding the path yourself produces a doubled route. - Keep the native protocol per model family. Use the OpenAI protocol for GPT, Gemini, and other models, and the Anthropic protocol for Claude.
- Use your MyTokenGate
tg-key, not the vendor key. An oldsk-orsk-ant-key will not authenticate against the gateway.