Search documentation of Ragex

# Ragex.AI.Config (Ragex v0.4.0)

View Source

Manages AI provider configuration.

Supports multiple AI providers with automatic fallback.

Loads settings from:

1. config/config.exs (compile-time defaults)
2. config/runtime.exs (runtime env vars)
3. Function call overrides

## Configuration

    config :ragex, :ai,
      providers: [:openai, :anthropic, :deepseek_r1, :ollama],
      default_provider: :openai,
      fallback_enabled: true

    config :ragex, :ai_providers,
      openai: [endpoint: "https://api.openai.com/v1", model: "gpt-4-turbo"],
      anthropic: [endpoint: "https://api.anthropic.com/v1", model: "claude-3-sonnet-20240229"],
      deepseek_r1: [endpoint: "https://api.deepseek.com", model: "deepseek-chat"],
      ollama: [endpoint: "http://localhost:11434", model: "codellama"]

## Summary

### Functions

api_config(provider_name \\ nil)

Get API configuration for a specific provider.

fallback_enabled?()

Check if fallback to alternative providers is enabled.

generation_opts(overrides \\ [], provider_name \\ nil)

Get generation options, merging config with overrides.

get_default_provider()

Get the default provider (returns provider name as atom).

provider()

Get the configured default AI provider module.

provider_name()

Get the configured default provider name.

providers()

Get list of all configured providers.

validate!()

Validate that required configuration is present for all providers.

## Functions

# api_config(provider_name \\ nil)

Get API configuration for a specific provider.

# fallback_enabled?()

Check if fallback to alternative providers is enabled.

# generation_opts(overrides \\ [], provider_name \\ nil)

Get generation options, merging config with overrides.

# get_default_provider()

    @spec get_default_provider() :: atom()

Get the default provider (returns provider name as atom).

This is an alias for `provider_name/0` with more explicit naming. Returns the configured default provider identifier.

## Returns

- Provider name atom (e.g., `:deepseek_r1`, `:openai`, `:anthropic`)

## Examples

    iex> Config.get_default_provider()
    :deepseek_r1

## Configuration

    config :ragex, :ai,
      default_provider: :openai

# provider()

Get the configured default AI provider module.

# provider_name()

Get the configured default provider name.

# providers()

Get list of all configured providers.

# validate!()

Validate that required configuration is present for all providers.