เริ่มต้นใช้งาน

เริ่มต้นใช้งาน

Call multiple models with one key through OpenAI- and Anthropic-compatible APIs. This page covers authentication, streaming, model selection and error handling.

รองรับ OpenAI SDK · Anthropic SDK · cURL

ขั้นที่ 1 — สมัครสมาชิกและรับเครดิตฟรี

ขั้นที่ 2 — สร้าง API Key

ขั้นที่ 3 — ตั้งค่า base URL ของคุณ

base URL ที่รองรับ OpenAI https://aaa.ashp.tw/v1
base URL ที่รองรับ Anthropic https://aaa.ashp.tw/v1/anthropic

ขั้นที่ 4 — ส่งคำขอแรกของคุณ

cURL curl https://aaa.ashp.tw/v1/chat/completions \ -H "Authorization: Bearer $AAA_TOKEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "messages": [{"role": "user", "content": "Hello!"}] }'

ส่ง API key ของคุณเอง (ขึ้นต้นด้วย sk-) เป็น Bearer token ในส่วนหัว Authorization

รับ API Key ของคุณ ตัวอย่าง →

API reference

Authentication

Every request must include your API key (it starts with sk-). On OpenAI-compatible endpoints, send it in the Authorization: Bearer header; on Anthropic-compatible endpoints you can also use the x-api-key header. Keep your key secret and never put it in client-side code or public repositories.

HTTP Header Authorization: Bearer $AAA_TOKEN_API_KEY

Streaming

Add stream: true to your request to receive output incrementally over Server-Sent Events (SSE), which suits chat interfaces and long responses. Streaming is supported on both the OpenAI-compatible /v1/chat/completions and the Anthropic-compatible /v1/messages.

Models and pricing

Set the model field of your request to a model name, such as claude-sonnet-4-6 or gpt-5.4. See the pricing page for available models and their per-million-token prices.

ดูราคา →

Error codes

HTTPType
401The API key is missing, invalid or has been revoked. Check that your key is correct.
402Insufficient balance. Top up your account and try again.
404The requested path or model was not found. Check the base URL, the path and the model name.
429Too many requests: a rate limit was hit. Wait a moment and retry with exponential backoff.
500+A temporary error or timeout occurred at the upstream model provider. Retry shortly; if it persists, contact [email protected].

Video generation API (Seedance)

Generate AI video with the same API key. Creating a task returns a task ID immediately; poll it with GET until it returns the video URL. The native Ark path /v1/contents/generations/tasks is also supported.

Create a video task curl https://aaa.ashp.tw/v1/videos/generations \ -H "Authorization: Bearer $AAA_TOKEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "doubao-seedance-1-5-pro-251215", "content": [{"type": "text", "text": "A golden dragon flying over a neon city at night"}], "resolution": "720p", "duration": 5, "ratio": "16:9" }'
Poll the task (every ~5 seconds) curl https://aaa.ashp.tw/v1/videos/generations/vid_xxxxxxxxxxxxxxxxxxxxxxxx \ -H "Authorization: Bearer $AAA_TOKEN_API_KEY"

Billing: you are charged only when the video succeeds — cost = video tokens × model price, where video tokens ≈ width × height × fps × seconds ÷ 1024. Failed or cancelled tasks are free. Video URLs expire after about 24 hours, so download promptly.

Per-key limits

Each API key can have its own total and daily spend caps, model allowlist, IP allowlist, expiry and requests-per-minute limit, set in your dashboard — so you can safely hand keys to teammates, clients or servers. When a limit is hit you get:

HTTPType
401key_expired — the key has expired
402key_spend_limit — the key reached its total spend cap
403model_not_allowed / ip_not_allowed — the model or source IP is not on the key’s allowlist
429key_daily_limit / key_rate_limit — the daily spend cap or per-minute limit was reached

Set key limits →

Model list

GET /v1/models returns every model currently available (OpenAI format), ready for tools like Cursor and Cline.

GET curl https://aaa.ashp.tw/v1/models -H "Authorization: Bearer $AAA_TOKEN_API_KEY"

More resources

สมัครสมาชิกรับเครดิตฟรี $1