Quick Start
Step 1: Get Your API Key
Sign up and log in at 1688token.ai. Go to the Tokens page and create an API Key.
Include it in every request via the HTTP header:
Authorization: Bearer <your-api-key>Step 2: Set the Base URL
1688token.ai is fully compatible with the OpenAI API format. All endpoints use the following base URL:
https://1688token.ai/v1Just replace base_url in your existing code and you're done.
Step 3: Install the SDK
bash
pip install openaibash
npm install openaiStep 4: Send Your First Request
python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://1688token.ai/v1"
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a professional AI assistant."},
{"role": "user", "content": "Hello! Introduce yourself."}
]
)
print(response.choices[0].message.content)javascript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://1688token.ai/v1"
});
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "system", content: "You are a professional AI assistant." },
{ role: "user", content: "Hello! Introduce yourself." }
]
});
console.log(response.choices[0].message.content);bash
curl https://1688token.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{"role": "system", "content": "You are a professional AI assistant."},
{"role": "user", "content": "Hello! Introduce yourself."}
]
}'Step 5: Common Endpoints
| Endpoint | Method | Description |
|---|---|---|
/v1/chat/completions | POST | Chat completion (supports streaming) |
/v1/models | GET | List available models |
Error Handling
When a request fails, the response body looks like:
json
{
"error": {
"message": "Invalid API key",
"type": "authentication_error",
"code": "invalid_api_key"
}
}Common HTTP status codes:
| Status | Meaning | Action |
|---|---|---|
401 | Invalid or missing API Key | Check your Authorization header |
403 | Insufficient permissions or balance | Check account balance and Key permissions |
429 | Rate limit exceeded | Reduce request frequency or contact support |
500 | Internal server error | Retry after a moment |
Rate Limits
| Limit | Description |
|---|---|
| Request rate | Varies by account tier; returns 429 when exceeded |
| Max tokens | Depends on the selected model's context window |
| Response timeout | Set client timeout to 60s; relax for streaming requests |
