Skip to content

Could not load provider 'azure-openai' #141

@paulbatum

Description

@paulbatum

I'm unable to configure the Azure OpenAI provider using amplifier provider use azure-openai. The command fails with:

Error: Could not load provider 'azure-openai'
Configuration cancelled.

Other providers (anthropic, openai) work fine.

Image Image

Steps to Reproduce:

  1. Install amplifier: uv tool install git+https://github.com/microsoft/amplifier
  2. Run: amplifier init (successfully installs all providers including azure-openai)
  3. Run: amplifier provider list (shows azure-openai in the list)
  4. Run: amplifier provider use azure-openai
  5. Error occurs immediately before any configuration prompts

Expected Behavior:

The command should prompt for Azure OpenAI configuration (endpoint, deployment, credentials) similar to how other providers work.

Actual Behavior:

The command fails immediately with "Could not load provider 'azure-openai'" before showing any prompts.

Root Cause

please note that the following analysis was generated by claude code and has not been independently verified:

The issue is in how the Azure OpenAI provider validates credentials during init():

amplifier-module-provider-azure-openai/init.py, lines 138-141

if api_key is None and token_provider is None:
raise ValueError("api_key or token_provider must be provided")

client = AsyncOpenAI(base_url=base_url, api_key=api_key or token_provider)

When amplifier provider use calls get_provider_info() to discover configuration fields, it uses _try_instantiate_provider() with placeholder credentials (empty string for api_key). The Azure OpenAI provider:

  1. Accepts the empty string (passes the None check)
  2. But then the underlying AsyncOpenAI client rejects the empty api_key with: "The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable"

This causes get_provider_info() to return None, which causes the "Could not load provider" error.

Why Other Providers Work:

The anthropic, openai, and ollama providers don't validate credentials or create clients during init() - they defer client creation until first use. This allows them to be instantiated for discovery purposes (calling get_info()) without valid credentials.

Suggested Fix:

The Azure OpenAI provider should allow instantiation without valid credentials, similar to other providers. Options:

  1. Lazy client initialization: Don't create the AsyncOpenAI client in init(), create it on first use
  2. Make credentials optional for info/discovery: Add a flag or separate method that allows getting provider info without credentials
  3. Accept placeholder credentials: Modify the validation to allow placeholder/empty values when the provider is being instantiated for discovery only

Environment:

  • amplifier version: Latest from main branch (installed via uv tool install git+https://github.com/microsoft/amplifier)
  • Python: 3.12.11
  • OS: Linux (WSL2)
  • All providers cached in ~/.amplifier/module-cache/ with latest commits

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions