Back to Blog

Migrate from OpenAI to Token Hacker in 5 Minutes

Why Migrate?

If you're using the OpenAI API directly, you're overpaying and limiting yourself to one provider's models. Token Hacker gives you the exact same API interface — OpenAI-compatible — but with access to 200+ models from every major provider, at prices typically 20-50% lower. Same code, more choice, less money. Here's how to make the switch in under five minutes.

Step 1 — Get Your API Key

Head to aiapisave.xyz and sign up. GitHub OAuth means no email verification, no waiting. Once logged in, go to your dashboard and copy your API key. It looks like this: th-sk-xxxxxxxxxxxxxxxxxxxxxxxx.

Top up your balance via Stripe (credit card) or USDT-TRC20. Any amount works — there's no minimum. Your balance never expires.

Step 2 — Change Two Lines

The migration is literally two changes in your code:

  1. Base URL: Change from https://api.openai.com/v1 to https://api.aiapisave.xyz/v1
  2. API Key: Replace your OpenAI key with your Token Hacker key (starts with th-sk-)

That's it. Every OpenAI-compatible library, SDK, and tool works unchanged. The request and response formats are identical.

Step 3 — Code Examples

Python

Before (OpenAI):

from openai import OpenAI

client = OpenAI(api_key="sk-...")

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

After (Token Hacker):

from openai import OpenAI

client = OpenAI(
    api_key="th-sk-your-key-here",
    base_url="https://api.aiapisave.xyz/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",  # Same model name — or try "claude-sonnet-4", "deepseek-v4"
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

Node.js

Before (OpenAI):

import OpenAI from 'openai';

const openai = new OpenAI({ apiKey: 'sk-...' });

const response = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(response.choices[0].message.content);

After (Token Hacker):

import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: 'th-sk-your-key-here',
  baseURL: 'https://api.aiapisave.xyz/v1',
});

const response = await openai.chat.completions.create({
  model: 'claude-sonnet-4',  // Try any model!
  messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(response.choices[0].message.content);

cURL

Before (OpenAI):

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-..." \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello!"}]}'

After (Token Hacker):

curl https://api.aiapisave.xyz/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer th-sk-your-key-here" \
  -d '{"model":"deepseek-v4","messages":[{"role":"user","content":"Hello!"}]}'

Advanced: Multi-Model Routing

Once you're on Token Hacker, you can build intelligent model routing. Here's a Python example that picks the best model based on task type:

from openai import OpenAI

client = OpenAI(
    api_key="th-sk-your-key-here",
    base_url="https://api.aiapisave.xyz/v1"
)

def smart_chat(prompt, task_type="general"):
    model_map = {
        "coding": "claude-sonnet-4",
        "reasoning": "claude-opus-4",
        "creative": "claude-opus-4",
        "fast": "deepseek-v4",
        "vision": "gpt-5.4",
        "general": "gpt-4o",
    }
    model = model_map.get(task_type, "gpt-4o")
    return client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": prompt}]
    )

# Same client, different models — all through one API key
code_review = smart_chat("Review this function for bugs", "coding")
analysis = smart_chat("Analyze this market trend", "reasoning")
quick_answer = smart_chat("What's 2+2?", "fast")

What About My Existing Code?

Short answer: it works. Token Hacker implements the full OpenAI chat completions API, including:

  • Streaming responses (SSE)
  • Function calling / tool use
  • JSON mode and structured outputs
  • System messages and multi-turn conversations
  • Temperature, top_p, max_tokens, and all standard parameters
  • Vision (image inputs via base64 or URL)

Libraries like LangChain, LlamaIndex, Vercel AI SDK, and continue.dev all work without modification. Just point them at Token Hacker's base URL.

Common Questions

Q: Is the response format identical?
Yes. The JSON response structure matches OpenAI's exactly. choices[0].message.content, usage.prompt_tokens, usage.completion_tokens — all the same fields in the same places.

Q: What about streaming?
Fully supported. SSE streaming works identically. All streaming clients (including browser-based ones) work without changes.

Q: Will my rate limits change?
Token Hacker provides generous default rate limits. If you need higher limits, reach out through the dashboard — we're happy to accommodate production workloads.

Q: Can I still use OpenAI models?
Yes! GPT-4o, GPT-5.4, and all OpenAI models are available through Token Hacker. You get the same models, often at better prices, plus access to every other provider's models through the same key.

Q: What if something goes wrong?
Token Hacker provides detailed error responses in the same format as OpenAI, plus a dashboard with real-time usage monitoring. Support is available via the website.