Class OpenRouterAiProvider

All Implemented Interfaces:
PropertyChangeSource, Rebindable

public class OpenRouterAiProvider extends OpenAiChatCompletionsProvider
Dedicated AI Provider for OpenRouter (openrouter.ai) using their OpenAI-compatible API.

Connects to https://openrouter.ai/api/v1 to access hundreds of models from OpenAI, Anthropic, Google, Meta, DeepSeek, xAI (Grok), Mistral, and open-source communities. Includes automated discovery of context lengths, provider output ceilings, pricing, and multimodal capabilities directly from the /v1/models endpoint.

Author:
anahata
  • Constructor Details

    • OpenRouterAiProvider

      public OpenRouterAiProvider()
      Constructs a new OpenRouter provider with stable UUID "OpenRouter".
  • Method Details

    • createModel

      protected OpenAiCompatibleModel createModel(com.fasterxml.jackson.databind.JsonNode node)
      Constructs a concrete model instance for this provider.

      Instantiates an OpenRouterModel capable of extracting rich capability, pricing, and context limits from OpenRouter model metadata.

      Overrides:
      createModel in class OpenAiChatCompletionsProvider
      Parameters:
      node - The raw JSON model descriptor.
      Returns:
      A configured OpenRouterModel instance.
    • getApiKeyHint

      public String getApiKeyHint()
      Gets a template or hint string to display when the API keys file is empty.

      Implementation details: Provides a standard header hint for the multi-key configuration file.

      Provides the OpenRouter-specific API key format template.

      Overrides:
      getApiKeyHint in class OpenAiChatCompletionsProvider
      Returns:
      Multi-line template string.