API Quickstart
info
The page and service rules are subject to the current Console.
First, confirm these three things
- Create an API key on the API Console "Tokens" page, and note which group the key belongs to.
- Get the current full model IDs from the Model Marketplace or
/v1/models. - The Base URL is fixed at
https://llmapi.cttai.art/v1(OpenAI-compatible).
The examples below use the local environment variable CTTAI_API_KEY — never commit a real key into your repository.
Query models visible to your key
curl https://llmapi.cttai.art/v1/models \
-H "Authorization: Bearer $CTTAI_API_KEY"
The model list shows what is currently visible; the exact protocol, modality, and real-time availability are subject to the model description.
Minimal Chat Completions request
Replace YOUR_AVAILABLE_MODEL with a full model ID that supports this protocol.
curl https://llmapi.cttai.art/v1/chat/completions \
-H "Authorization: Bearer $CTTAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_AVAILABLE_MODEL",
"messages": [{"role": "user", "content": "Please just reply OK"}]
}'
This request may incur a small cost. After success, confirm the model and usage in the Console "Usage Logs".
SDK examples
Node.js (OpenAI SDK)
npm install openai
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.CTTAI_API_KEY,
baseURL: 'https://llmapi.cttai.art/v1',
});
const result = await client.chat.completions.create({
model: process.env.CTTAI_MODEL,
messages: [{role: 'user', content: 'Please just reply OK'}],
});
console.log(result.choices[0].message.content);
Python (OpenAI SDK)
python -m pip install openai
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ['CTTAI_API_KEY'],
base_url='https://llmapi.cttai.art/v1',
)
result = client.chat.completions.create(
model=os.environ['CTTAI_MODEL'],
messages=[{'role': 'user', 'content': 'Please just reply OK'}],
)
print(result.choices[0].message.content)
Streaming
Add "stream": true to the request body to receive an SSE stream:
data: {"id":"chatcmpl-...","choices":[{"delta":{"content":"Hello"},"index":0}]}
data: [DONE]
Pre-launch checklist
- Use a dedicated key with its own budget and confirm group permissions.
- Handle connection, read, and business timeouts; for long tasks, check status first and avoid duplicate submissions.
- Use bounded retry with backoff for transient 429 / 5xx; never blindly retry auth or parameter errors.
- Log time, model, request id / task id, and the error body; never store a full key in logs.
- Actual costs are subject to the Console usage logs and billing rules.
Other models
- Judgement models (non-chat protocol): see Jev Model Integration