Function autoDetectProvider

  • Auto-detects the active provider by scanning well-known environment variables and CLI binaries in priority order.

    Returns the identifier of the first provider whose key env var is non-empty, whose base-URL env var holds more than whitespace (an empty or whitespace-only one is unset, as the call that follows reads it), or whose CLI binary is on PATH, or undefined when no recognisable runtime is present.

    Default priority: openrouter → openai → anthropic → gemini → groq → together → mistral → xai → requesty → minimax (text only) → claude-code-cli → gemini-cli → ollama → the image providers, minimax last among them.

    The order can be overridden process-wide via setProviderPriority(['anthropic', 'openai', ...]). When a custom list is installed, only the providers in that list are considered (in the order given); pass the full set you want detection to consider.

    Parameters

    • Optional task: ProviderDefaultTask

    Returns string | undefined