LLMOps

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

llmops.ts
import { llmops } from '@llmops/sdk';
import { Pool } from 'pg';

export default llmops({
  database: new Pool({
    connectionString: process.env.DATABASE_URL,
  }),
});

Either database or providers must 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'; // default

This 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'; // default

This option:

  • Creates the schema if it doesn't exist (during migrations)
  • Sets search_path on every database connection
  • Isolates LLMOps tables from your application's tables
ValueBehavior
'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:

FieldRequiredDescription
providerYesProvider type (e.g. 'openai', 'anthropic', 'google')
slugYesUnique slug for routing (@slug/model)
apiKeyNoAPI key for the provider
customHostNoCustom API host URL
requestTimeoutNoRequest timeout in milliseconds
forwardHeadersNoHeaders 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 VariableSlugProvider
OPENAI_API_KEY@openaiOpenAI
ANTHROPIC_API_KEY@anthropicAnthropic
GOOGLE_API_KEY@googleGoogle
MISTRAL_API_KEY@mistralMistral
GROQ_API_KEY@groqGroq
COHERE_API_KEY@cohereCohere
TOGETHER_API_KEY@togetherTogether AI
PERPLEXITY_API_KEY@perplexityPerplexity
DEEPSEEK_API_KEY@deepseekDeepSeek
FIREWORKS_API_KEY@fireworksFireworks AI
OPENROUTER_API_KEY@openrouterOpenRouter
XAI_API_KEY@xaixAI
CEREBRAS_API_KEY@cerebrasCerebras
SAMBANOVA_API_KEY@sambanovaSambaNova
HUGGINGFACE_API_KEY@huggingfaceHugging Face
REPLICATE_API_TOKEN@replicateReplicate
AI21_API_KEY@ai21AI21
DEEPINFRA_API_KEY@deepinfraDeepInfra

When you provide explicit providers, auto-detected defaults are still added for any slug not already defined.


Complete Example

llmops.ts
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

.env
# 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-...

On this page