#241·dexter

Default model (gpt-5.4) ignores ANTHROPIC_API_KEY — no auto-detection of available provider

Author: ulises2kCreated May 2, 2026Updated May 2, 2026

Bug Description

When only ANTHROPIC_API_KEY is set in .env (without OPENAI_API_KEY), running bun start still attempts to use the default model gpt-5.4 (OpenAI), resulting in an authentication error:

Error: 401 Incorrect API key provided: your-ope*******-key.

Steps to Reproduce

  1. Clone the repo and run bun install
  2. In .env, set only ANTHROPIC_API_KEY=sk-ant-... (no OPENAI_API_KEY)
  3. Run bun start
  4. Ask any query (e.g. Show me what you know about me from memory.)

Expected Behavior

Either:

  • (a) The agent auto-detects which provider key is available and selects an appropriate default model, or
  • (b) On startup, if the default model's required API key is missing, show a clear error pointing the user to use /model to switch providers

Actual Behavior

The agent silently tries to call OpenAI's API with whatever value OPENAI_API_KEY has (the placeholder your-openai-api-key from env.example), producing a confusing 401 error with no indication that the fix is to run /model claude-sonnet-4-5 (or similar).

Why This Matters

The README lists ANTHROPIC_API_KEY as a valid standalone configuration:

ANTHROPIC_API_KEY=your-anthropic-api-key (optional)

New users reasonably expect setting only this key to be sufficient to run the agent against Claude.

Suggested Fix

In src/model/llm.ts (or wherever the default model is resolved), add a startup check:

typescript
// Pseudo-code
function resolveDefaultModel(): string {
  if (!process.env.OPENAI_API_KEY && process.env.ANTHROPIC_API_KEY) {
    return "claude-sonnet-4-5"; // or whatever the preferred Claude default is
  }
  if (!process.env.OPENAI_API_KEY && process.env.GOOGLE_API_KEY) {
    return "gemini-2.0-flash";
  }
  // fallback
  return DEFAULT_MODEL; // gpt-5.4
}

Alternatively, validate at startup that the required key for the configured default model exists and print a helpful message like: Default model is gpt-5.4 but OPENAI_API_KEY is not set. Use /model to switch providers (e.g. /model claude-sonnet-4-5).

Environment

  • OS: Windows 11
  • Bun version: (your version)
  • Dexter version / commit: latest main
  • .env config: only ANTHROPIC_API_KEY set