Introduction
ttonkapi provides a unified API interface compatible with OpenAI's format. You can use existing OpenAI SDKs and tools without modification.
Base URL: https://ttonkapi.com/v1
Authentication
All API requests require authentication using a Bearer token. Get your API key from the Dashboard.
Authorization: Bearer ttonk_sk_xxxxxxxxxxxx
Chat Completions
Create a chat completion using any supported model.
Endpoint
POST /v1/chat/completions
Request
curl https://ttonkapi.com/v1/chat/completions \
-H "Authorization: Bearer ttonk_sk_xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-plus",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"max_tokens": 1000,
"temperature": 0.7
}'
Response
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1711353600,
"model": "qwen-plus",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 10,
"total_tokens": 30
}
}
Available Models
| Model | Provider | Use Case |
|---|---|---|
qwen-turbo |
Alibaba | Fast, cheap tasks |
qwen-plus |
Alibaba | Balanced performance |
qwen-max |
Alibaba | Complex reasoning |
deepseek-chat |
DeepSeek | General chat |
deepseek-reasoner |
DeepSeek | Reasoning tasks |
List Models
Get a list of all available models.
Endpoint
GET /v1/models
Response
{
"data": [
{
"id": "qwen-turbo",
"object": "model",
"created": 1711353600,
"owned_by": "qwen"
},
...
]
}
Image Generation
Coming soon...
Errors
| HTTP Code | Error Type | Description |
|---|---|---|
| 400 | invalid_request_error | Invalid request parameters |
| 401 | authentication_error | Invalid or missing API key |
| 402 | insufficient_quota | Not enough balance |
| 429 | rate_limit_error | Rate limit exceeded |
| 500 | server_error | Internal server error |
Rate Limits
| Plan | Requests/minute | Tokens/minute |
|---|---|---|
| Starter | 60 | 10,000 |
| Pro | 300 | 100,000 |
| Business | 1000 | Unlimited |
SDKs
Use official OpenAI SDKs with our API:
Python
from openai import OpenAI
client = OpenAI(
api_key="ttonk_sk_xxx",
base_url="https://ttonkapi.com/v1"
)
response = client.chat.completions.create(
model="qwen-plus",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
Node.js
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'ttonk_sk_xxx',
baseURL: 'https://ttonkapi.com/v1'
});
const response = await client.chat.completions.create({
model: 'qwen-plus',
messages: [{ role: 'user', content: 'Hello!' }]
});
console.log(response.choices[0].message.content);