OpenBB-finance/OpenBB · error · OpenBBError

Missing credential '{c}'.{extra_msg} Refer to the documentat

Error message

Missing credential '{c}'.{extra_msg} Refer to the documentation for setting provider credentials at https://docs.openbb.co/platform/settings/user_settings/api_keys.

What it means

OpenBBError from QueryExecutor.filter_credentials: the chosen provider declares required credentials, and at execution time a required credential is absent from user settings or its secret value is empty. The message names the missing credential, links the provider's website when known, and points to OpenBB's credentials documentation. Only raised when require_credentials is true (default).

Source

Thrown at openbb_platform/core/openbb_core/provider/query_executor.py:56

        credentials: dict[str, SecretStr] | None,
        provider: Provider,
        require_credentials: bool,
    ) -> dict[str, str]:
        """Filter credentials and check if they match provider requirements."""
        filtered_credentials = {}

        if provider.credentials:
            if credentials is None:
                credentials = {}

            for c in provider.credentials:
                v = credentials.get(c)
                secret = v.get_secret_value() if v else None
                if c not in credentials or not secret:
                    if require_credentials:
                        website = provider.website or ""
                        extra_msg = f" Check {website} to get it." if website else ""
                        raise OpenBBError(
                            f"Missing credential '{c}'.{extra_msg} Refer to the documentation for setting provider "
                            "credentials at https://docs.openbb.co/platform/settings/user_settings/api_keys."
                        )
                else:
                    filtered_credentials[c] = secret

        return filtered_credentials

    async def execute(
        self,
        provider_name: str,
        model_name: str,
        params: dict[str, Any],
        credentials: dict[str, SecretStr] | None = None,
        **kwargs: Any,
    ) -> Any:
        """Execute query.

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Set the named credential: obb.user.credentials.<name_in_error> = 'KEY', or export OPENBB_<NAME>_API_KEY=...
  2. Use the exact credential name shown in the error - check obb.coverage.credentials or provider docs for the field name
  3. Persist it in openbb_settings.json / Hub account so cron and CI jobs inherit it
  4. Or switch to a provider whose credentials are already set

Example fix

# before
res = obb.equity.price.historical('AAPL', provider='benzinga')  # Missing credential

# after
obb.user.credentials.benzinga_api_key = 'YOUR_KEY'
res = obb.equity.price.historical('AAPL', provider='benzinga')
Defensive patterns

Strategy: validation

Validate before calling

from openbb import obb

def credentials_ready(provider: str) -> bool:
    spec = obb.coverage.providers.get(provider.lower())
    if not spec:
        return False
    creds = obb.user.credentials.model_dump()
    return all(creds.get(f) for f in spec.get('credentials', {}))

Type guard

def has_required_credentials(obb, provider: str) -> bool:
    import openbb
    fields = openbb.coverage.providers.get(provider.lower(), {}).get('credentials', {})
    return all(getattr(obb.user.credentials, f, None) for f in fields)

Try / catch

from openbb_core.app.model.abstract.error import OpenBBError

try:
    res = obb.equity.price.historical('AAPL', provider='benzinga')
except OpenBBError as e:
    if 'Missing credential' in str(e):
        res = obb.equity.price.historical('AAPL', provider='yfinance')  # keyless fallback
    else:
        raise

Prevention

When it happens

Trigger: Calling obb.equity.price.historical('AAPL', provider='benzinga') with no benziga/benzinga API key configured; key present in settings but empty string; key name mismatch (e.g. set 'benzinga_token' where the provider requires 'benzinga_api_key'); OPENBB_<NAME>_API_KEY env var not exported in the current shell.

Common situations: Fresh setup without keys; wrong credential key name in openbb_settings.json or .env; env var defined in one shell but the script runs in another (cron, CI, systemd); provider renamed its credential field between versions.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/2e8222309d911165. Report an issue: GitHub.