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
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"$env:SCALEMAX_API_KEY = "your-scale-max-key"
# API-credit key:
$env:SCALEMAX_BASE_URL = "https://api.scalemax.pro/v1"
# API-token key used through this OpenAI-compatible example:
# $env:SCALEMAX_BASE_URL = "https://api.scalemax.pro/token/v1"
$env:SCALEMAX_AUTH_HEADER = "Authorization: Bearer $env:SCALEMAX_API_KEY"List models
curl "$SCALEMAX_BASE_URL/models" \
-H "$SCALEMAX_AUTH_HEADER"curl.exe "$env:SCALEMAX_BASE_URL/models" `
-H "$env:SCALEMAX_AUTH_HEADER"Chat completion
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."}]
}'@'
{
"model": "YOUR_AUTHENTICATED_MODEL_ID",
"messages": [{"role": "user", "content": "Say hello from ScaleMax."}]
}
'@ | Set-Content -Path body.json
curl.exe "$env:SCALEMAX_BASE_URL/chat/completions" `
-H "$env:SCALEMAX_AUTH_HEADER" `
-H "Content-Type: application/json" `
--data-binary "@body.json"Streaming
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."}]
}'@'
{
"model": "YOUR_AUTHENTICATED_MODEL_ID",
"stream": true,
"messages": [{"role": "user", "content": "Stream a short greeting."}]
}
'@ | Set-Content -Path body.json
curl.exe -N "$env:SCALEMAX_BASE_URL/chat/completions" `
-H "$env:SCALEMAX_AUTH_HEADER" `
-H "Content-Type: application/json" `
--data-binary "@body.json"Windows PowerShell
The macOS/Linux commands do not work as typed in PowerShell. The Windows tabs above already account for this:
- Type
curl.exe, notcurl. In Windows PowerShell 5.1,curlruns 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 answers400with “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) orsetx NAME "value"(new windows only — open a new terminal aftersetx). - 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.