Migrate from the Anthropic API to TokenRex
Keep using the Anthropic SDK for Claude, or switch to the OpenAI format to reach every model.
Steps
- Create a TokenRex API key.
- Set the Anthropic client's base URL to https://tokenrex.ai/api/public.
- Keep your Claude model calls as they are, or switch to the OpenAI SDK to use GPT and Gemini too.
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
import anthropic
client = anthropic.Anthropic(api_key="YOUR_TOKENREX_KEY", base_url="https://tokenrex.ai/api/public")Questions
- 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 OpenRouter 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