# All files / src/providers/openrouter OpenRouterProvider.ts

46.15% Statements 6/13
50% Branches 2/4
41.66% Functions 5/12
46.15% Lines 6/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36

    7x
    1x
    1x

    2x

    7x

    14x

     import { OpenAIProvider } from "../openai/OpenAIProvider.js";
    import { OpenRouterCapabilities } from "./Capabilities.js";

    export interface OpenRouterProviderOptions {
      apiKey: string;
      baseUrl?: string;
    }

    export class OpenRouterProvider extends OpenAIProvider {
      public capabilities = {
        supportsVision: (model: string) => OpenRouterCapabilities.supportsVision(model),
        supportsTools: (model: string) => OpenRouterCapabilities.supportsTools(model),
        supportsStructuredOutput: (model: string) =>
          OpenRouterCapabilities.supportsStructuredOutput(model),
        supportsEmbeddings: (model: string) => OpenRouterCapabilities.supportsEmbeddings(model),
        supportsImageGeneration: (model: string) =>
          OpenRouterCapabilities.supportsImageGeneration(model),
        supportsTranscription: (model: string) => OpenRouterCapabilities.supportsTranscription(model),
        supportsModeration: (model: string) => OpenRouterCapabilities.supportsModeration(model),
        supportsReasoning: (model: string) => OpenRouterCapabilities.supportsReasoning(model),
        supportsDeveloperRole: (_model: string) => true,
        getContextWindow: (model: string) => OpenRouterCapabilities.getContextWindow(model) || null
      };

      constructor(options: OpenRouterProviderOptions) {
        super({
          apiKey: options.apiKey,
          baseUrl: options.baseUrl || "https://openrouter.ai/api/v1"
        });
      }

      protected providerName(): string {
        return "OpenRouter";
      }
    }