langchain-ai/deepagents · error · NoCredentialsConfiguredError
No credentials configured. Please set one of: ANTHROPIC_API_
Error message
No credentials configured. Please set one of: ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY
What it means
Raised when no default model can be auto-detected because none of the explicit-credential providers (openai, anthropic, google_genai) have a verifiably present API key. The resolver picks a default from available credentials, so with zero keys there is nothing to choose. Callers may catch `NoCredentialsConfiguredError` to defer startup and prompt interactively.
Source
Thrown at libs/code/deepagents_code/config.py:5145
# `is True` deliberately excludes `ProviderAuthState.UNKNOWN` (which maps
# to `as_legacy_bool() -> None`). For the three explicit-credential
# providers below, an UNKNOWN result means we cannot prove auth works, so
# we fall through rather than pick an unverifiable default. If an
# implicit-auth provider (e.g., Vertex ADC) is added to this fallback
# list, switch to checking `state` against the relevant
# `ProviderAuthState` members directly.
if get_provider_auth_status("openai").as_legacy_bool() is True:
return "openai:gpt-5.6-terra"
if get_provider_auth_status("anthropic").as_legacy_bool() is True:
return "anthropic:claude-opus-5"
if get_provider_auth_status("google_genai").as_legacy_bool() is True:
return "google_genai:gemini-3.1-pro-preview"
msg = (
"No credentials configured. Please set one of: "
"ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY"
)
raise NoCredentialsConfiguredError(msg)
_OPENROUTER_APP_URL = "https://pypi.org/project/deepagents-code/"
"""Default `app_url` (maps to `HTTP-Referer`) for OpenRouter attribution.
See https://openrouter.ai/docs/app-attribution for details.
"""
_OPENROUTER_APP_TITLE = "Deep Agents Code"
"""Default `app_title` (maps to `X-Title`) for OpenRouter attribution."""
_OPENROUTER_APP_CATEGORIES: list[str] = ["cli-agent"]
"""Default `app_categories` (maps to `X-OpenRouter-Categories`) for OpenRouter."""
_cli_openrouter_profile_registered = False
"""Process-wide guard so the app's OpenRouter profile is registered exactly once."""
View on GitHub (pinned to a1af029e6e)
Solutions
- Export one of the listed keys: ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY
- Run `/auth` inside dcode to store credentials persistently
- Set an explicit default model in config.toml if you rely on implicit auth (e.g. Vertex ADC) that this legacy fallback does not check
Example fix
// before $ dcode NoCredentialsConfiguredError: No credentials configured... // after $ export ANTHROPIC_API_KEY=sk-ant-... $ dcode # auto-detects anthropic:claude-opus-5
Defensive patterns
Strategy: validation
Validate before calling
import os
missing = [k for k in ("ANTHROPIC_API_KEY", "OPENAI_API_KEY", "GOOGLE_API_KEY") if not os.environ.get(k)]
if len(missing) == 3:
raise SystemExit("Set at least one of: " + ", ".join(missing)) Type guard
def has_any_default_credential() -> bool:
import os
return any(os.environ.get(k) for k in ("ANTHROPIC_API_KEY", "OPENAI_API_KEY", "GOOGLE_API_KEY")) Try / catch
from deepagents_code.model_config import NoCredentialsConfiguredError
try:
model_spec = resolve_default_model_spec()
except NoCredentialsConfiguredError:
prompt_for_credentials_interactively() # e.g. launch /auth flow Prevention
- Export a provider key in your shell profile and confirm it sources in non-interactive shells
- Use `/auth` to persist credentials instead of relying on env vars per session
- In CI, verify secret injection with a preflight `os.environ` check
When it happens
Trigger: Calling the default-model resolver when `models.allowed` is not configured, no default/recent model is stored, and `get_provider_auth_status(...).as_legacy_bool()` is not True for openai, anthropic, or google_genai — i.e. ANTHROPIC_API_KEY, OPENAI_API_KEY, and GOOGLE_API_KEY are all unset/empty (config.py:5134-5145).
Common situations: Fresh install before running `/auth`; CI/Docker containers launched without secret env vars; keys exported only in an interactive shell profile while the app runs under systemd/cron; typo'd env var name (e.g. ANTHROPIC_API_TOKEN).
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- No credentials are configured for any model in models.allowe
- Google Cloud location is required for provider 'google_anthr
- No credentials found for provider '{provider}'. Please set t
- modes can only be provided when agent is a factory
- models can only be provided when agent is a factory
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/8aa6cc142401e71c.
Report an issue: GitHub.