Skip to content

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/v1

Just replace base_url in your existing code and you're done.

Step 3: Install the SDK

bash
pip install openai
bash
npm install openai

Step 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

EndpointMethodDescription
/v1/chat/completionsPOSTChat completion (supports streaming)
/v1/modelsGETList 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:

StatusMeaningAction
401Invalid or missing API KeyCheck your Authorization header
403Insufficient permissions or balanceCheck account balance and Key permissions
429Rate limit exceededReduce request frequency or contact support
500Internal server errorRetry after a moment

Rate Limits

LimitDescription
Request rateVaries by account tier; returns 429 when exceeded
Max tokensDepends on the selected model's context window
Response timeoutSet client timeout to 60s; relax for streaming requests