Configuration
Learn how to configure the Agent OTP SDK for different environments and use cases.
API Keys
Every Agent OTP client requires an API key for authentication. You can create API keys using the CLI after starting your self-hosted instance:
# Create a new agent and get an API key
docker compose exec api bun run cli agent:create --name "my-assistant"API Key Format
API keys follow this format:
ak_live_xxxxxxxxxxxxxxxxxxxx # Production key
ak_test_xxxxxxxxxxxxxxxxxxxx # Test/sandbox keySecurity: Never expose API keys in client-side code or commit them to version control. Always use environment variables.
Environment Variables
We recommend storing your API key in an environment variable:
# .env
AGENT_OTP_API_KEY=ak_live_xxxxxxxxxxxxxxxxxxxx
# Optional: for self-hosted deployments
AGENT_OTP_BASE_URL=https://your-instance.comFramework-Specific Setup
Next.js
// lib/otp.ts
import { AgentOTPClient } from '@orrisai/agent-otp-sdk';
export const otp = new AgentOTPClient({
apiKey: process.env.AGENT_OTP_API_KEY!,
});Node.js with dotenv
import 'dotenv/config';
import { AgentOTPClient } from '@orrisai/agent-otp-sdk';
export const otp = new AgentOTPClient({
apiKey: process.env.AGENT_OTP_API_KEY!,
});Client Options
The AgentOTPClient constructor accepts the following options:
| Option | Type | Default | Description |
|---|---|---|---|
| apiKey | string | - | Your API key (required) |
| baseUrl | string | https://api.agentotp.com | API base URL |
| timeout | number | 30000 | Request timeout in milliseconds |
| retries | number | 3 | Number of retry attempts |
| debug | boolean | false | Enable debug logging |
Full Example
import { AgentOTPClient } from '@orrisai/agent-otp-sdk';
const client = new AgentOTPClient({
apiKey: process.env.AGENT_OTP_API_KEY!,
baseUrl: 'https://api.agentotp.com',
timeout: 30000,
retries: 3,
debug: process.env.NODE_ENV === 'development',
});Self-Hosted Configuration
If you're running a self-hosted Agent OTP instance, configure the base URL to point to your server:
const client = new AgentOTPClient({
apiKey: process.env.AGENT_OTP_API_KEY!,
baseUrl: 'https://otp.your-company.com',
});See the Self-Hosting Guide for deployment instructions.
Multiple Environments
Use different API keys for development, staging, and production:
// lib/otp.ts
import { AgentOTPClient } from '@orrisai/agent-otp-sdk';
const apiKeys = {
development: process.env.AGENT_OTP_DEV_KEY,
staging: process.env.AGENT_OTP_STAGING_KEY,
production: process.env.AGENT_OTP_API_KEY,
};
const env = process.env.NODE_ENV || 'development';
export const otp = new AgentOTPClient({
apiKey: apiKeys[env as keyof typeof apiKeys]!,
});