Authentication
The Exnest AI SDKs use API keys for authentication. You can obtain an API key from the Exnest Dashboard.
Setting the API Key
Section titled “Setting the API Key”It is recommended to use environment variables to store your API key securely.
Environment Variable
Section titled “Environment Variable”The SDK automatically looks for the EXNEST_API_KEY environment variable.
export EXNEST_API_KEY="your_api_key_here"import { ExnestAI } from '@exnest-dev/ai';
// No need to pass apiKey if env var is setconst client = new ExnestAI();Constructor Argument
Section titled “Constructor Argument”You can also pass the API key directly to the constructor.
const client = new ExnestAI({ apiKey: 'your_api_key_here',});Environment Variable
Section titled “Environment Variable”The SDK automatically looks for the EXNEST_API_KEY environment variable.
export EXNEST_API_KEY="your_api_key_here"from exnestai import ExnestAI
# No need to pass api_key if env var is setclient = ExnestAI()Constructor Argument
Section titled “Constructor Argument”You can also pass the API key directly to the constructor.
client = ExnestAI(api_key="your_api_key_here")Universal Connector
Section titled “Universal Connector”Exnest supports both Exnest API keys (prefixed with ex-sk) and official provider API keys through the Universal Connector feature. This allows you to:
- Use your existing API keys from providers like OpenAI, Anthropic, etc.
- Still benefit from Exnest’s unified API interface
- Optionally use Exnest’s billing and management features when using Exnest API keys
Using Exnest API Keys (with billing)
Section titled “Using Exnest API Keys (with billing)”const exnest = new ExnestAI({ apiKey: 'ex-sk-your-exnest-api-key'});
const response = await exnest.chat('gpt-4.1-mini', [ { role: 'user', content: 'Hello!' }]);Using Official Provider API Keys (without billing)
Section titled “Using Official Provider API Keys (without billing)”const exnest = new ExnestAI({ apiKey: 'sk-your-openai-api-key'});
const response = await exnest.chat('gpt-4.1-mini', [ { role: 'user', content: 'Hello!' }]);