Use your Script Ninja key from your application's server. Keep it out of public code and browser bundles.
Make a request.
POST https://scriptninja.pro/api/v1/chat/completions
Authorization: Bearer YOUR_SCRIPT_NINJA_KEY
Content-Type: application/json
{
"model": "ninja-fast",
"messages": [{"role": "user", "content": "Summarise this project brief."}],
"max_tokens": 1024,
"stream": false
}Models and limits.
Use ninja-fast or ninja-pro. This release accepts system, user and assistant text messages, up to 30 messages and 60KB total message data. Maximum output is 8,192 tokens per request. An account can have up to three requests in progress.
Inspect your usage.
Successful responses contain prompt_tokens, completion_tokens, total_tokens and cached_input_tokens. Cached input is part of prompt_tokens, so do not add it again. The billing object includes charge_usd and request_id.
Credit reservations.
A request reserves enough credit for its bounded input and maximum output. Completed requests settle against the recorded usage. If a request is interrupted and its usage is unknown, the reservation stays pending for reconciliation.
Handle errors.
| Status | Meaning |
|---|---|
| 400 | Check the model, message format and output limit. |
| 401 | The key is missing, invalid or revoked. |
| 402 | Add enough credit for the request. |
| 429 | Wait for current requests to finish. |
| 502 | The request failed or needs reconciliation. Do not immediately replay a potentially billable request. |
| 503 | The service is temporarily unavailable or not yet activated. |
Rotate a key.
Create a new key in your dashboard, update your application's secret configuration, then revoke the old key. The raw key is displayed only when it is created.
Review token pricing ↗