A valid Levanto API key is always required for decision calls. Every POST to /decide and /decide/batch must carry a key; requests without one are rejected with HTTP 401.
Sending the key
Send the key in the Authorization header:
Authorization: Bearer lv_live_...
Keys look like lv_live_.... If you don’t have one yet, create it in the dashboard under Intelligence → API Keys.
Only /decide and /decide/batch require a key. GET /ready does not — use it to check model readiness before you have a key.
Error responses
| Status | Meaning |
|---|
401 | Missing or invalid API key |
402 | Key is valid but account balance is too low |
{"detail": "API key required. Provide a valid Levanto API key."}
Handling keys safely
Never hardcode, log, echo, or commit your API key. Read it from an environment variable (for example SAGE_API_KEY) and pass it only in the request header.
curl -s -H "Authorization: Bearer $SAGE_API_KEY" \
-H 'Content-Type: application/json' \
"https://sage.levanto.ai/decide" -d '{
"content": "Marketing email draft promotes '\''guaranteed 40% returns'\'' and describes the product as '\''risk-free'\'' for accredited investors.",
"question": {"id": "needs_compliance_review", "kind": "yesno", "instructions": "Does this copy require compliance review before send?"}
}'
See Errors for the full status code and error body reference.