Configuration
The llmops() function accepts an optional configuration object that controls how LLMOps behaves. All fields are optional — providers are auto-detected from environment variables by default.
Zero-Config
import { llmops } from '@llmops/sdk';
// Auto-detects providers from env vars (OPENAI_API_KEY, etc.)
const client = llmops();With Database
import { llmops } from '@llmops/sdk';
import { Pool } from 'pg';
export default llmops({
database: new Pool({
connectionString: process.env.DATABASE_URL,
}),
});Either
databaseorprovidersmust be configured. If neither is provided explicitly, LLMOps auto-detects providers from API key environment variables (e.g.OPENAI_API_KEY).
Configuration Options
basePath
Optional — The URL path where LLMOps routes will be mounted. Must be a non-empty string starting with /. Defaults to '/llmops'.
basePath: '/llmops'; // defaultThis determines where the dashboard and API endpoints are accessible:
- Dashboard:
http://localhost:3000/llmops - API:
http://localhost:3000/llmops/api/genai/v1/chat/completions
database
Optional — A PostgreSQL connection pool instance for storing configs, variants, and enabling the dashboard UI.
import { Pool } from 'pg';
database: new Pool({
connectionString: process.env.DATABASE_URL,
});You can also pass individual connection options:
database: new Pool({
host: 'localhost',
port: 5432,
database: 'llmops',
user: 'postgres',
password: 'password',
});schema
Optional — The PostgreSQL schema name where LLMOps tables will be created. Defaults to 'llmops'.
schema: 'llmops'; // defaultThis option:
- Creates the schema if it doesn't exist (during migrations)
- Sets
search_pathon every database connection - Isolates LLMOps tables from your application's tables
| Value | Behavior |
|---|---|
'llmops' | Uses dedicated llmops schema (default) |
'public' | Uses the default PostgreSQL public schema |
'custom' | Uses a custom schema name of your choice |
providers
Optional — An array of inline provider configurations. Each provider has a unique slug used for routing via the @slug/model format.
Code-configured providers take precedence over auto-detected defaults.
providers: [
{
provider: 'openai',
slug: 'openai-prod',
apiKey: process.env.OPENAI_API_KEY,
},
{
provider: 'anthropic',
slug: 'anthropic-dev',
apiKey: process.env.ANTHROPIC_API_KEY,
},
]Each provider config accepts:
| Field | Required | Description |
|---|---|---|
provider | Yes | Provider type (e.g. 'openai', 'anthropic', 'google') |
slug | Yes | Unique slug for routing (@slug/model) |
apiKey | No | API key for the provider |
customHost | No | Custom API host URL |
requestTimeout | No | Request timeout in milliseconds |
forwardHeaders | No | Headers to forward to the provider |
Auto-Detected Providers
When providers is not specified, LLMOps scans for API key environment variables and auto-configures providers:
| Environment Variable | Slug | Provider |
|---|---|---|
OPENAI_API_KEY | @openai | OpenAI |
ANTHROPIC_API_KEY | @anthropic | Anthropic |
GOOGLE_API_KEY | @google | |
MISTRAL_API_KEY | @mistral | Mistral |
GROQ_API_KEY | @groq | Groq |
COHERE_API_KEY | @cohere | Cohere |
TOGETHER_API_KEY | @together | Together AI |
PERPLEXITY_API_KEY | @perplexity | Perplexity |
DEEPSEEK_API_KEY | @deepseek | DeepSeek |
FIREWORKS_API_KEY | @fireworks | Fireworks AI |
OPENROUTER_API_KEY | @openrouter | OpenRouter |
XAI_API_KEY | @xai | xAI |
CEREBRAS_API_KEY | @cerebras | Cerebras |
SAMBANOVA_API_KEY | @sambanova | SambaNova |
HUGGINGFACE_API_KEY | @huggingface | Hugging Face |
REPLICATE_API_TOKEN | @replicate | Replicate |
AI21_API_KEY | @ai21 | AI21 |
DEEPINFRA_API_KEY | @deepinfra | DeepInfra |
When you provide explicit providers, auto-detected defaults are still added for any slug not already defined.
Complete Example
import 'dotenv/config';
import { llmops } from '@llmops/sdk';
import { Pool } from 'pg';
export default llmops({
basePath: '/llmops',
database: new Pool({
connectionString: process.env.DATABASE_URL!,
}),
providers: [
{
provider: 'openai',
slug: 'openai-prod',
apiKey: process.env.OPENAI_API_KEY,
},
],
});Environment Variables
# Database (optional — enables dashboard)
DATABASE_URL=postgresql://postgres:password@localhost:5432/llmops
# Provider API keys (auto-detected when set)
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...