import {
  FALLBACK_MODELS
} from "./chunk-ZBFU37UL.js";
import {
  getConfig,
  readSetting
} from "./chunk-2MAQ6JFL.js";
import {
  __commonJS
} from "./chunk-2ESYSVXG.js";

// src/lib/model-catalog.json
var require_model_catalog = __commonJS({
  "src/lib/model-catalog.json"(exports, module) {
    module.exports = {
      "claude-haiku-4-5": {
        cache_creation_input_token_cost: 125e-8,
        cache_creation_input_token_cost_above_1hr: 2e-6,
        cache_read_input_token_cost: 1e-7,
        input_cost_per_token: 1e-6,
        litellm_provider: "anthropic",
        max_input_tokens: 2e5,
        max_output_tokens: 64e3,
        max_tokens: 64e3,
        mode: "chat",
        output_cost_per_token: 5e-6,
        supports_assistant_prefill: true,
        supports_function_calling: true,
        supports_computer_use: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_tool_choice: true,
        supports_vision: true
      },
      "claude-opus-4-5": {
        cache_creation_input_token_cost: 625e-8,
        cache_creation_input_token_cost_above_1hr: 1e-5,
        cache_read_input_token_cost: 5e-7,
        input_cost_per_token: 5e-6,
        litellm_provider: "anthropic",
        max_input_tokens: 2e5,
        max_output_tokens: 64e3,
        max_tokens: 64e3,
        mode: "chat",
        output_cost_per_token: 25e-6,
        search_context_cost_per_query: {
          search_context_size_high: 0.01,
          search_context_size_low: 0.01,
          search_context_size_medium: 0.01
        },
        supports_assistant_prefill: true,
        supports_computer_use: true,
        supports_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_tool_choice: true,
        supports_vision: true,
        tool_use_system_prompt_tokens: 159
      },
      "claude-opus-4-6": {
        cache_creation_input_token_cost: 625e-8,
        cache_creation_input_token_cost_above_1hr: 1e-5,
        cache_read_input_token_cost: 5e-7,
        input_cost_per_token: 5e-6,
        litellm_provider: "anthropic",
        max_input_tokens: 1e6,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 25e-6,
        search_context_cost_per_query: {
          search_context_size_high: 0.01,
          search_context_size_low: 0.01,
          search_context_size_medium: 0.01
        },
        supports_assistant_prefill: false,
        supports_computer_use: true,
        supports_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_tool_choice: true,
        supports_vision: true,
        tool_use_system_prompt_tokens: 346,
        provider_specific_entry: {
          us: 1.1,
          fast: 6
        },
        supports_max_reasoning_effort: true,
        supports_minimal_reasoning_effort: true
      },
      "claude-opus-4-7": {
        cache_creation_input_token_cost: 625e-8,
        cache_creation_input_token_cost_above_1hr: 1e-5,
        cache_read_input_token_cost: 5e-7,
        input_cost_per_token: 5e-6,
        litellm_provider: "anthropic",
        max_input_tokens: 1e6,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 25e-6,
        search_context_cost_per_query: {
          search_context_size_high: 0.01,
          search_context_size_low: 0.01,
          search_context_size_medium: 0.01
        },
        supports_assistant_prefill: false,
        supports_computer_use: true,
        supports_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_tool_choice: true,
        supports_vision: true,
        supports_xhigh_reasoning_effort: true,
        tool_use_system_prompt_tokens: 346,
        provider_specific_entry: {
          us: 1.1,
          fast: 6
        },
        supports_max_reasoning_effort: true,
        supports_minimal_reasoning_effort: true
      },
      "claude-sonnet-4-5": {
        cache_creation_input_token_cost: 375e-8,
        cache_read_input_token_cost: 3e-7,
        input_cost_per_token: 3e-6,
        input_cost_per_token_above_200k_tokens: 6e-6,
        output_cost_per_token_above_200k_tokens: 225e-7,
        cache_creation_input_token_cost_above_200k_tokens: 75e-7,
        cache_read_input_token_cost_above_200k_tokens: 6e-7,
        litellm_provider: "anthropic",
        max_input_tokens: 2e5,
        max_output_tokens: 64e3,
        max_tokens: 64e3,
        mode: "chat",
        output_cost_per_token: 15e-6,
        search_context_cost_per_query: {
          search_context_size_high: 0.01,
          search_context_size_low: 0.01,
          search_context_size_medium: 0.01
        },
        supports_assistant_prefill: true,
        supports_computer_use: true,
        supports_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_tool_choice: true,
        supports_vision: true,
        tool_use_system_prompt_tokens: 346
      },
      "claude-sonnet-4-6": {
        cache_creation_input_token_cost: 375e-8,
        cache_read_input_token_cost: 3e-7,
        input_cost_per_token: 3e-6,
        litellm_provider: "anthropic",
        max_input_tokens: 1e6,
        max_output_tokens: 64e3,
        max_tokens: 64e3,
        mode: "chat",
        output_cost_per_token: 15e-6,
        search_context_cost_per_query: {
          search_context_size_high: 0.01,
          search_context_size_low: 0.01,
          search_context_size_medium: 0.01
        },
        supports_assistant_prefill: true,
        supports_computer_use: true,
        supports_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_tool_choice: true,
        supports_vision: true,
        tool_use_system_prompt_tokens: 346,
        supports_minimal_reasoning_effort: true
      },
      "codex-mini-latest": {
        cache_read_input_token_cost: 375e-9,
        input_cost_per_token: 15e-7,
        litellm_provider: "openai",
        max_input_tokens: 2e5,
        max_output_tokens: 1e5,
        max_tokens: 1e5,
        mode: "responses",
        output_cost_per_token: 6e-6,
        supported_endpoints: [
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_vision: true
      },
      "gemini-2.0-flash": {
        cache_read_input_token_cost: 25e-9,
        deprecation_date: "2026-06-01",
        input_cost_per_audio_token: 7e-7,
        input_cost_per_token: 1e-7,
        litellm_provider: "vertex_ai-language-models",
        max_audio_length_hours: 8.4,
        max_audio_per_prompt: 1,
        max_images_per_prompt: 3e3,
        max_input_tokens: 1048576,
        max_output_tokens: 8192,
        max_pdf_size_mb: 30,
        max_tokens: 8192,
        max_video_length: 1,
        max_videos_per_prompt: 10,
        mode: "chat",
        output_cost_per_token: 4e-7,
        source: "https://ai.google.dev/pricing#2_0flash",
        supported_modalities: [
          "text",
          "image",
          "audio",
          "video"
        ],
        supported_output_modalities: [
          "text",
          "image"
        ],
        supports_audio_input: true,
        supports_audio_output: true,
        supports_function_calling: true,
        supports_parallel_function_calling: true,
        supports_prompt_caching: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_url_context: true,
        supports_vision: true,
        supports_web_search: true
      },
      "gemini-2.0-flash-lite": {
        cache_read_input_token_cost: 1875e-11,
        deprecation_date: "2026-06-01",
        input_cost_per_audio_token: 75e-9,
        input_cost_per_token: 75e-9,
        litellm_provider: "vertex_ai-language-models",
        max_audio_length_hours: 8.4,
        max_audio_per_prompt: 1,
        max_images_per_prompt: 3e3,
        max_input_tokens: 1048576,
        max_output_tokens: 8192,
        max_pdf_size_mb: 50,
        max_video_length: 1,
        max_videos_per_prompt: 10,
        mode: "chat",
        output_cost_per_token: 3e-7,
        source: "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",
        supported_modalities: [
          "text",
          "image",
          "audio",
          "video"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_audio_output: true,
        supports_function_calling: true,
        supports_parallel_function_calling: true,
        supports_prompt_caching: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_vision: true,
        supports_web_search: true
      },
      "gemini-2.5-flash": {
        cache_read_input_token_cost: 3e-8,
        input_cost_per_audio_token: 1e-6,
        input_cost_per_token: 3e-7,
        litellm_provider: "vertex_ai-language-models",
        max_audio_length_hours: 8.4,
        max_audio_per_prompt: 1,
        max_images_per_prompt: 3e3,
        max_input_tokens: 1048576,
        max_output_tokens: 65535,
        max_pdf_size_mb: 30,
        max_tokens: 65535,
        max_video_length: 1,
        max_videos_per_prompt: 10,
        mode: "chat",
        output_cost_per_reasoning_token: 25e-7,
        output_cost_per_token: 25e-7,
        source: "https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/completions",
          "/v1/batch"
        ],
        supported_modalities: [
          "text",
          "image",
          "audio",
          "video"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_audio_output: false,
        supports_function_calling: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_url_context: true,
        supports_vision: true,
        supports_web_search: true,
        supports_service_tier: true
      },
      "gemini-2.5-flash-lite": {
        cache_read_input_token_cost: 1e-8,
        input_cost_per_audio_token: 3e-7,
        input_cost_per_token: 1e-7,
        litellm_provider: "vertex_ai-language-models",
        max_audio_length_hours: 8.4,
        max_audio_per_prompt: 1,
        max_images_per_prompt: 3e3,
        max_input_tokens: 1048576,
        max_output_tokens: 65535,
        max_pdf_size_mb: 30,
        max_tokens: 65535,
        max_video_length: 1,
        max_videos_per_prompt: 10,
        mode: "chat",
        output_cost_per_reasoning_token: 4e-7,
        output_cost_per_token: 4e-7,
        source: "https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/completions",
          "/v1/batch"
        ],
        supported_modalities: [
          "text",
          "image",
          "audio",
          "video"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_audio_output: false,
        supports_function_calling: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_url_context: true,
        supports_vision: true,
        supports_web_search: true,
        supports_service_tier: true
      },
      "gemini-2.5-pro": {
        cache_read_input_token_cost: 125e-9,
        cache_read_input_token_cost_above_200k_tokens: 25e-8,
        cache_creation_input_token_cost_above_200k_tokens: 25e-8,
        input_cost_per_token: 125e-8,
        input_cost_per_token_above_200k_tokens: 25e-7,
        litellm_provider: "vertex_ai-language-models",
        max_audio_length_hours: 8.4,
        max_audio_per_prompt: 1,
        max_images_per_prompt: 3e3,
        max_input_tokens: 1048576,
        max_output_tokens: 65535,
        max_pdf_size_mb: 30,
        max_tokens: 65535,
        max_video_length: 1,
        max_videos_per_prompt: 10,
        mode: "chat",
        output_cost_per_token: 1e-5,
        output_cost_per_token_above_200k_tokens: 15e-6,
        source: "https://cloud.google.com/vertex-ai/generative-ai/pricing",
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/completions"
        ],
        supported_modalities: [
          "text",
          "image",
          "audio",
          "video"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_audio_input: true,
        supports_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_video_input: true,
        supports_vision: true,
        supports_web_search: true,
        supports_service_tier: true
      },
      "gemini-3.1-flash-lite-preview": {
        cache_read_input_token_cost: 25e-9,
        cache_read_input_token_cost_per_audio_token: 5e-8,
        input_cost_per_audio_token: 5e-7,
        input_cost_per_token: 25e-8,
        litellm_provider: "vertex_ai-language-models",
        max_audio_length_hours: 8.4,
        max_audio_per_prompt: 1,
        max_images_per_prompt: 3e3,
        max_input_tokens: 1048576,
        max_output_tokens: 65536,
        max_pdf_size_mb: 30,
        max_tokens: 65536,
        max_video_length: 1,
        max_videos_per_prompt: 10,
        mode: "chat",
        output_cost_per_reasoning_token: 15e-7,
        output_cost_per_token: 15e-7,
        source: "https://ai.google.dev/gemini-api/docs/models",
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/completions",
          "/v1/batch"
        ],
        supported_modalities: [
          "text",
          "image",
          "audio",
          "video"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_audio_input: true,
        supports_audio_output: false,
        supports_code_execution: true,
        supports_file_search: true,
        supports_function_calling: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_url_context: true,
        supports_video_input: true,
        supports_vision: true,
        supports_web_search: true,
        supports_native_streaming: true,
        supports_service_tier: true
      },
      "gemini-3.1-pro-preview": {
        cache_read_input_token_cost: 2e-7,
        cache_read_input_token_cost_above_200k_tokens: 4e-7,
        cache_creation_input_token_cost_above_200k_tokens: 25e-8,
        input_cost_per_token: 2e-6,
        input_cost_per_token_above_200k_tokens: 4e-6,
        input_cost_per_token_batches: 1e-6,
        litellm_provider: "vertex_ai-language-models",
        max_audio_length_hours: 8.4,
        max_audio_per_prompt: 1,
        max_images_per_prompt: 3e3,
        max_input_tokens: 1048576,
        max_output_tokens: 65536,
        max_pdf_size_mb: 30,
        max_tokens: 65536,
        max_video_length: 1,
        max_videos_per_prompt: 10,
        mode: "chat",
        output_cost_per_token: 12e-6,
        output_cost_per_token_above_200k_tokens: 18e-6,
        output_cost_per_token_batches: 6e-6,
        output_cost_per_image: 12e-5,
        source: "https://cloud.google.com/vertex-ai/generative-ai/pricing#gemini-models",
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/completions",
          "/v1/batch"
        ],
        supported_modalities: [
          "text",
          "image",
          "audio",
          "video"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_audio_input: true,
        supports_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_video_input: true,
        supports_vision: true,
        supports_web_search: true,
        supports_url_context: true,
        supports_native_streaming: true,
        input_cost_per_token_priority: 36e-7,
        input_cost_per_token_above_200k_tokens_priority: 72e-7,
        output_cost_per_token_priority: 216e-7,
        output_cost_per_token_above_200k_tokens_priority: 324e-7,
        cache_read_input_token_cost_priority: 36e-8,
        cache_read_input_token_cost_above_200k_tokens_priority: 72e-8,
        supports_service_tier: true
      },
      "gpt-4.1": {
        cache_read_input_token_cost: 5e-7,
        cache_read_input_token_cost_priority: 875e-9,
        input_cost_per_token: 2e-6,
        input_cost_per_token_batches: 1e-6,
        input_cost_per_token_priority: 35e-7,
        litellm_provider: "openai",
        max_input_tokens: 1047576,
        max_output_tokens: 32768,
        max_tokens: 32768,
        mode: "chat",
        output_cost_per_token: 8e-6,
        output_cost_per_token_batches: 4e-6,
        output_cost_per_token_priority: 14e-6,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_web_search: true
      },
      "gpt-4.1-mini": {
        cache_read_input_token_cost: 1e-7,
        cache_read_input_token_cost_priority: 175e-9,
        input_cost_per_token: 4e-7,
        input_cost_per_token_batches: 2e-7,
        input_cost_per_token_priority: 7e-7,
        litellm_provider: "openai",
        max_input_tokens: 1047576,
        max_output_tokens: 32768,
        max_tokens: 32768,
        mode: "chat",
        output_cost_per_token: 16e-7,
        output_cost_per_token_batches: 8e-7,
        output_cost_per_token_priority: 28e-7,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_web_search: true
      },
      "gpt-4.1-nano": {
        cache_read_input_token_cost: 25e-9,
        cache_read_input_token_cost_priority: 5e-8,
        input_cost_per_token: 1e-7,
        input_cost_per_token_batches: 5e-8,
        input_cost_per_token_priority: 2e-7,
        litellm_provider: "openai",
        max_input_tokens: 1047576,
        max_output_tokens: 32768,
        max_tokens: 32768,
        mode: "chat",
        output_cost_per_token: 4e-7,
        output_cost_per_token_batches: 2e-7,
        output_cost_per_token_priority: 8e-7,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true
      },
      "gpt-5": {
        cache_read_input_token_cost: 125e-9,
        cache_read_input_token_cost_flex: 625e-10,
        cache_read_input_token_cost_priority: 25e-8,
        input_cost_per_token: 125e-8,
        input_cost_per_token_flex: 625e-9,
        input_cost_per_token_priority: 25e-7,
        litellm_provider: "openai",
        max_input_tokens: 272e3,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 1e-5,
        output_cost_per_token_flex: 5e-6,
        output_cost_per_token_priority: 2e-5,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_web_search: true,
        supports_none_reasoning_effort: false,
        supports_xhigh_reasoning_effort: false,
        supports_minimal_reasoning_effort: true
      },
      "gpt-5-mini": {
        cache_read_input_token_cost: 25e-9,
        cache_read_input_token_cost_flex: 125e-10,
        cache_read_input_token_cost_priority: 45e-9,
        input_cost_per_token: 25e-8,
        input_cost_per_token_flex: 125e-9,
        input_cost_per_token_priority: 45e-8,
        litellm_provider: "openai",
        max_input_tokens: 272e3,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 2e-6,
        output_cost_per_token_flex: 1e-6,
        output_cost_per_token_priority: 36e-7,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_web_search: true,
        supports_none_reasoning_effort: false,
        supports_xhigh_reasoning_effort: false,
        supports_minimal_reasoning_effort: true
      },
      "gpt-5-nano": {
        cache_read_input_token_cost: 5e-9,
        cache_read_input_token_cost_flex: 25e-10,
        input_cost_per_token: 5e-8,
        input_cost_per_token_flex: 25e-9,
        input_cost_per_token_priority: 25e-7,
        litellm_provider: "openai",
        max_input_tokens: 272e3,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 4e-7,
        output_cost_per_token_flex: 2e-7,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_vision: true,
        supports_web_search: true,
        supports_none_reasoning_effort: false,
        supports_xhigh_reasoning_effort: false,
        supports_minimal_reasoning_effort: true
      },
      "gpt-5-pro": {
        input_cost_per_token: 15e-6,
        input_cost_per_token_batches: 75e-7,
        litellm_provider: "openai",
        max_input_tokens: 128e3,
        max_output_tokens: 272e3,
        max_tokens: 272e3,
        mode: "responses",
        output_cost_per_token: 12e-5,
        output_cost_per_token_batches: 6e-5,
        supported_endpoints: [
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: false,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_vision: true,
        supports_web_search: true,
        supports_none_reasoning_effort: false,
        supports_xhigh_reasoning_effort: false,
        supports_minimal_reasoning_effort: true
      },
      "gpt-5.1": {
        cache_read_input_token_cost: 125e-9,
        cache_read_input_token_cost_priority: 25e-8,
        input_cost_per_token: 125e-8,
        input_cost_per_token_priority: 25e-7,
        litellm_provider: "openai",
        max_input_tokens: 272e3,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 1e-5,
        output_cost_per_token_priority: 2e-5,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text",
          "image"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_web_search: true,
        supports_none_reasoning_effort: true,
        supports_xhigh_reasoning_effort: false,
        supports_minimal_reasoning_effort: true
      },
      "gpt-5.2": {
        cache_read_input_token_cost: 175e-9,
        cache_read_input_token_cost_priority: 35e-8,
        input_cost_per_token: 175e-8,
        input_cost_per_token_priority: 35e-7,
        litellm_provider: "openai",
        max_input_tokens: 272e3,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 14e-6,
        output_cost_per_token_priority: 28e-6,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text",
          "image"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_web_search: true,
        supports_none_reasoning_effort: true,
        supports_xhigh_reasoning_effort: true,
        supports_minimal_reasoning_effort: true
      },
      "gpt-5.2-pro": {
        input_cost_per_token: 21e-6,
        litellm_provider: "openai",
        max_input_tokens: 272e3,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "responses",
        output_cost_per_token: 168e-6,
        supported_endpoints: [
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_vision: true,
        supports_web_search: true,
        supports_none_reasoning_effort: false,
        supports_xhigh_reasoning_effort: true,
        supports_minimal_reasoning_effort: true
      },
      "gpt-5.4": {
        cache_read_input_token_cost: 25e-8,
        cache_read_input_token_cost_above_272k_tokens: 5e-7,
        cache_read_input_token_cost_flex: 13e-8,
        cache_read_input_token_cost_priority: 5e-7,
        input_cost_per_token: 25e-7,
        input_cost_per_token_above_272k_tokens: 5e-6,
        input_cost_per_token_flex: 125e-8,
        input_cost_per_token_batches: 125e-8,
        input_cost_per_token_priority: 5e-6,
        litellm_provider: "openai",
        max_input_tokens: 105e4,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 15e-6,
        output_cost_per_token_above_272k_tokens: 225e-7,
        output_cost_per_token_flex: 75e-7,
        output_cost_per_token_batches: 75e-7,
        output_cost_per_token_priority: 3e-5,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_none_reasoning_effort: true,
        supports_xhigh_reasoning_effort: true,
        supports_minimal_reasoning_effort: true
      },
      "gpt-5.4-mini": {
        cache_read_input_token_cost: 75e-9,
        cache_read_input_token_cost_flex: 375e-10,
        cache_read_input_token_cost_batches: 375e-10,
        cache_read_input_token_cost_priority: 15e-8,
        input_cost_per_token: 75e-8,
        input_cost_per_token_flex: 375e-9,
        input_cost_per_token_batches: 375e-9,
        input_cost_per_token_priority: 15e-7,
        litellm_provider: "openai",
        max_input_tokens: 272e3,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 45e-7,
        output_cost_per_token_flex: 225e-8,
        output_cost_per_token_batches: 225e-8,
        output_cost_per_token_priority: 9e-6,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_web_search: true,
        supports_none_reasoning_effort: true,
        supports_xhigh_reasoning_effort: true,
        supports_minimal_reasoning_effort: false
      },
      "gpt-5.4-nano": {
        cache_read_input_token_cost: 2e-8,
        cache_read_input_token_cost_flex: 1e-8,
        cache_read_input_token_cost_batches: 1e-8,
        input_cost_per_token: 2e-7,
        input_cost_per_token_flex: 1e-7,
        input_cost_per_token_batches: 1e-7,
        litellm_provider: "openai",
        max_input_tokens: 272e3,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 125e-8,
        output_cost_per_token_flex: 625e-9,
        output_cost_per_token_batches: 625e-9,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_web_search: true,
        supports_none_reasoning_effort: true,
        supports_xhigh_reasoning_effort: true,
        supports_minimal_reasoning_effort: false
      },
      "gpt-5.4-pro": {
        cache_read_input_token_cost: 3e-6,
        cache_read_input_token_cost_above_272k_tokens: 6e-6,
        input_cost_per_token: 3e-5,
        input_cost_per_token_above_272k_tokens: 6e-5,
        input_cost_per_token_flex: 15e-6,
        input_cost_per_token_batches: 15e-6,
        litellm_provider: "openai",
        max_input_tokens: 105e4,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "responses",
        output_cost_per_token: 18e-5,
        output_cost_per_token_above_272k_tokens: 27e-5,
        output_cost_per_token_flex: 9e-5,
        output_cost_per_token_batches: 9e-5,
        supported_endpoints: [
          "/v1/responses",
          "/v1/batch"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: false,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_web_search: true,
        supports_none_reasoning_effort: false,
        supports_xhigh_reasoning_effort: true,
        supports_minimal_reasoning_effort: true
      },
      "gpt-5.5": {
        cache_read_input_token_cost: 5e-7,
        input_cost_per_token: 5e-6,
        litellm_provider: "openai",
        max_input_tokens: 272e3,
        max_output_tokens: 128e3,
        max_tokens: 128e3,
        mode: "chat",
        output_cost_per_token: 3e-5,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_none_reasoning_effort: true,
        supports_xhigh_reasoning_effort: true,
        supports_minimal_reasoning_effort: true
      },
      "o1-pro": {
        input_cost_per_token: 15e-5,
        input_cost_per_token_batches: 75e-6,
        litellm_provider: "openai",
        max_input_tokens: 2e5,
        max_output_tokens: 1e5,
        max_tokens: 1e5,
        mode: "responses",
        output_cost_per_token: 6e-4,
        output_cost_per_token_batches: 3e-4,
        supported_endpoints: [
          "/v1/responses",
          "/v1/batch"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: false,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_vision: true
      },
      "o3-deep-research": {
        cache_read_input_token_cost: 25e-7,
        input_cost_per_token: 1e-5,
        input_cost_per_token_batches: 5e-6,
        litellm_provider: "openai",
        max_input_tokens: 2e5,
        max_output_tokens: 1e5,
        max_tokens: 1e5,
        mode: "responses",
        output_cost_per_token: 4e-5,
        output_cost_per_token_batches: 2e-5,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_vision: true,
        supports_web_search: true
      },
      "o3-mini": {
        cache_read_input_token_cost: 55e-8,
        input_cost_per_token: 11e-7,
        litellm_provider: "openai",
        max_input_tokens: 2e5,
        max_output_tokens: 1e5,
        max_tokens: 1e5,
        mode: "chat",
        output_cost_per_token: 44e-7,
        supports_function_calling: true,
        supports_parallel_function_calling: false,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_tool_choice: true,
        supports_vision: false
      },
      "o3-pro": {
        input_cost_per_token: 2e-5,
        input_cost_per_token_batches: 1e-5,
        litellm_provider: "openai",
        max_input_tokens: 2e5,
        max_output_tokens: 1e5,
        max_tokens: 1e5,
        mode: "responses",
        output_cost_per_token: 8e-5,
        output_cost_per_token_batches: 4e-5,
        supported_endpoints: [
          "/v1/responses",
          "/v1/batch"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_parallel_function_calling: false,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_tool_choice: true,
        supports_vision: true,
        supports_web_search: true
      },
      "o4-mini": {
        cache_read_input_token_cost: 275e-9,
        cache_read_input_token_cost_flex: 1375e-10,
        cache_read_input_token_cost_priority: 5e-7,
        input_cost_per_token: 11e-7,
        input_cost_per_token_flex: 55e-8,
        input_cost_per_token_priority: 2e-6,
        litellm_provider: "openai",
        max_input_tokens: 2e5,
        max_output_tokens: 1e5,
        max_tokens: 1e5,
        mode: "chat",
        output_cost_per_token: 44e-7,
        output_cost_per_token_flex: 22e-7,
        output_cost_per_token_priority: 8e-6,
        supports_function_calling: true,
        supports_parallel_function_calling: false,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_reasoning: true,
        supports_response_schema: true,
        supports_tool_choice: true,
        supports_service_tier: true,
        supports_vision: true,
        supports_web_search: true
      },
      "o4-mini-deep-research": {
        cache_read_input_token_cost: 5e-7,
        input_cost_per_token: 2e-6,
        input_cost_per_token_batches: 1e-6,
        litellm_provider: "openai",
        max_input_tokens: 2e5,
        max_output_tokens: 1e5,
        max_tokens: 1e5,
        mode: "responses",
        output_cost_per_token: 8e-6,
        output_cost_per_token_batches: 4e-6,
        supported_endpoints: [
          "/v1/chat/completions",
          "/v1/batch",
          "/v1/responses"
        ],
        supported_modalities: [
          "text",
          "image"
        ],
        supported_output_modalities: [
          "text"
        ],
        supports_function_calling: true,
        supports_native_streaming: true,
        supports_parallel_function_calling: true,
        supports_pdf_input: true,
        supports_prompt_caching: true,
        supports_response_schema: true,
        supports_system_messages: true,
        supports_tool_choice: true,
        supports_vision: true,
        supports_web_search: true
      }
    };
  }
});

// src/lib/model-registry.ts
var TTL_MS = 4 * 60 * 60 * 1e3;
var CLOUD_TIMEOUT_MS = 1e4;
var OLLAMA_TIMEOUT_MS = 2e3;
var cache = { data: null, fetchedAt: 0, promise: null };
function resolveOllamaUrl() {
  return process.env.OLLAMA_URL || readSetting("ollama_url") || "http://localhost:11434";
}
async function fetchWithTimeout(url, init, timeoutMs) {
  const controller = new AbortController();
  const timeout = setTimeout(() => controller.abort(), timeoutMs);
  try {
    return await fetch(url, { ...init, signal: controller.signal });
  } finally {
    clearTimeout(timeout);
  }
}
async function fetchAnthropic(apiKey) {
  const res = await fetchWithTimeout(
    "https://api.anthropic.com/v1/models?limit=100",
    { headers: { "x-api-key": apiKey, "anthropic-version": "2023-06-01" } },
    CLOUD_TIMEOUT_MS
  );
  if (!res.ok) return [];
  const body = await res.json();
  return (body.data ?? []).map((m) => ({
    id: m.id,
    provider: "anthropic",
    engines: {
      claude: m.id,
      opencode: `anthropic/${m.id}`,
      pi: `anthropic/${m.id}`,
      factory: m.id
    }
  }));
}
var OPENAI_CHAT_PREFIXES = ["gpt-", "o1-", "o3-", "o4-", "codex-", "chatgpt-"];
async function fetchOpenAI(apiKey) {
  const res = await fetchWithTimeout(
    "https://api.openai.com/v1/models",
    { headers: { Authorization: `Bearer ${apiKey}` } },
    CLOUD_TIMEOUT_MS
  );
  if (!res.ok) return [];
  const body = await res.json();
  return (body.data ?? []).filter((m) => OPENAI_CHAT_PREFIXES.some((p) => m.id.startsWith(p))).map((m) => ({
    id: m.id,
    provider: "openai",
    engines: {
      codex: m.id,
      opencode: `openai/${m.id}`,
      pi: `openai/${m.id}`,
      factory: m.id
    }
  }));
}
async function fetchGoogle(apiKey) {
  const res = await fetchWithTimeout(
    `https://generativelanguage.googleapis.com/v1/models?key=${encodeURIComponent(apiKey)}`,
    {},
    CLOUD_TIMEOUT_MS
  );
  if (!res.ok) return [];
  const body = await res.json();
  return (body.models ?? []).filter((m) => m.name.includes("gemini")).map((m) => {
    const id = m.name.replace(/^models\//, "");
    return {
      id,
      provider: "google",
      engines: {
        gemini: id,
        pi: `google/${id}`
      },
      context_window: m.inputTokenLimit
    };
  });
}
async function fetchOllama() {
  const baseUrl = resolveOllamaUrl();
  const res = await fetchWithTimeout(
    `${baseUrl}/api/tags`,
    {},
    OLLAMA_TIMEOUT_MS
  );
  if (!res.ok) return [];
  const body = await res.json();
  return (body.models ?? []).map((m) => ({
    id: m.name,
    provider: "ollama",
    engines: { codex: m.name, opencode: m.name },
    local: true
  }));
}
async function fetchOpenRouter() {
  const res = await fetchWithTimeout(
    "https://openrouter.ai/api/v1/models",
    {},
    CLOUD_TIMEOUT_MS
  );
  if (!res.ok) return [];
  const body = await res.json();
  return (body.data ?? []).filter((m) => {
    return m.id.startsWith("anthropic/") || m.id.startsWith("openai/") || m.id.startsWith("google/") || m.id.startsWith("meta-llama/") || m.id.startsWith("mistralai/");
  }).map((m) => {
    const engines = {};
    if (m.id.startsWith("anthropic/")) {
      const canonical = m.id.replace("anthropic/", "");
      engines.claude = canonical;
      engines.opencode = m.id;
      engines.pi = m.id;
      engines.factory = canonical;
    } else if (m.id.startsWith("openai/")) {
      const canonical = m.id.replace("openai/", "");
      engines.codex = canonical;
      engines.opencode = m.id;
      engines.pi = m.id;
      engines.factory = canonical;
    } else if (m.id.startsWith("google/")) {
      const canonical = m.id.replace("google/", "");
      engines.gemini = canonical;
      engines.pi = m.id;
    } else {
      engines.opencode = m.id;
      engines.pi = m.id;
    }
    return {
      id: m.id.includes("/") ? m.id.split("/").slice(1).join("/") : m.id,
      provider: "openrouter",
      engines,
      context_window: m.context_length
    };
  });
}
async function fetchAllModels() {
  const cfg = getConfig();
  const fetchers = [];
  if (cfg.anthropicApiKey) fetchers.push(fetchAnthropic(cfg.anthropicApiKey).catch(() => []));
  if (cfg.openAiApiKey) fetchers.push(fetchOpenAI(cfg.openAiApiKey).catch(() => []));
  if (cfg.geminiApiKey) fetchers.push(fetchGoogle(cfg.geminiApiKey).catch(() => []));
  fetchers.push(fetchOllama().catch(() => []));
  if (process.env.OPENROUTER_ENABLED === "1") {
    fetchers.push(fetchOpenRouter().catch(() => []));
  }
  fetchers.push(fetchRemoteCatalog().then((c) => c ? catalogToModels(c) : []).catch(() => []));
  const results = await Promise.allSettled(fetchers);
  const all = [];
  for (const r of results) {
    if (r.status === "fulfilled") all.push(...r.value);
  }
  const PRIORITY = {
    anthropic: 0,
    openai: 0,
    google: 0,
    ollama: 1,
    openrouter: 2
  };
  const seen = /* @__PURE__ */ new Map();
  all.sort((a, b) => (PRIORITY[a.provider] ?? 99) - (PRIORITY[b.provider] ?? 99));
  for (const entry of all) {
    if (!seen.has(entry.id)) {
      seen.set(entry.id, entry);
    }
  }
  return Array.from(seen.values());
}
async function getModels(opts) {
  let models = await getModelsFromCache();
  if (opts?.engine) {
    models = models.filter((m) => opts.engine in m.engines);
  }
  if (opts?.provider) {
    models = models.filter((m) => m.provider === opts.provider);
  }
  if (opts?.q) {
    const q = opts.q.toLowerCase();
    models = models.filter((m) => m.id.toLowerCase().includes(q));
  }
  return models;
}
function getModelsFromCache() {
  const now = Date.now();
  if (cache.data && now - cache.fetchedAt < TTL_MS) {
    return Promise.resolve(cache.data);
  }
  if (cache.promise) return cache.promise;
  cache.promise = fetchAllModels().then((data) => {
    const fallback = buildFallbackModels();
    const seen = new Set(data.map((m) => m.id));
    const merged = [...data];
    for (const fb of fallback) {
      if (!seen.has(fb.id)) {
        merged.push(fb);
        seen.add(fb.id);
      }
    }
    cache.data = merged;
    cache.fetchedAt = Date.now();
    return cache.data;
  }).catch(() => {
    if (cache.data) return cache.data;
    const fallback = buildFallbackModels();
    cache.data = fallback;
    cache.fetchedAt = Date.now();
    return fallback;
  }).finally(() => {
    cache.promise = null;
  });
  return cache.promise;
}
var CATALOG_URL = "https://raw.githubusercontent.com/agentstep/gateway/main/packages/agent-sdk/src/lib/model-catalog.json";
var remoteCatalogCache = null;
async function fetchRemoteCatalog() {
  if (remoteCatalogCache) return remoteCatalogCache;
  try {
    const res = await fetch(CATALOG_URL, { signal: AbortSignal.timeout(5e3) });
    if (!res.ok) return null;
    remoteCatalogCache = await res.json();
    return remoteCatalogCache;
  } catch {
    return null;
  }
}
function catalogToModels(catalog) {
  const results = [];
  const PROVIDER_MAP = {
    anthropic: "anthropic",
    openai: "openai",
    vertex_ai: "google",
    "vertex_ai-language-models": "google",
    gemini: "google"
  };
  const CHAT_PREFIXES = ["claude-", "gpt-", "o1-", "o3-", "o4-", "chatgpt-", "codex-", "gemini-"];
  const SKIP_PATTERNS = [
    /\d{4}-?\d{2}-?\d{2}/,
    // date-stamped snapshots (20250101, 2025-01-01)
    /-(0125|0613|1106|0314|0301|0501|0806|1120)$/,
    // OpenAI date suffixes
    /:/
    // Ollama-style tags in catalog
  ];
  for (const [modelId, info] of Object.entries(catalog)) {
    const litellmProvider = info.litellm_provider ?? "";
    const provider = PROVIDER_MAP[litellmProvider];
    if (!provider) continue;
    if (!CHAT_PREFIXES.some((p) => modelId.startsWith(p))) continue;
    if (SKIP_PATTERNS.some((re) => re.test(modelId))) continue;
    if (modelId.includes("image") || modelId.includes("tts") || modelId.includes("audio") || modelId.includes("transcribe") || modelId.includes("diarize") || modelId.includes("realtime") || modelId.includes("search-api") || modelId.includes("embedding") || modelId.includes("exp-") || modelId.includes("computer-use") || modelId.startsWith("gpt-3.5") || modelId.startsWith("gpt-4-") || modelId.startsWith("gpt-4o") && !modelId.startsWith("gpt-4o-mini")) continue;
    const contextWindow = info.max_input_tokens ?? info.max_tokens;
    const engines = {};
    if (provider === "anthropic") {
      engines.claude = modelId;
      engines.opencode = `anthropic/${modelId}`;
      engines.pi = `anthropic/${modelId}`;
      engines.factory = modelId;
    } else if (provider === "openai") {
      engines.codex = modelId;
      engines.opencode = `openai/${modelId}`;
      engines.pi = `openai/${modelId}`;
      engines.factory = modelId;
    } else if (provider === "google") {
      engines.gemini = modelId;
      engines.pi = `google/${modelId}`;
    }
    results.push({
      id: modelId,
      provider,
      engines,
      context_window: contextWindow
    });
  }
  return results;
}
function buildFallbackModels() {
  if (remoteCatalogCache) return catalogToModels(remoteCatalogCache);
  try {
    const bundled = require_model_catalog();
    return catalogToModels(bundled);
  } catch {
    return buildLegacyFallback();
  }
}
function buildLegacyFallback() {
  const modelMap = /* @__PURE__ */ new Map();
  for (const [engine, models] of Object.entries(FALLBACK_MODELS)) {
    for (const engineModelId of models) {
      let canonicalId = engineModelId;
      let provider = "unknown";
      if (engineModelId.includes("/")) {
        const [prov, id] = engineModelId.split("/", 2);
        canonicalId = id;
        provider = prov === "anthropic" ? "anthropic" : prov === "openai" ? "openai" : prov === "google" ? "google" : prov;
      } else if (canonicalId.startsWith("claude-")) provider = "anthropic";
      else if (canonicalId.match(/^(gpt-|codex-|o[134]-)/)) provider = "openai";
      else if (canonicalId.startsWith("gemini-")) provider = "google";
      const existing = modelMap.get(canonicalId);
      if (existing) {
        existing.engines[engine] = engineModelId;
      } else {
        modelMap.set(canonicalId, { id: canonicalId, provider, engines: { [engine]: engineModelId } });
      }
    }
  }
  return Array.from(modelMap.values());
}
function _resetCache() {
  cache.data = null;
  cache.fetchedAt = 0;
  cache.promise = null;
}

export {
  getModels,
  _resetCache
};
