Skip to content

cURL examples

On this page · 5 sections

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 SCALEMAX_API_KEY.

This page uses the OpenAI-compatible route: API credit uses https://api.scalemax.pro/v1, while API-token keys use https://api.scalemax.pro/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.

Every example has a macOS/Linux and a Windows PowerShell version. Pick yours once; the page remembers it.

Set your key

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

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

export SCALEMAX_AUTH_HEADER="Authorization: Bearer $SCALEMAX_API_KEY"

List models

models.sh
curl "$SCALEMAX_BASE_URL/models" \
  -H "$SCALEMAX_AUTH_HEADER"

Chat completion

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

Streaming

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

Windows PowerShell

The macOS/Linux commands do not work as typed in PowerShell. The Windows tabs above already account for this:

  • Type curl.exe, not curl. In Windows PowerShell 5.1, curl runs a different command (Invoke-WebRequest) that rejects these options.
  • Put the JSON body in a file and send the file: curl.exe … --data-binary "@body.json". PowerShell strips the double quotes inside a -d '{…}' argument, and ScaleMax then answers 400 with “Request body is not valid JSON”. Keep the quotes around "@body.json": a bare @ means something else in PowerShell.
  • Set variables with $env:NAME = "value" (this window only) or setx NAME "value" (new windows only — open a new terminal after setx).
  • End a continued line with a backtick (`), not a backslash.

Command Prompt (cmd.exe) has the same quoting problem; use PowerShell with the commands above.