ExAgent.Models.OpenRouter (ExAgent v0.1.0)

Copy Markdown View Source

OpenRouter provider.

OpenRouter speaks the OpenAI Chat Completions wire format, so it reuses ExAgent.Providers.OpenAIChat. The only differences are the base URL (https://openrouter.ai/api/v1), the env key (OPENROUTER_API_KEY) and the optional attribution headers (HTTP-Referer / X-Title), pulled from OPENROUTER_APP_URL / OPENROUTER_APP_TITLE.

model = ExAgent.Models.OpenRouter.new(model: "anthropic/claude-3.5-sonnet")

Summary

Functions

Build an OpenRouter model.

Types

t()

@type t() :: %ExAgent.Models.OpenRouter{
  api_key: String.t() | nil,
  base_url: String.t() | nil,
  extra_headers: [{String.t(), String.t()}],
  model: String.t()
}

Functions

new(opts)

@spec new(keyword()) :: t()

Build an OpenRouter model.

Options:

  • :model — the OpenRouter model slug, e.g. "openai/gpt-4o-mini".
  • :api_key — falls back to OPENROUTER_API_KEY.
  • :base_url — defaults to https://openrouter.ai/api/v1.
  • :app_url/:app_title — for attribution; default to env vars.