cURL
すべてのエンドポイントに対応する、依存関係のない例。デバッグやCIチェックに役立ちます。
モデル一覧の取得
curl https://aiprimetech.io/v1/models \
-H "Authorization: Bearer $CLAUDEAPIKEY"
Messages
curl https://aiprimetech.io/v1/messages \
-H "x-api-key: $CLAUDEAPIKEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"system": "Be concise.",
"messages": [{"role": "user", "content": "What is a CDN?"}]
}'
Chat Completions
curl https://aiprimetech.io/v1/chat/completions \
-H "Authorization: Bearer $CLAUDEAPIKEY" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"messages": [
{"role": "system", "content": "Be concise."},
{"role": "user", "content": "What is a CDN?"}
]
}'
ストリーミング
curl -N https://aiprimetech.io/v1/messages \
-H "x-api-key: $CLAUDEAPIKEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-6","max_tokens":512,"stream":true,
"messages":[{"role":"user","content":"Count to five"}]}'
-N は curl 自体のバッファリングを無効にします。これがないとストリーム全体が一度に表示され、ストリーミングが機能していないように見えます。
CI でのヘルスチェック
"c">#!/usr/bin/env bash
set -euo pipefail
code=$(curl -s -o /dev/null -w "%{http_code}" https://aiprimetech.io/v1/models \
-H "Authorization: Bearer $CLAUDEAPIKEY")
[ "$code" = "200" ] || { echo "gateway check failed: $code" >&2; exit 1; }
echo "gateway ok"