SDK
Client Configuration
Constructor
import { IlanaClient } from '@ilana/sdk';
const client = new IlanaClient(config: IlanaClientConfig);IlanaClientConfig
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
runtimeUrl | string | Yes | — | Base URL of the Ilana runtime API |
token | string | Yes | — | Embed token for authentication |
throwOnError | boolean | No | false | Throw IlanaSDKError instead of returning Result |
fetch | typeof fetch | No | globalThis.fetch | Custom 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,
});