@odnoga/node

Thin wrapper around odnoga. Use it when you want first-class managed prompts and _meta returned alongside the response, without rolling your own helper.

Install

npm i @odnoga/node

Init

import { airouter } from '@odnoga/node';

const ai = airouter({
  apiKey: process.env.AIROUTER_API_KEY!,
  endUser: userId,              // sets x-airouter-end-user on every call
  // baseUrl: optional override
});

Chat by prompt slug

const res = await ai.prompts.chat({
  slug: 'welcome-email',
  label: 'production',
  variables: { name: 'Ada' },
});

console.log(res.text);
console.log(res._meta.requestId, res._meta.costUsd, res._meta.remainingUsd);

Raw chat completion

const res = await ai.chat.completions({
  model: 'gpt-4o-mini',
  messages: [{ role: 'user', content: 'hi' }],
});

Errors

AirouterError with code, status, requestId. Same shape as the shared helper pattern.