Chatoyant - v0.11.1
    Preparing search index...

    Function detectProviderByModel

    • Detect provider from a model name using signature matching.

      Detection priority (first match wins):

      1. OpenRouter: model contains / — OpenRouter uses org/model notation (e.g. "anthropic/claude-opus-4", "meta-llama/llama-3.1-8b"). This check runs BEFORE signature matching so that e.g. "anthropic/claude-opus-4" routes to OpenRouter, not the native Anthropic API.
      2. Native providers: model name matches a known signature
        • OpenAI: gpt-, o1-, o3-, chatgpt-
        • Anthropic: claude-*
        • xAI: grok-*
      3. No match: returns null — caller falls back to local if LOCAL_BASE_URL is set.

      Parameters

      • model: string

        Model identifier

      Returns ProviderId | null

      Provider ID if detected, null otherwise

      detectProviderByModel('gpt-4-turbo');              // 'openai'
      detectProviderByModel('claude-3-opus'); // 'anthropic'
      detectProviderByModel('grok-2'); // 'xai'
      detectProviderByModel('anthropic/claude-opus-4'); // 'openrouter' (slash notation)
      detectProviderByModel('openai/gpt-4o'); // 'openrouter' (slash notation)
      detectProviderByModel('meta-llama/llama-3.1-8b'); // 'openrouter' (slash notation)
      detectProviderByModel('Qwen3-4B-MLX'); // null (unknown → local fallback)