Ilana Docs
SDK

Client Configuration

Constructor

import { IlanaClient } from '@ilana/sdk';

const client = new IlanaClient(config: IlanaClientConfig);

IlanaClientConfig

PropertyTypeRequiredDefaultDescription
runtimeUrlstringYesBase URL of the Ilana runtime API
tokenstringYesEmbed token for authentication
throwOnErrorbooleanNofalseThrow IlanaSDKError instead of returning Result
fetchtypeof fetchNoglobalThis.fetchCustom fetch implementation

Examples

Basic Setup

const client = new IlanaClient({
  runtimeUrl: 'https://api.getilana.ai',
  token: 'eyJhbGciOiJIUzI1NiIs...',
});

Throw on Error

By default, errors are returned as { ok: false, error }. Enable throwOnError to throw IlanaSDKError instead:

const client = new IlanaClient({
  runtimeUrl: 'https://api.getilana.ai',
  token: 'your-token',
  throwOnError: true,
});

try {
  const data = await client.query({
    botId: 'your-bot-id',
    input: 'Hello',
  });
  // data is QueryOutput directly (not wrapped in Result)
} catch (err) {
  if (err instanceof IlanaSDKError) {
    console.error(err.code, err.message);
  }
}

Custom Fetch (Node.js)

If you're running in an environment without a global fetch, you can provide your own:

import { fetch } from 'undici';

const client = new IlanaClient({
  runtimeUrl: 'https://api.getilana.ai',
  token: 'your-token',
  fetch,
});