Error Codes
401

Missing or invalid API key

Make sure the key starts with nai_ and is active

403

Scope not allowed for this key

The key does not have permissions for this function

400

Missing parameters (e.g. prompt)

Check that the JSON body contains all required fields

429

Rate limit exceeded

Too many requests per minute, wait before retrying

500

Internal error during processing

Server-side error, retry or contact support

πŸ’‘ Recommended error handling:

const res = await fetch(API_URL, { ... });
const data = await res.json();

if (!res.ok || data.status !== "success") {
  console.error("Error:", data.error);
}