Skip to content

feat: add OpenRouter as a first-class LLM provider#882

Open
octo-patch wants to merge 1 commit intokatanemo:mainfrom
octo-patch:fix/issue-612-add-openrouter-provider
Open

feat: add OpenRouter as a first-class LLM provider#882
octo-patch wants to merge 1 commit intokatanemo:mainfrom
octo-patch:fix/issue-612-add-openrouter-provider

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #612

Problem

OpenRouter is a popular API gateway that provides unified access to hundreds of models from providers like OpenAI, Anthropic, Google, and others via an OpenAI-compatible API. Previously, users had to configure it as an unsupported provider by manually specifying base_url and provider_interface, which was undocumented and fragile.

Solution

Add openrouter as a first-class supported provider:

  • crates/hermesllm/src/providers/id.rs: Add OpenRouter variant to ProviderId enum with TryFrom<&str> mapping and OpenAI-compatible API routing
  • crates/common/src/configuration.rs: Add OpenRouter variant to LlmProviderType enum
  • cli/planoai/config_generator.py: Add "openrouter" to SUPPORTED_PROVIDERS_WITH_BASE_URL (requires base_url since the endpoint is external)
  • config/plano_config_schema.yaml: Add "openrouter" to the provider_interface enum

Users can now configure OpenRouter like this:

model_providers:
  - model: openrouter/openai/gpt-4o
    access_key: $OPENROUTER_API_KEY
    base_url: https://openrouter.ai/api/v1
    default: true
  - model: openrouter/anthropic/claude-3-5-sonnet
    access_key: $OPENROUTER_API_KEY
    base_url: https://openrouter.ai/api/v1

OpenRouter uses the OpenAI-compatible chat completions API, so no new request/response types are needed.

Testing

  • All existing Rust tests pass (cargo test --lib -p hermesllm -p common)
  • Verified cargo check succeeds for all modified crates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for OpenRouter as an LLM provider

1 participant