はじめに
クイックスタート
3 ステップで最初の呼び出しを成功させましょう。どの例も現在稼働中のモデルを使っています。
#AI エージェントに組み込ませる
Claude Code、Cursor、Codex をお使いですか?このプロンプトを貼り付けると、API の完全な仕様を読み、クライアント・リトライ・タスクのポーリングを書いてくれます。
プロンプトを表示
Please integrate the APIKing API into this project.
Read these two documents first and implement what they say; do not assume OpenAI defaults:
- Full API contract: https://apiking.ai/llms-full.txt
- OpenAPI spec: https://apiking.ai/openapi.json
Basics
- Base URL: https://apiking.ai/v1, OpenAI-compatible. Use the official OpenAI SDK and change only base_url and the key.
- Anthropic SDK / Claude Code: base URL https://apiking.ai; the endpoint is /v1/messages.
- Auth: Authorization: Bearer <key>. Read the key from the APIKING_API_KEY environment variable. Never hard-code or commit it, and never ship it in a browser or app bundle.
- Do not guess model IDs: call GET /v1/models and pick from what it returns. Ask me when unsure.
Pick the endpoint by task
- Chat: POST /v1/chat/completions (or /v1/responses); Anthropic format: POST /v1/messages.
- Images, video, music and 3D are async tasks: submit, get a task_id, then poll its status.
- Image, music, 3D: queued → processing → succeeded / failed.
- Video: queued → in_progress → completed / failed.
- unknown is not terminal: poll until a deadline, then reconcile. Never treat it as success.
- You can pass webhook_url at submit instead, but the status endpoint stays the source of truth.
- Balance: GET /v1/balance, free and not billed.
Errors and retries
- Errors look like {"error":{"message","type","code"}}; branch on code.
- Every response carries X-Oneapi-Request-Id. Log it; support asks for it.
- 429: wait Retry-After, then retry. 5xx: retry with exponential backoff. Other 4xx: do not retry.
- Send an Idempotency-Key on paid non-streaming writes (task submits above all) and reuse it on retries, so a retry is never charged twice. Streaming requests must not carry it.
Deliver
1. A client module that wraps the retries, idempotency keys and task polling above.
2. One minimal example that runs as is.
3. A README note on setting APIKING_API_KEY.
Ask me before running anything that makes a paid request.または Agent Skill としてインストールすれば、毎回のセッションで APIKing を理解した状態になります:
Claude Code のみ(Node 不要):
#1. API キーを作成
キーは一度しか表示されません。Web ページではなく、サーバーに保管してください。
API キーを作成すべてのリクエストの送信先:
#2. リクエストをコピー
YOUR_API_KEY を自分のキーに置き換えて実行します。
API_KEY="${API_KEY:-YOUR_API_KEY}"
curl --fail-with-body -sS https://apiking.ai/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "GPT-5.6 Luna",
"messages": [
{
"role": "user",
"content": "Say hello."
}
],
"stream": false
}'すでに OpenAI SDK を使っていますか?
変更するのは base_url と api_key だけです。既存のクライアント、メッセージ形式、ストリーミングのパーサー、再試行のラッパーはそのまま使えます。
#3. 応答を確認
このような 200 の応答が返れば接続できています。
response.json
{
"id": "chatcmpl_xxx",
"choices": [
{
"message": {
"role": "assistant",
"content": "Hello!"
}
}
]
}まだ解決しませんか?
リクエスト ID かエラーメッセージを送っていただければ、こちらで調査します。