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

100% Statements 26/26
100% Branches 34/34
100% Functions 10/10
100% Lines 23/23

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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81

    35x

    11x
    11x
    3x

    8x

    4x
    4x
    3x

    1x

    6x
    6x

    4x

    6x
    6x

    5x

    2x

    2x

    1x

    6x
    6x

    5x

    2x
    2x

     import { ModelRegistry } from "../../models/ModelRegistry.js";

    export class OpenRouterCapabilities {
      private static findModel(model: string) {
        return ModelRegistry.find(model, "openrouter");
      }

      static supportsVision(model: string): boolean {
        const info = this.findModel(model);
        if (info)
          return info.capabilities.includes("vision") || info.modalities.input.includes("image");

        // Fallback heuristics
        return (
          model.includes("vision") ||
          model.includes("gpt-4o") ||
          model.includes("claude-3") ||
          model.includes("gemini-1.5") ||
          model.includes("gemini-2.0") ||
          model.includes("flash") ||
          model.includes("gemini-pro-vision")
        );
      }

      static supportsTools(model: string): boolean {
        const info = this.findModel(model);
        if (info)
          return info.capabilities.includes("tools") || info.capabilities.includes("function_calling");

        // Fallback: Default to true for OpenRouter as most models support tools
        // but this is the "honest" check we wanted.
        return true;
      }

      static supportsStructuredOutput(model: string): boolean {
        const info = this.findModel(model);
        if (info) return info.capabilities.includes("structured_output") || info.id.includes("gpt-4");

        // Fallback heuristics
        return model.includes("gpt-4") || model.includes("gpt-3.5") || model.includes("claude-3");
      }

      static supportsEmbeddings(model: string): boolean {
        const info = this.findModel(model);
        if (info) return info.capabilities.includes("embeddings");

        // Fallback heuristics
        return model.includes("embedding") || model.includes("text-sdk");
      }

      static supportsImageGeneration(_model: string): boolean {
        return false;
      }

      static supportsTranscription(_model: string): boolean {
        return false;
      }

      static supportsModeration(_model: string): boolean {
        return false;
      }

      static supportsReasoning(model: string): boolean {
        const info = this.findModel(model);
        if (info) return info.capabilities.includes("reasoning");

        // Fallback heuristics
        return (
          model.includes("o1") ||
          model.includes("o3") ||
          model.includes("deepseek-r1") ||
          model.includes("qwq")
        );
      }

      static getContextWindow(model: string): number | null {
        const info = this.findModel(model);
        return info?.context_window ?? null;
      }
    }