API Reference
The AI Token API is fully compatible with the OpenAI API specification. Use your existing OpenAI SDK code with just two configuration changes.
Authentication
All API requests require authentication via a Bearer token in the Authorization header.
Authorization: Bearer YOUR_API_KEY
Base URL
All API endpoints are relative to this base URL:
https://bb71d3f3506709ed-101-126-19-34.serveousercontent.com/v1
Request Format
All requests must include:
Content-Type: application/jsonheaderAuthorization: Bearer YOUR_API_KEYheader- JSON body with required parameters
Streaming
Set "stream": true in your request body to receive responses as Server-Sent Events (SSE). Each chunk contains a partial response in the same format as the non-streaming response.
stream = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
messages=[{"role": "user", "content": "Write a poem"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="")
Chat Completions
Creates a model response for the given chat conversation. This is the primary endpoint for most use cases.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Model ID to use. See model list for all available models. |
| messages | array | Required | A list of messages comprising the conversation. Each message has role (system/user/assistant) and content. |
| temperature | number | Optional | Sampling temperature (0-2). Higher = more random. Default: 1.0 |
| max_tokens | integer | Optional | Maximum number of tokens to generate. Default: model-specific. |
| top_p | number | Optional | Nucleus sampling parameter (0-1). Alternative to temperature. Default: 1.0 |
| stream | boolean | Optional | If true, stream response as Server-Sent Events. Default: false |
| stop | string/array | Optional | Stop sequences. Generation stops when these are encountered. |
| frequency_penalty | number | Optional | Penalize tokens based on frequency (-2 to 2). Default: 0 |
| presence_penalty | number | Optional | Penalize tokens based on presence (-2 to 2). Default: 0 |
Request Example
{
"model": "deepseek-ai/DeepSeek-V4-Pro",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"temperature": 0.7,
"max_tokens": 500
}
Response Example
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1699000000,
"model": "deepseek-ai/DeepSeek-V4-Pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 8,
"total_tokens": 32
}
}
Completions (Legacy)
Legacy text completion endpoint. For new applications, we recommend using Chat Completions instead.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Model ID |
| prompt | string/array | Required | The prompt(s) to generate completions for |
| max_tokens | integer | Optional | Maximum tokens to generate. Default: 16 |
| temperature | number | Optional | Sampling temperature (0-2). Default: 1.0 |
Request Example
curl https://bb71d3f3506709ed-101-126-19-34.serveousercontent.com/v1/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-ai/DeepSeek-V3",
"prompt": "Write a tagline for an AI startup:",
"max_tokens": 50
}'
Embeddings
Creates embedding vectors for the given input text. Useful for semantic search, RAG pipelines, clustering, and classification.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Embedding model ID (e.g., Qwen/Qwen3-Embedding-8B) |
| input | string/array | Required | Input text to embed. Can be a string or array of strings. |
| encoding_format | string | Optional | Format: float or base64. Default: float |
Request Example
response = client.embeddings.create(
model="Qwen/Qwen3-Embedding-8B",
input="The quick brown fox jumps over the lazy dog"
)
print(response.data[0].embedding[:5]) # First 5 dimensions
Response
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023, -0.0094, 0.0159, ...]
}
],
"model": "Qwen/Qwen3-Embedding-8B",
"usage": {
"prompt_tokens": 10,
"total_tokens": 10
}
}
List Models
Returns a list of all available models.
curl https://bb71d3f3506709ed-101-126-19-34.serveousercontent.com/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
Response
{
"object": "list",
"data": [
{
"id": "deepseek-ai/DeepSeek-V4-Pro",
"object": "model",
"created": 1699000000,
"owned_by": "deepseek"
},
...
]
}
Error Codes
The API uses standard HTTP status codes. Error responses include a JSON body with details.
| Code | Meaning | Description |
|---|---|---|
200 | Success | Request completed successfully. |
400 | Bad Request | Invalid request body or parameters. |
401 | Unauthorized | Invalid or missing API key. |
403 | Forbidden | API key does not have permission for this model. |
404 | Not Found | Model not found or endpoint doesn't exist. |
429 | Rate Limited | Too many requests. Wait and retry. |
500 | Server Error | Internal error. Retry with exponential backoff. |
502 | Bad Gateway | Upstream model provider error. Try another model. |
503 | Unavailable | Model temporarily unavailable. Retry later. |
Error Response Format
{
"error": {
"message": "Invalid API key provided.",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}
Rate Limits
Rate limits vary by plan and model:
| Plan | Requests/min | Tokens/min |
|---|---|---|
| Starter (Free) | 20 | 40,000 |
| Pro | 60 | 200,000 |
| Business | 200 | 1,000,000 |
| Enterprise | Custom | Custom |
X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers.
Response Format
All responses follow the OpenAI response format, ensuring compatibility with existing integrations.
Usage Object
Every response includes a usage object with token counts:
"usage": {
"prompt_tokens": 24,
"completion_tokens": 150,
"total_tokens": 174
}