Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:416rehman DeepZero LLM API Keys

From Leeroopedia
Knowledge Sources
Domains Infrastructure, LLMs
Last Updated 2026-10-27 00:00 GMT

Overview

API-key credentials for metered LLM access via LiteLLM, covering any endpoint litellm supports (OpenAI, Anthropic, Gemini, etc.).

Description

This environment provides the API keys required by the `LiteLLMBackend` — the default fallback backend for any model string whose scheme is not claimed by a more specific backend. DeepZero does not hardcode provider names; litellm's `validate_environment()` checks which keys the chosen model needs and reports any that are missing. Keys are loaded from `.env` via `python-dotenv` or set directly in the shell environment.

Usage

Use this environment when a pipeline's `model` string does not use a CLI-agent scheme (e.g. `openai/gpt-4o`, `gemini/gemini-1.5-pro`, or a bare `gpt-4o`). Any unregistered scheme falls through to the LiteLLM backend, which requires the corresponding provider's API key. It is the mandatory prerequisite for the LiteLLMBackend implementation.

System Requirements

Category Requirement Notes
OS Any Keys are environment variables
Hardware Any No special hardware
Disk None Keys live in environment / `.env`

Dependencies

System Packages

  • None beyond the base Python environment

Python Packages

  • `litellm` >= 1.0 (installed via `pip install -e ".[llm]"`)
  • `python-dotenv` >= 1.0.0 (for `.env` loading)

Credentials

The following environment variables may be required, depending on the model string's provider. LiteLLM's `validate_environment()` determines which are needed at pipeline load time:

  • `OPENAI_API_KEY` — OpenAI models (e.g. `openai/gpt-4o`)
  • `ANTHROPIC_API_KEY` — Anthropic API models (e.g. `anthropic/claude-3-opus`)
  • `GEMINI_API_KEY` or `GOOGLE_API_KEY` — Google Gemini models
  • `AZURE_API_KEY`, `AZURE_API_BASE`, `AZURE_API_VERSION` — Azure OpenAI
  • `COHERE_API_KEY` — Cohere models
  • `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` — Bedrock models

Never commit actual key values to the repository. Use a local `.env` file (gitignored) or inject via CI secrets.

Quick Install

# Install litellm extra
pip install -e ".[llm]"

# Set API key (example: OpenAI)
export OPENAI_API_KEY="sk-..."

# Or add to .env file
echo 'OPENAI_API_KEY=sk-...' >> .env

Code Evidence

LiteLLM import check from `backends/litellm_backend.py:36-40`:

try:
    import litellm
except ImportError as exc:
    raise ImportError(
        "litellm is required for LLM support. install with: pip install litellm"
    ) from exc

Environment validation via litellm at pipeline load from `backends/litellm_backend.py:61-75`:

@classmethod
def validate_model(cls, model: str) -> list[str]:
    try:
        import litellm
    except ImportError:
        return ["LLM configured, but 'litellm' framework is not installed"]

    env_state = litellm.validate_environment(model=model)
    if not env_state.get("keys_in_environment", True):
        missing_keys = env_state.get("missing_keys", [])
        if missing_keys:
            return [
                f"LLM backend '{model}' missing credentials in environment. "
                f"Need: {missing_keys}"
            ]
    return []

Default fallback registration from `backends/__init__.py:43-44`:

# litellm is the fallback for any scheme no other backend claims
register_backend(LiteLLMBackend, default=True)

Common Errors

Error Message Cause Solution
`LLM configured, but 'litellm' framework is not installed` `[llm]` extra not installed `pip install -e ".[llm]"`
`LLM backend 'openai/gpt-4o' missing credentials in environment. Need: ['OPENAI_API_KEY']` API key env var not set Set the key in `.env` or shell environment
`no backend can handle model '...' and no default backend is registered` No backends registered Ensure `deepzero.engine.backends` is imported

Compatibility Notes

  • Provider-agnostic: Any provider litellm supports works; the model string's scheme determines which key is needed.
  • Default fallthrough: Unregistered schemes (e.g. `gpt-4o` with no `/`) land on LiteLLM. See Heuristic:416rehman_DeepZero_Default_Fallthrough.
  • Noisy logging suppressed: `litellm.suppress_debug_info = True` and the litellm logger is set to CRITICAL to reduce traceback spam.
  • CLI-agent keys blocked: When a CLI-agent backend (e.g. ClaudeCodeBackend) is selected, metered API keys are stripped from the child environment so the CLI uses its own subscription auth.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment