API guide
Send your first request
Add USD credit, create an application key and store it in the environment variable TOKEN_SALE_KEY。
Base URL https://leanapi.ai/v1
curl 'https://leanapi.ai/v1/models' \
-H "Authorization: Bearer $TOKEN_SALE_KEY"
curl 'https://leanapi.ai/v1/chat/completions' \
-H "Authorization: Bearer $TOKEN_SALE_KEY" \
-H 'Content-Type: application/json' \
-d '{"model":"kimi-k3.1-pro","messages":[{"role":"user","content":"Hello"}],"max_tokens":128}'
Text messages support system, user and assistant roles. Set stream: true to receive SSE events ending with [DONE] . If interrupted, use the X-Request-ID response header to check settlement.
Troubleshooting
- 400 Invalid parameters
- Check the request fields, message types, context and output limits.
- 401 Invalid API key
- Check the Bearer header and key status.
- 402 Insufficient balance / 403 Budget exceeded
- Check the available balance or adjust the application budget.
- 429 Too many requests
- Reduce concurrency and request frequency.
- 503 Upstream unavailable
- Keep the request ID and check the status in your statement.