<?php

return [
    'anthropic' => [
        'name' => 'Anthropic',
        'models' => [
            'claude-sonnet-4-5' => ['label' => 'Claude Sonnet 4.5', 'input_cost' => 3, 'output_cost' => 15],
            'claude-haiku-4-5' => ['label' => 'Claude Haiku 4.5', 'input_cost' => 1, 'output_cost' => 5],
            'claude-opus-4-6' => ['label' => 'Claude Opus 4.6', 'input_cost' => 15, 'output_cost' => 75],
        ],
    ],
    'openai' => [
        'name' => 'OpenAI',
        'models' => [
            'gpt-4o' => ['label' => 'GPT-4o', 'input_cost' => 5, 'output_cost' => 15],
            'gpt-4o-mini' => ['label' => 'GPT-4o Mini', 'input_cost' => 0.15, 'output_cost' => 0.60],
        ],
    ],
    'google' => [
        'name' => 'Google',
        'models' => [
            'gemini-2.5-flash' => ['label' => 'Gemini 2.5 Flash', 'input_cost' => 0.5, 'output_cost' => 1.5],
            'gemini-2.5-pro' => ['label' => 'Gemini 2.5 Pro', 'input_cost' => 7, 'output_cost' => 21],
        ],
    ],
    'groq' => [
        'name' => 'Groq',
        'models' => [
            'llama-3.3-70b-versatile' => ['label' => 'Llama 3.3 70B', 'input_cost' => 0.59, 'output_cost' => 0.79],
            'llama-3.1-8b-instant' => ['label' => 'Llama 3.1 8B', 'input_cost' => 0.05, 'output_cost' => 0.08],
            'llama-4-scout-17b-16e' => ['label' => 'Llama 4 Scout', 'input_cost' => 0.11, 'output_cost' => 0.34],
            'gemma2-9b-it' => ['label' => 'Gemma 2 9B', 'input_cost' => 0.20, 'output_cost' => 0.20],
            'qwen-qwq-32b' => ['label' => 'Qwen QwQ 32B', 'input_cost' => 0.29, 'output_cost' => 0.39],
            'mixtral-8x7b-32768' => ['label' => 'Mixtral 8x7B', 'input_cost' => 0.24, 'output_cost' => 0.24],
        ],
    ],
    'openrouter' => [
        'name' => 'OpenRouter',
        // Dynamic catalog: when model_catalog.enabled, the static list below is
        // replaced by the live catalog fetched from models_endpoint (300+ models).
        // The static list remains the fallback when the endpoint is unreachable.
        'dynamic_catalog' => true,
        'models_endpoint' => env('OPENROUTER_MODELS_ENDPOINT', 'https://openrouter.ai/api/v1/models'),
        'models_endpoint_auth' => 'none', // OpenRouter /models is public (no key required)
        'catalog_adapter' => 'openrouter',
        'models' => [
            'meta-llama/llama-3.3-70b-instruct:free' => ['label' => 'Llama 3.3 70B (free)', 'input_cost' => 0, 'output_cost' => 0],
            'qwen/qwen3-coder-480b-a35b:free' => ['label' => 'Qwen3 Coder 480B (free)', 'input_cost' => 0, 'output_cost' => 0],
            'google/gemma-3-27b-it:free' => ['label' => 'Gemma 3 27B (free)', 'input_cost' => 0, 'output_cost' => 0],
            'mistralai/mistral-small-3.1-24b-instruct:free' => ['label' => 'Mistral Small 3.1 (free)', 'input_cost' => 0, 'output_cost' => 0],
            'openrouter/free' => ['label' => 'Auto (best free model)', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],

    // --- Tier 1: Named providers (native Prism support) ---

    'mistral' => [
        'name' => 'Mistral AI',
        'models' => [
            'mistral-large-latest' => ['label' => 'Mistral Large',  'input_cost' => 2.0,  'output_cost' => 6.0],
            'mistral-small-latest' => ['label' => 'Mistral Small',  'input_cost' => 0.1,  'output_cost' => 0.3],
            'codestral-latest' => ['label' => 'Codestral',      'input_cost' => 0.2,  'output_cost' => 0.6],
            'mistral-nemo-latest' => ['label' => 'Mistral Nemo',   'input_cost' => 0.15, 'output_cost' => 0.15],
        ],
    ],

    'deepseek' => [
        'name' => 'DeepSeek',
        'models' => [
            'deepseek-chat' => ['label' => 'DeepSeek V3',  'input_cost' => 0.27, 'output_cost' => 1.10],
            'deepseek-reasoner' => ['label' => 'DeepSeek R1', 'input_cost' => 0.55, 'output_cost' => 2.19],
        ],
    ],

    'xai' => [
        'name' => 'xAI (Grok)',
        'models' => [
            'grok-3' => ['label' => 'Grok 3',       'input_cost' => 3.0,  'output_cost' => 15.0],
            'grok-3-mini' => ['label' => 'Grok 3 Mini',  'input_cost' => 0.3,  'output_cost' => 0.5],
            'grok-2-latest' => ['label' => 'Grok 2',      'input_cost' => 2.0,  'output_cost' => 10.0],
        ],
    ],

    // --- Portkey AI Gateway (team-level passthrough proxy) ---
    // When a team configures a Portkey API key, ALL their AI requests are routed
    // through https://api.portkey.ai/v1. The model string is passed through verbatim.
    // Portkey supports virtual keys, observability, caching, and 250+ providers.
    // See https://portkey.ai for setup instructions.
    'portkey' => [
        'name' => 'Portkey (AI Gateway)',
        'portkey' => true,  // Marks this as a Portkey passthrough provider
        'credential_fields' => ['api_key', 'virtual_key'],
        'models' => [
            // Portkey routes to the underlying provider — model strings are passed verbatim.
            // Examples of what you can configure when using Portkey:
            'anthropic/claude-sonnet-4-5-20250929' => ['label' => 'Anthropic Claude Sonnet 4.5', 'input_cost' => 0, 'output_cost' => 0],
            'openai/gpt-4o' => ['label' => 'OpenAI GPT-4o', 'input_cost' => 0, 'output_cost' => 0],
            'google/gemini-2.5-pro' => ['label' => 'Google Gemini 2.5 Pro', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],

    // --- Tier 2: OpenAI-compatible providers (custom Prism registration) ---

    'perplexity' => [
        'name' => 'Perplexity',
        'models' => [
            'sonar-pro' => ['label' => 'Sonar Pro',       'input_cost' => 3.0,  'output_cost' => 15.0],
            'sonar' => ['label' => 'Sonar',           'input_cost' => 1.0,  'output_cost' => 1.0],
            'sonar-reasoning' => ['label' => 'Sonar Reasoning', 'input_cost' => 1.0,  'output_cost' => 5.0],
        ],
    ],

    'fireworks' => [
        'name' => 'Fireworks AI',
        'models' => [
            'accounts/fireworks/models/llama-v3p3-70b-instruct' => ['label' => 'Llama 3.3 70B',  'input_cost' => 0.9,  'output_cost' => 0.9],
            'accounts/fireworks/models/deepseek-r1' => ['label' => 'DeepSeek R1',    'input_cost' => 3.0,  'output_cost' => 8.0],
            'accounts/fireworks/models/qwen3-235b-a22b' => ['label' => 'Qwen3 235B',     'input_cost' => 0.22, 'output_cost' => 0.88],
            'accounts/fireworks/models/mixtral-8x22b-instruct' => ['label' => 'Mixtral 8x22B',  'input_cost' => 1.2,  'output_cost' => 1.2],
        ],
    ],
    'codex' => [
        'name' => 'Codex (Local)',
        'local' => true,
        'agent_key' => 'codex',
        'models' => [
            'gpt-5.3-codex' => ['label' => 'GPT-5.3 Codex', 'input_cost' => 0, 'output_cost' => 0],
            'gpt-5.2-codex' => ['label' => 'GPT-5.2 Codex', 'input_cost' => 0, 'output_cost' => 0],
            'gpt-5.1-codex-mini' => ['label' => 'GPT-5.1 Codex Mini', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],
    'claude-code' => [
        'name' => 'Claude Code (Local)',
        'local' => true,
        'agent_key' => 'claude-code',
        'models' => [
            'claude-sonnet-4-5' => ['label' => 'Claude Sonnet 4.5', 'input_cost' => 0, 'output_cost' => 0],
            'claude-opus-4-6' => ['label' => 'Claude Opus 4.6', 'input_cost' => 0, 'output_cost' => 0],
            'claude-haiku-4-5' => ['label' => 'Claude Haiku 4.5', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],
    'claude-code-vps' => [
        'name' => 'Claude Code (VPS — super-admin)',
        'local' => true,
        'vps' => true,
        'agent_key' => 'claude-code-vps',
        'models' => [
            'claude-sonnet-4-5' => ['label' => 'Claude Sonnet 4.5', 'input_cost' => 0, 'output_cost' => 0],
            'claude-opus-4-6' => ['label' => 'Claude Opus 4.6', 'input_cost' => 0, 'output_cost' => 0],
            'claude-haiku-4-5' => ['label' => 'Claude Haiku 4.5', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],
    'gemini-cli' => [
        'name' => 'Gemini CLI (Local)',
        'local' => true,
        'agent_key' => 'gemini-cli',
        'models' => [
            'gemini-2.5-pro' => ['label' => 'Gemini 2.5 Pro', 'input_cost' => 0, 'output_cost' => 0],
            'gemini-2.5-flash' => ['label' => 'Gemini 2.5 Flash', 'input_cost' => 0, 'output_cost' => 0],
            'gemini-3-pro' => ['label' => 'Gemini 3 Pro', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],
    'kiro' => [
        'name' => 'Kiro CLI (Local)',
        'local' => true,
        'agent_key' => 'kiro',
        'models' => [
            'kiro-default' => ['label' => 'Kiro (Default)', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],
    'aider' => [
        'name' => 'Aider (Local)',
        'local' => true,
        'agent_key' => 'aider',
        'models' => [
            'aider-default' => ['label' => 'Aider (Default)', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],
    'amp' => [
        'name' => 'Amp (Local)',
        'local' => true,
        'agent_key' => 'amp',
        'models' => [
            'amp-default' => ['label' => 'Amp (Default)', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],
    'opencode' => [
        'name' => 'OpenCode (Local)',
        'local' => true,
        'agent_key' => 'opencode',
        'models' => [
            'opencode-default' => ['label' => 'OpenCode (Default)', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],
    'cursor' => [
        'name' => 'Cursor (Local)',
        'local' => true,
        'agent_key' => 'cursor',
        'models' => [
            'auto' => ['label' => 'Auto (best available)',        'input_cost' => 0, 'output_cost' => 0],
            'sonnet-4' => ['label' => 'Claude Sonnet 4',              'input_cost' => 0, 'output_cost' => 0],
            'gpt-5' => ['label' => 'GPT-5',                        'input_cost' => 0, 'output_cost' => 0],
            'gemini-2.5-pro' => ['label' => 'Gemini 2.5 Pro',              'input_cost' => 0, 'output_cost' => 0],
            'composer-1.5' => ['label' => 'Composer 1.5 (Cursor native)', 'input_cost' => 0, 'output_cost' => 0],
        ],
    ],

    // RAGFlow — self-hosted deep document understanding & hybrid RAG engine
    'ragflow' => [
        'name' => 'RAGFlow (Self-Hosted)',
        'http_local' => true,
        'ragflow' => true, // marks this as a RAGFlow endpoint, not an LLM
        'default_url' => env('RAGFLOW_URL', 'http://ragflow:9380'),
        'url_hint' => 'RAGFlow base URL — e.g. http://ragflow:9380 or https://ragflow.example.com',
        'display_name' => 'RAGFlow',
        'description' => 'Deep document understanding (PDF/table/OCR), hybrid BM25+vector retrieval, RAPTOR, and GraphRAG.',
        'credential_fields' => ['api_key', 'base_url'],
        'models' => [], // RAGFlow is not an LLM provider
    ],

    // HTTP-based local LLM providers (Ollama, OpenAI-compatible endpoints)

    // Mesh LLM — distributed llama.cpp inference across machines.
    // Pools spare GPU capacity and exposes a single OpenAI-compatible API.
    // Install: curl -fsSL https://raw.githubusercontent.com/michaelneale/mesh-llm/main/install.sh | bash
    // Start:   mesh-llm serve --auto
    // Models are discovered dynamically from GET /v1/models.
    'mesh_llm' => [
        'name' => 'Mesh LLM (Local/Distributed)',
        'http_local' => true,
        'default_url' => 'http://localhost:9337/v1',
        'url_hint' => 'Mesh LLM API URL — default http://localhost:9337/v1',
        'models' => [], // Populated dynamically from GET /v1/models
    ],

    'ollama' => [
        'name' => 'Ollama',
        'http_local' => true,
        'default_url' => 'http://localhost:11434',
        'url_hint' => 'Root URL without /v1 suffix — e.g. http://localhost:11434',
        'models' => [], // Populated dynamically from GET /api/tags — never hardcoded
    ],

    'openai_compatible' => [
        'name' => 'OpenAI-Compatible',
        'http_local' => true,
        'default_url' => 'http://localhost:1234/v1',
        'url_hint' => 'URL with /v1 suffix — e.g. http://localhost:1234/v1',
        'models' => [], // Dynamic — set by the user when configuring the endpoint
    ],

    // LiteLLM proxy — routes calls to 100+ providers (Bedrock, Vertex, Cohere, Together, etc.)
    // Teams self-host a LiteLLM proxy and register its base URL here.
    // See https://docs.litellm.ai/docs/proxy/quick_start for setup instructions.
    'litellm_proxy' => [
        'name' => 'LiteLLM Proxy',
        'http_local' => true,
        'default_url' => 'http://localhost:4000',
        'url_hint' => 'Base URL of your LiteLLM proxy — e.g. http://litellm:4000 (without /v1)',
        'models' => [], // Dynamic — populated from proxy /models endpoint or set manually
    ],

    // Bridge-backed providers — routed through the FleetQ Bridge daemon
    'bridge_llm' => [
        'name' => 'Local LLM (via FleetQ Bridge)',
        'bridge' => true,
        'cost_per_token' => ['input' => 0, 'output' => 0],
        'models' => [], // Populated dynamically from bridge manifest
    ],

    'bridge_agent' => [
        'name' => 'Local AI Agent (via FleetQ Bridge)',
        'bridge' => true,
        'local' => false, // Not a CLI-based local agent — handled by the bridge
        'cost_per_token' => ['input' => 0, 'output' => 0],
        'models' => [], // Populated dynamically from bridge manifest
    ],
];
