API Documentation
Get started with TokenProxy API in minutes.
Quick Start
To use the TokenProxy API, you need an API key which you'll receive after purchasing a token pack.
curl -X POST https://api.tokener.top/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Authentication
All API requests require your API key to be included in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Never share your API key publicly or commit it to version control.
Endpoints
POST /v1/chat/completions
Send a chat completion request.
Request Body
{
"model": "gpt-4", // required (gpt-4, gpt-3.5-turbo, etc.)
"messages": [ // required
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"temperature": 0.7, // optional, default 0.7
"max_tokens": 1000 // optional, default 4096
}
GET /v1/models
List available models.
curl https://api.tokener.top/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
Code Examples
Python
import requests
api_key = "YOUR_API_KEY"
url = "https://api.tokener.top/v1/chat/completions"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
data = {
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hello!"}]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript (Node.js)
const response = await fetch('https://api.tokener.top/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-4',
messages: [{role: 'user', content: 'Hello!'}]
})
});
const data = await response.json();
console.log(data);
Error Handling
The API returns standard HTTP status codes:
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid API key |
| 429 | Rate limit exceeded |
| 500 | Server error - Try again later |