Migrate from OpenRouter to TokenRex
Switch from OpenRouter to TokenRex with INR billing and UPI top-ups.
Steps
- Create a TokenRex API key and top up in rupees.
- Change the base URL from OpenRouter's to https://tokenrex.ai/api/public.
- Remove the provider prefix from model IDs (openai/gpt-6-sol becomes gpt-6-sol).
- Remove OpenRouter-only headers; they are not needed.
What to check after switching
- Run your existing test prompts and compare replies.
- Check the usage field in responses to confirm token counts and costs.
- Short model IDs are used on TokenRex, for example gpt-6-sol rather than openai/gpt-6-sol.
Example
from openai import OpenAI
client = OpenAI(api_key="YOUR_TOKENREX_KEY", base_url="https://tokenrex.ai/api/public")
resp = client.chat.completions.create(
model="gpt-6-sol",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)Questions
- Do old prefixed model IDs still work?
- Yes, prefixed IDs are still accepted for compatibility, but short IDs are recommended.
- Can I switch back?
- Yes. Nothing is locked in: change the base URL and key back and your code keeps working.
Related
- How to use the OpenAI SDK with a custom base URL
- What is a model ID?
- Migrate from the OpenAI API to TokenRex
- Migrate from the Anthropic API to TokenRex
- Migrate from the Google Gemini API to TokenRex
- Migrate from LangChain's ChatOpenAI default endpoint to TokenRex
- Migrate from the Vercel AI SDK OpenAI provider to TokenRex
- Migrate from several separate provider accounts to TokenRex
- Migrate from USD card billing to TokenRex