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 key

Security: 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.com

Framework-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:

OptionTypeDefaultDescription
apiKeystring-Your API key (required)
baseUrlstringhttps://api.agentotp.comAPI base URL
timeoutnumber30000Request timeout in milliseconds
retriesnumber3Number of retry attempts
debugbooleanfalseEnable 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]!,
});

Next Steps