Remote LLM provider definition for Candil.
A provider represents an external API endpoint. Apero ships with built-in
support for OpenAI-compatible, Anthropic and Ollama APIs. Any
OpenAI-compatible endpoint (Together AI, Fireworks AI, Groq, LM Studio,
vLLM, etc.) can be used with :openai_compatible.
Fields
:alias— unique atom identifier:type— provider protocol (see below):base_url— base URL of the API (without trailing slash):api_key— authentication key:org_id— optional organisation ID (OpenAI only):api_version— optional API version header (Azure OpenAI):timeout_ms— request timeout in milliseconds (default:60_000):headers— additional HTTP headers as[{name, value}]tuples
Provider types
:openai— OpenAI API (https://api.openai.com):anthropic— Anthropic Messages API (https://api.anthropic.com):ollama— Ollama local server (http://localhost:11434):openai_compatible— any endpoint following the OpenAI REST spec
Examples
%Candil.Provider{
alias: :openai,
type: :openai,
base_url: "https://api.openai.com",
api_key: System.get_env("OPENAI_API_KEY")
}
%Candil.Provider{
alias: :anthropic,
type: :anthropic,
base_url: "https://api.anthropic.com",
api_key: System.get_env("ANTHROPIC_API_KEY")
}
%Candil.Provider{
alias: :ollama,
type: :ollama,
base_url: "http://localhost:11434"
}
%Candil.Provider{
alias: :groq,
type: :openai_compatible,
base_url: "https://api.groq.com/openai",
api_key: System.get_env("GROQ_API_KEY")
}
Summary
Functions
Builds the HTTP request headers for this provider.
Returns the chat completions endpoint URL for this provider.
Returns the embeddings endpoint URL for this provider.
Returns all valid provider type atoms.
Validates a provider struct. Returns :ok or {:error, [reasons]}.
Types
@type provider_type() :: :openai | :anthropic | :ollama | :openai_compatible
@type t() :: %Candil.Provider{ alias: atom(), api_key: binary() | nil, api_version: binary() | nil, base_url: binary(), headers: [{binary(), binary()}], org_id: binary() | nil, timeout_ms: pos_integer(), type: provider_type() }
Functions
Builds the HTTP request headers for this provider.
Includes authentication headers appropriate to the provider type.
Returns the chat completions endpoint URL for this provider.
Returns the embeddings endpoint URL for this provider.
@spec provider_types() :: [provider_type()]
Returns all valid provider type atoms.
Validates a provider struct. Returns :ok or {:error, [reasons]}.