LLM.Provider.OpenRouter (LLM v0.1.2)

Copy Markdown View Source

OpenRouter provider preset.

Uses LLM.Adapter.OpenAI since OpenRouter is OpenAI-compatible.

Configuration

config :llm, :providers,
  openrouter: [api_key: "sk-or-..."]

Or at runtime:

LLM.put_key(:openrouter, "sk-or-...")

Usage

# Using as provider option
LLM.generate("Hello", provider: LLM.Provider.OpenRouter, model: "anthropic/claude-3-opus")

# With explicit API key
LLM.generate("Hello", provider: {LLM.Provider.OpenRouter, api_key: "sk-or-..."}, model: "anthropic/claude-3-opus")