Docs
Dokumentasi developer
AITREE kompatibel dengan API OpenAI. Untuk sebagian besar SDK, Anda cukup mengganti base_url dan api_key.
Autentikasi
Kirim Bearer token di header Authorization. Buat dan kelola kunci di konsol.
Authorization: Bearer $AITREE_API_KEYChat completions
Parameter sama dengan OpenAI /v1/chat/completions, termasuk streaming.
curl https://aitree.ai/v1/chat/completions \
-H "Authorization: Bearer $AITREE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash-0731",
"stream": true,
"messages": [{ "role": "user", "content": "用一句话解释什么是算力中转站" }]
}'Anthropic Messages
Model Claude juga mendukung protokol Anthropic native: arahkan base_url SDK resmi ke AITREE (tanpa /v1) dan gunakan kunci API yang sama.
import anthropic
client = anthropic.Anthropic(base_url="https://aitree.ai", api_key="YOUR_AITREE_KEY")
msg = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)Pembuatan gambar
Sama seperti OpenAI /v1/images/generations; mengembalikan URL gambar. Ditagih per panggilan atau per token, tergantung modelnya.
curl https://aitree.ai/v1/images/generations \
-H "Authorization: Bearer $AITREE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-5-0-260128",
"prompt": "a glowing compute tree at night, cinematic",
"size": "1024x1024"
}'Pembuatan video
Video berjalan sebagai tugas asinkron: POST /v1/video/generations mengembalikan task_id; lakukan polling GET /v1/video/generations/{id} hingga status bernilai succeeded untuk mendapatkan URL video.
# 1. submit
curl https://aitree.ai/v1/video/generations \
-H "Authorization: Bearer $AITREE_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "doubao-seedance-2-0-fast-260128", "prompt": "drone shot through a forest of light", "seconds": "5" }'
# 2. poll until status is "succeeded"
curl https://aitree.ai/v1/video/generations/$TASK_ID \
-H "Authorization: Bearer $AITREE_API_KEY"Daftar model
Temukan model yang saat ini tersedia untuk kunci Anda.
curl https://aitree.ai/v1/models \
-H "Authorization: Bearer $AITREE_API_KEY"Kunci dan keamanan
Setiap kunci dapat diberi batas pengeluaran, masa berlaku, daftar izin model, dan daftar izin IP. Jika kunci bocor, nonaktifkan di konsol lalu buat kunci baru.
Kesalahan
Respons error mengikuti format OpenAI; error.type menunjukkan asalnya.
{
"error": {
"message": "insufficient user quota",
"type": "new_api_error",
"code": "insufficient_user_quota"
}
}Kompatibilitas
Berfungsi dengan SDK resmi OpenAI, LangChain, LlamaIndex, Cherry Studio, Open WebUI, Cursor, dan aplikasi lain yang mendukung base_url kustom.