Skip to content

cURL examples

Direct HTTP calls are useful for debugging. For production applications, prefer an SDK — see Python, JavaScript, or the OpenAI SDK examples — and store the key in CLOUDSERVICE_API_KEY.

This page uses the OpenAI-compatible route: API credit uses https://api.yourdomain.example/v1, while API-token keys use https://api.yourdomain.example/token/v1. A Claude token key must use a Claude model from its catalog. For native Anthropic Messages requests, use the origin-only route in the Claude Code or Claude Desktop guide.

Set your key

bash
export CLOUDSERVICE_API_KEY="your-scale-max-key"

# API-credit key:
export CLOUDSERVICE_BASE_URL="https://api.yourdomain.example/v1"
# API-token key used through this OpenAI-compatible example:
# export CLOUDSERVICE_BASE_URL="https://api.yourdomain.example/token/v1"

export CLOUDSERVICE_AUTH_HEADER="Authorization: Bearer $CLOUDSERVICE_API_KEY"

List models

models.sh
curl "$CLOUDSERVICE_BASE_URL/models" \
  -H "$CLOUDSERVICE_AUTH_HEADER"

Chat completion

chat.sh
curl "$CLOUDSERVICE_BASE_URL/chat/completions" \
  -H "$CLOUDSERVICE_AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_AUTHENTICATED_MODEL_ID",
    "messages": [{"role":"user","content":"Say hello from CloudService."}]
  }'

Streaming

stream.sh
curl -N "$CLOUDSERVICE_BASE_URL/chat/completions" \
  -H "$CLOUDSERVICE_AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_AUTHENTICATED_MODEL_ID",
    "stream": true,
    "messages": [{"role":"user","content":"Stream a short greeting."}]
  }'