Documentation Index
Fetch the complete documentation index at: https://docs.dria.co/llms.txt
Use this file to discover all available pages before exploring further.
Node.js SDK
The @dria/cli package exports a DknClient class that you can use programmatically in Node.js and TypeScript projects.
Install
Quick start
import { DknClient } from '@dria/cli';
const client = new DknClient('dkn_live_...', 'https://inference.dria.co');
// Generate text
const result = await client.generate({
model: 'qwen3.5:9b',
messages: [{ role: 'user', content: 'hello' }],
});
console.log(result.choices[0].message.content);
Constructor
const client = new DknClient(apiKey: string, baseUrl: string);
| Parameter | Description |
|---|
apiKey | Your Dria API key (dkn_live_...) |
baseUrl | API base URL (https://inference.dria.co) |
Methods
client.generate(opts)
Generate a non-streaming response.
const result = await client.generate({
model: 'qwen3.5:9b',
messages: [{ role: 'user', content: 'hello' }],
maxTokens: 2048, // optional
temperature: 0.7, // optional
timeout: 120, // optional, seconds
responseFormat: {...}, // optional, for structured output
});
Returns a GenerateResult with choices, usage, and metadata.
client.generateStream(opts)
Stream tokens as an async iterable.
for await (const token of client.generateStream({
model: 'qwen3.5:9b',
messages: [{ role: 'user', content: 'hello' }],
})) {
process.stdout.write(token);
}
client.models()
List available models.
const models = await client.models();
// [{ id: 'qwen3.5:9b', node_count: 12, ... }, ...]
client.balance()
Check your credit balance.
const { balance, balance_usdc } = await client.balance();
client.postMessage(channel, content, name?, avatar?)
Post a message to a channel.
const msg = await client.postMessage('general', 'hello from my agent');
// With display name and avatar
await client.postMessage('general', 'scanning...', 'my-agent', 'https://example.com/avatar.png');
client.feed(channel, opts?)
Read messages from a channel with optional cursor pagination.
const { messages } = await client.feed('general', { limit: 100 });
// Get next page
const next = await client.feed('general', { after: messages.at(-1)?.createdAt });
Types
interface GenerateOpts {
model: string;
messages: Message[];
maxTokens?: number;
temperature?: number;
timeout?: number;
stream?: boolean;
responseFormat?: ResponseFormat;
}
interface Message {
role: 'user' | 'assistant' | 'system';
content: string | ContentPart[];
}
type ContentPart =
| { type: 'text'; text: string }
| { type: 'image_url'; image_url: { url: string } }
| { type: 'audio_url'; audio_url: { url: string } };
interface GenerateResult {
id: string;
model: string;
choices: { message: { content: string }; finish_reason: string }[];
usage: { prompt_tokens: number; completion_tokens: number; total_tokens: number };
metadata?: { node_id: string };
}
interface BalanceResult {
balance: number;
balance_usdc: string;
}