Skip to content

AI Providers

The platform uses LLM providers across the AI audit, reporting insights, keyword expansion, and campaign narratives. Providers are configured in the admin panel, with environment variables as fallbacks.

Provider provider_type Notes
OpenAI openai Default
Anthropic anthropic
Google Gemini google
OpenAI-compatible base_url Any AI_BASE_URL (e.g. vLLM, Ollama, local models)

The admin panel (/admin/settings) holds the source of truth in the ai_provider PlatformSetting:

Field Purpose
enabled Master switch
provider_type openai / anthropic / google / custom
api_key Provider key
base_url OpenAI-compatible endpoint
default_model Model name
max_tokens Output cap
temperature Sampling temperature

Env vars are only consulted when the setting is unconfigured — they never auto-enable a provider when the setting is absent and the user hasn’t opted in. When unconfigured, GET /v1/settings/ai_provider returns enabled: null.

API key resolution order (_env_api_key):

  1. AI_API_KEY (explicit override)
  2. Provider-specific: ANTHROPIC_API_KEY for anthropic, GEMINI_API_KEY for google
  3. OPENAI_API_KEY otherwise

AI is a best-effort enhancement, never a blocker:

  • AI audit — skipped with a warning (ai_audit_skipped_not_enabled) when AI is disabled.
  • Reports — fall back to deterministic, finding-specific AI sections and log report_ai_deterministic_fallback (with scan_id).
  • Provider construction — logs report_ai_provider_unavailable with reason (ai_disabled / missing_api_key) and provider_type.
  • Insights — skipped (ai_insights_skipped_no_provider) when no provider is configured.