Skip to content

[Bug] Custom OpenAI-compatible provider auth fails with 'No API key found' despite correct configuration #15096

@kevin-computa

Description

@kevin-computa

Description

Custom OpenAI-compatible providers (e.g., NVIDIA API) fail authentication with "No API key found for provider" error despite having correctly configured auth credentials in both openclaw.json and auth-profiles.json. The provider configuration is recognized by the gateway and shows in openclaw models status, but the auth lookup consistently fails at runtime, causing all requests to fall back to the first working provider.

Environment

Configuration

~/.openclaw/openclaw.json

{
  "models": {
    "providers": {
      "nvidia": {
        "baseUrl": "https://integrate.api.nvidia.com/v1",
        "api": "openai-completions",
        "models": [{
          "id": "moonshotai/kimi-k2.5",
          "name": "Kimi K2.5 (NVIDIA)",
          "cost": {"input": 0.6, "output": 3.0, "cacheRead": 0.1, "cacheWrite": 0.6},
          "reasoning": true,
          "input": ["text", "image"],
          "contextWindow": 262144,
          "maxTokens": 8192
        }]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "nvidia/moonshotai/kimi-k2.5",
        "fallbacks": ["anthropic/claude-haiku-4-5"]
      },
      "models": {
        "nvidia/moonshotai/kimi-k2.5": {
          "alias": "kimi",
          "params": {"stream": true}
        }
      }
    }
  }
}

~/.openclaw/agents/main/agent/auth-profiles.json

{
  "profiles": {
    "nvidia": {
      "type": "api_key",
      "provider": "openai",
      "key": "nvapi-..."
    }
  }
}

Steps to Reproduce

  1. Configure custom provider in models.providers with "api": "openai-completions"
  2. Add auth profile to auth-profiles.json with proper structure
  3. Restart gateway: openclaw gateway restart
  4. Check status: openclaw models status (shows provider configured, auth marked as "Missing")
  5. Make request: openclaw agent -m "test"

Expected Behavior

  • Auth system should match provider name from model string (nvidia/moonshotai/kimi-k2.5) to auth profile
  • API key should be found and used for requests
  • Requests should succeed using the configured provider

Actual Behavior

  • Gateway logs show: FailoverError: No API key found for provider "nvidia". Auth store: ~/.openclaw/agents/main/agent/auth-profiles.json
  • openclaw models status output shows auth profile exists but marks provider as "Missing auth"
  • All requests fallback to first working provider (Anthropic Claude)
  • Provider never successfully authenticates

Investigation & Attempted Solutions

Tried multiple approaches without success:

  1. ✅ Provider config with "api": "openai-completions" (required field)
  2. ✅ Various provider names: openai-nvidia, nvidia, nvidia-custom
  3. ✅ Multiple auth profile formats matching documentation
  4. ✅ Using openclaw models auth paste-token --provider nvidia
  5. ✅ Environment variable: OPENAI_NVIDIA_API_KEY in ~/.openclaw/.env
  6. ✅ Running openclaw doctor --fix
  7. ❌ Auth lookup still fails every time

Logs

Gateway startup (shows model recognized):

{"subsystem":"gateway"} agent model: nvidia/moonshotai/kimi-k2.5
{"subsystem":"gateway"} listening on ws://127.0.0.1:18789 (PID 99675)

Auth failure at runtime:

lane task error: FailoverError: No API key found for provider "nvidia". 
Auth store: /Users/computa/.openclaw/agents/main/agent/auth-profiles.json

openclaw models status output:

- openai effective=profiles | profiles=2 | openai:default=sk-proj-..., nvidia=nvapi-8w...

Missing auth
- nvidia Run `openclaw configure` or set an API key env var.

Impact

Severity: High - Blocks use of cost-effective providers

  • Custom provider costs: $0.60/$3.00 per million tokens (input/output)
  • Fallback to Claude Haiku: $1/$5 per million tokens
  • Cost impact: 10x more expensive (~$650/month additional cost at current usage)
  • Affects any custom OpenAI-compatible provider (NVIDIA, local inference, proxies)

Related Configurations That Work

  • Built-in providers (Anthropic, OpenAI, OpenRouter) work correctly
  • Direct curl requests to NVIDIA API succeed with same credentials
  • Auth system works for providers without custom names

Possible Root Cause

Auth lookup system may not properly handle:

  1. Custom provider names in model strings (e.g., nvidia/model-id)
  2. Mapping between provider name in config vs auth-profiles
  3. Dynamic provider registration vs built-in provider hardcoding

Workaround

None found. Must use built-in providers or fallback to more expensive alternatives.

Additional Context

  • Followed documentation at https://docs.openclaw.ai/gateway/authentication
  • Configuration matches examples from community guides
  • API key is valid (tested with direct curl)
  • Issue persists across multiple gateway restarts and config variations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions