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

504

Timeout during generation

Video, music, or deep research exceeded the maximum time. Retry or use dedicated endpoints.

🔄 VIDEO TIMEOUT: RESUME AT NO EXTRA COST

The video timeout returns error_code: "video_generation_timeout" with video_operation_name in the JSON body, the tokens have already been charged upfront (upfront charge, NOT refunded on timeout). Resend the same request with the video_operation_name parameter: the API resumes polling the same video generation operation instead of starting a new paid one.

const res = await fetch(API_URL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(requestBody) });
const data = await res.json();

if (data.error_code === "video_generation_timeout" && data.video_operation_name) {
  requestBody.video_operation_name = data.video_operation_name;
  // reinvia la stessa richiesta: riprende il polling
  // della stessa operazione di generazione video (addebito anticipato: il resume è incluso nel prezzo già pagato)
}

🎬 VIDEO ANALYSIS (RAG): PROCESSING IN PROGRESS

Analyzing large video files can exceed the server budget during Google processing. The response contains error_code: "video_processing_timeout" with video_file_name. The 20 base tokens have already been charged upfront (upfront charge, NOT refunded on timeout). Resend the same request adding the video_file_name parameter: the API resumes processing the same file already uploaded to Google, with no re-download or re-upload.

const requestBody = { api_key: "nai_xxx", prompt: "...", video_url: "https://...mp4" };
const res = await fetch(API_URL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(requestBody) });
const data = await res.json();

if (data.error_code === "video_processing_timeout" && data.video_file_name) {
  requestBody.video_file_name = data.video_file_name;
  // reinvia la stessa richiesta: riprende l'elaborazione
  // dello stesso file già caricato su Google (addebito anticipato: il resume è incluso nel prezzo già pagato)
}

💡 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);
}