API Documentation
Everything you need to integrate Token Hacker into your application.
Quick Start
Get your first AI response in under 5 minutes.
1. Get your API key
Sign up with GitHub OAuth — no email verification, no waiting. Your API key is ready instantly on the Dashboard.
2. Install the OpenAI SDK
Token Hacker is fully OpenAI-compatible. Use any existing OpenAI SDK — Python, Node.js, or any language with an OpenAI client library.
3. Make your first request
Set the base URL to Token Hacker, use your API key, and pick a model. That's it — your existing OpenAI code works unchanged.
Python
from openai import OpenAI
client = OpenAI(
base_url="https://api.aiapisave.xyz/v1",
api_key="sk-your-api-key",
)
response = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[
{"role": "user", "content": "Hello, world!"}
],
)
print(response.choices[0].message.content)Node.js
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.aiapisave.xyz/v1',
apiKey: 'sk-your-api-key',
});
const response = await client.chat.completions.create({
model: 'openai/gpt-4o-mini',
messages: [
{ role: 'user', content: 'Hello, world!' }
],
});
console.log(response.choices[0].message.content);cURL
curl https://api.aiapisave.xyz/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-api-key" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello, world!"}]
}'Streaming (Python)
from openai import OpenAI
client = OpenAI(
base_url="https://api.aiapisave.xyz/v1",
api_key="sk-your-api-key",
)
# Enable streaming with stream=True
stream = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Tell me a short story"}],
stream=True,
)
# Print each token as it arrives
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")Streaming (Node.js)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.aiapisave.xyz/v1',
apiKey: 'sk-your-api-key',
});
const stream = await client.chat.completions.create({
model: 'openai/gpt-4o-mini',
messages: [{ role: 'user', content: 'Tell me a short story' }],
stream: true,
});
// Print each token as it arrives
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}Authentication
All API requests require authentication via Bearer token in the Authorization header. Keep your API key secure — never expose it in client-side code or public repositories.
| Base URL | https://api.aiapisave.xyz/v1 |
| Authorization Header | Authorization: Bearer sk-your-api-key |
| Content-Type Header | application/json |
Get your API key from the Dashboard.
Model Reference
Token Hacker supports 200+ models across all major providers — OpenAI, Anthropic, Google, DeepSeek, Meta, Mistral, and more. Browse the complete catalog on the Models page.
Model IDs follow the pattern provider/model-name. Use this format in the model parameter of your API requests.
| Provider | Format | Example |
|---|---|---|
| OpenAI | openai/model | openai/gpt-4o |
| Anthropic | anthropic/model | anthropic/claude-sonnet |
google/model | google/gemini-pro | |
| DeepSeek | deepseek/model | deepseek/deepseek-v4 |
| Meta | meta/model | meta/llama-4-maverick |
Visit the Models page for pricing, context windows, and capabilities for each model.
Streaming
Stream responses token-by-token for real-time output. All models support Server-Sent Events (SSE) streaming — set stream: true in your request and iterate over the response chunks. Streaming dramatically improves perceived latency for user-facing applications.
Python
from openai import OpenAI
client = OpenAI(
base_url="https://api.aiapisave.xyz/v1",
api_key="sk-your-api-key",
)
# Enable streaming
stream = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Write a haiku about coding"}],
stream=True,
)
# Collect the full response while printing in real-time
full_response = ""
for chunk in stream:
delta = chunk.choices[0].delta
if delta.content:
print(delta.content, end="", flush=True)
full_response += delta.content
print() # final newlineNode.js
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.aiapisave.xyz/v1',
apiKey: 'sk-your-api-key',
});
const stream = await client.chat.completions.create({
model: 'openai/gpt-4o-mini',
messages: [{ role: 'user', content: 'Write a haiku about coding' }],
stream: true,
});
// Collect the full response while printing in real-time
let fullResponse = '';
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content || '';
process.stdout.write(content);
fullResponse += content;
}
console.log(); // final newlineFunction Calling
Let models call your functions to access external data, APIs, and tools. Token Hacker supports the full OpenAI function calling / tool use API. Define your tools, send them with the request, and the model will return structured function call arguments when needed.
Python
from openai import OpenAI
import json
client = OpenAI(
base_url="https://api.aiapisave.xyz/v1",
api_key="sk-your-api-key",
)
# Define a weather function tool
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name, e.g. San Francisco"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "Temperature unit"
}
},
"required": ["city"]
}
}
}]
# Model decides whether to call the function
response = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
tools=tools,
tool_choice="auto",
)
msg = response.choices[0].message
if msg.tool_calls:
for tool_call in msg.tool_calls:
func_name = tool_call.function.name
func_args = json.loads(tool_call.function.arguments)
print(f"Calling {func_name} with {func_args}")
# Call your actual function here
# result = your_weather_function(**func_args)
else:
print(msg.content)Rate Limits
Rate limits depend on your account tier and current balance. Standard accounts have the following default limits:
- Requests per minute: 60 RPM
- Tokens per minute: 100K TPM
- Concurrent requests: 10
When a rate limit is exceeded, the API returns HTTP 429 Too Many Requests. Implement exponential backoff with jitter to handle this gracefully. Higher-tier team accounts get increased limits.
import time
import random
def call_with_retry(client, max_retries=5, **kwargs):
"""Call the API with exponential backoff on rate limits."""
for attempt in range(max_retries):
try:
return client.chat.completions.create(**kwargs)
except Exception as e:
if "429" in str(e):
# Exponential backoff with jitter
delay = (2 ** attempt) + random.uniform(0, 1)
print(f"Rate limited. Retrying in {delay:.1f}s...")
time.sleep(delay)
continue
raise
raise Exception(f"Failed after {max_retries} retries")Error Handling
The API returns standard HTTP status codes. Here are the most common ones and how to handle them:
| Code | Meaning |
|---|---|
401 | Invalid or missing API key — check your Authorization header |
402 | Insufficient balance — top up your account to continue |
429 | Rate limit exceeded — slow down and implement backoff |
500 | Internal server error — retry with exponential backoff |
503 | Model temporarily unavailable — try again or switch models |
Frequently Asked Questions
Is the API OpenAI-compatible?
Yes, fully. Token Hacker implements the complete OpenAI chat completions API. Any library or SDK built for OpenAI works out of the box — just change the base_url to https://api.aiapisave.xyz/v1 and use your Token Hacker API key.
Does my balance expire?
No. Your prepaid balance never expires. Top up any amount and use it whenever you need — there is no monthly minimum, no subscription, and no auto-renewal to worry about.
What payment methods are accepted?
We accept credit and debit cards (Visa, Mastercard) via Stripe, and USDT-TRC20 for cryptocurrency payments. Your balance is credited instantly after payment confirmation.
Do you log my prompts or model outputs?
No. We do not log, store, or train on your prompts or model responses. Your data stays yours — we are a passthrough API, not a data platform.
Can I get a refund on unused balance?
Prepaid balances are non-refundable. We recommend starting with a small top-up ($5) to test the service and confirm it meets your needs before committing larger amounts.
How do I stream responses?
Set stream: true in your API request. The server responds with Server-Sent Events (SSE), delivering each token as it is generated. All OpenAI-compatible streaming clients work without modification. See the Streaming section above for code examples.
What happens when I hit a rate limit?
The API returns HTTP 429 Too Many Requests. You should implement exponential backoff with jitter — wait 1s, then 2s, 4s, 8s (plus random jitter) before retrying. Team accounts get higher rate limits.
Can I use Token Hacker with LangChain or Vercel AI SDK?
Absolutely. Both LangChain and Vercel AI SDK support OpenAI-compatible endpoints natively. Set openai_api_base (LangChain) or baseURL (Vercel AI SDK) to https://api.aiapisave.xyz/v1, provide your Token Hacker API key, and everything works as expected.