Getting Started
API Reference
How to use exnest ai
API Reference
ExnestAI Client Options
interface ExnestClientOptions {
apiKey: string; // Required: Your ExnestAI API key
baseUrl?: string; // Optional: API base URL (default: https://api.exnest.app/v1)
timeout?: number; // Optional: Request timeout in ms (default: 30000)
retries?: number; // Optional: Number of retries (default: 3)
retryDelay?: number; // Optional: Delay between retries in ms (default: 1000)
debug?: boolean; // Optional: Enable debug logging (default: false)
}
Chat Completion
const response = await exnest.chat(
'gpt-4.1-mini', // Model identifier
[
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Explain async/await in JavaScript' }
],
{
temperature: 0.7, // Optional
max_tokens: 500, // Optional
}
);
Streaming Responses
// Streaming chat completion
for await (const chunk of exnest.stream('gpt-4.1-mini', [
{ role: 'user', content: 'Write a story about a robot learning to love' }
])) {
process.stdout.write(chunk.choices[0].delta.content || '');
}
Simple Response
const response = await exnest.responses(
'claude-3-haiku', // Model identifier
'What is TypeScript?', // User input
200 // Optional max tokens
);