Use Ngila in a server-side JavaScript or TypeScript application.
Set up
Download ngila.mjs and save it next to your application. Use Node.js 22+ with NGILA_API_KEY set in its environment. For TypeScript, place Download TypeScript declarations beside the module with the same basename.
Send a request
import { NgilaClient, choice } from "./ngila.mjs";
const client = new NgilaClient();
const result = await client.systemOne({
state: "I was charged twice.",
questions: {queue: choice("Which team handles this?", ["Billing", "Support", "Other"])}
});
console.log(result.answers.queue.choice, result.usage.input_tokens);Inspect errors
HTTP failures reject the promise with an Error carrying the numeric status. Handle fetch and timeout errors separately. Keep API calls on the server so the key stays private.
Images
Read image bytes with Node’s file API and pass them to the image helper. Add the result to assets under the same reference used in state or question text.