Menu: curl

Guides

curl

Call the gateway and your endpoints from the command line.

export SCALAIX_API_KEY="sx_..."

List models

curl -s https://www.scalaix.com/v1/models \
  -H "Authorization: Bearer $SCALAIX_API_KEY" | jq '.data[].id'

Chat completion

curl -s https://www.scalaix.com/v1/chat/completions \
  -H "Authorization: Bearer $SCALAIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Say hi in Portuguese."}]
  }' | jq -r '.choices[0].message.content'

See the Scalaix headers

curl -s -D - -o /dev/null https://www.scalaix.com/v1/chat/completions \
  -H "Authorization: Bearer $SCALAIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "auto", "messages": [{"role": "user", "content": "ping"}]}' | grep -i x-scalaix
x-scalaix-request-id: req_5b1e0c9a77
x-scalaix-model: gpt-4o-mini
x-scalaix-cache: miss
x-scalaix-fallbacks: 0

Stream

curl -N https://www.scalaix.com/v1/chat/completions \
  -H "Authorization: Bearer $SCALAIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-4o-mini", "stream": true, "messages": [{"role": "user", "content": "Count to 3"}]}'

Skip the cache

curl https://www.scalaix.com/v1/chat/completions -H "X-Scalaix-Cache: off" ...

Call a published endpoint

curl -s https://www.scalaix.com/acme/support/classify-ticket \
  -H "Authorization: Bearer $SCALAIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inputs": {"ticket": {"subject": "Charged twice", "body": "Billed two times in March."}}}' | jq .data

Pin a version with ?version=3. Errors come back as JSON with error.type and error.message; add -w '%{http_code}' to see the status.