
Migrate from OpenAI to TokenRex in 5 minutes
A step-by-step migration guide. Zero code changes beyond the base_url and key.
If your code already uses the OpenAI SDK, migration is a two-line change. Nothing else has to move.
Step 1 — Get a key#
Sign up at tokenrex.ai/auth, top up any amount, and generate a key from the dashboard.
Step 2 — Swap two lines#
diff
- client = OpenAI(api_key="sk-...")
+ client = OpenAI(
+ api_key="YOUR_TOKENREX_API_KEY",
+ base_url="https://tokenrex.ai/api/public/v1",
+ )Step 3 — Update the model name#
Model IDs on TokenRex are provider-prefixed. gpt-5.4-mini becomes gpt-5.4-mini. See the models catalog.
Streaming, tool calls, JSON mode, and vision inputs all work unchanged. If it worked against api.openai.com, it works here.
Rollback plan#
Change the two lines back. There is no lock-in and no proprietary shape.
Models in this article
Review current prices, specifications and source-linked benchmarks.
Build this with TokenRex
TokenRex is an LLM marketplace by Asirex Labs. Choose an enabled model, create a private API key and use the supported endpoint shown in Docs. Check live prices before your first request.