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:AIScientists Dev WorldSeed LiteLLM DM Provider

From Leeroopedia
Knowledge Sources
Domains LLM, API_Integration
Last Updated 2026-10-26 19:00 GMT

Overview

Python 3.11+ with LiteLLM and Instructor (optional `[dm]` extra) plus LLM provider API keys for DM judgment and gazette generation.

System Requirements

Category Requirement Notes
OS Linux / macOS / WSL2 Same as Python engine
Python >= 3.11 Inherits core engine requirement
Hardware CPU only No local GPU needed; LLM inference is remote
Network Internet access to LLM API Required for DM calls and model listing

Dependencies

System Packages

Python Packages (Optional `[dm]` Extra)

  • `litellm` >= 1.60, < 2
  • `instructor` >= 1.7, < 2

Notes

LiteLLM and Instructor are imported lazily — only loaded when the DM provider is first used or the models endpoint is queried. The `mypy` config marks both as `ignore_missing_imports = true` since they lack type stubs.

Credentials

The following environment variables must be set depending on the LLM provider used:

  • `OPENAI_API_KEY`: OpenAI API key (for `openai/*` models)
  • `ANTHROPIC_API_KEY`: Anthropic API key (for `anthropic/*` models)
  • `AZURE_API_KEY`: Azure OpenAI key (for `azure/*` models)
  • `GEMINI_API_KEY`: Google Gemini key (for `gemini/*` models)
  • `WORLDSEED_DM_MODEL`: Default DM model ID in `provider/model` format

LiteLLM auto-detects provider from the model string prefix and uses the corresponding env var. No single key is mandatory — only the keys for the providers you actually use.

Quick Install

# Install engine + DM extra
pip install -e ".[dm]"

# Or just the DM dependencies
pip install "litellm>=1.60,<2" "instructor>=1.7,<2"

# Set API key for your provider
export OPENAI_API_KEY="sk-..."
export WORLDSEED_DM_MODEL="openai/gpt-4o"

Code Evidence

Optional DM dependencies from `pyproject.toml:19-22`:

[project.optional-dependencies]
dm = [
    "litellm>=1.60,<2",
    "instructor>=1.7,<2",
]

Lazy import in `src/worldseed/dm/providers/llm.py:66-72`:

def _get_client(self) -> Any:
    if self._client is None:
        import instructor
        import litellm

        self._client = instructor.from_litellm(
            litellm.acompletion,
            mode=instructor.Mode.TOOLS,
        )
    return self._client

Model listing with function-calling filter from `src/worldseed/server/routes/settings.py:37-48`:

valid = litellm.get_valid_models(check_provider_endpoint=True)
for model_id in sorted(valid):
    if not litellm.supports_function_calling(model=model_id):
        continue

Common Errors

Error Message Cause Solution
`ImportError: No module named 'litellm'` DM extra not installed `pip install -e ".[dm]"`
`NotFoundError: model not found` Invalid model ID or missing API key Check `WORLDSEED_DM_MODEL` format is `provider/model`
`AuthenticationError: Invalid API key` Wrong or expired API key Set correct `OPENAI_API_KEY` / `ANTHROPIC_API_KEY`
`litellm.get_valid_models failed` No API keys set or network issue Set at least one provider API key

Compatibility Notes

  • Model format: Must use `provider/model-name` (e.g. `openai/gpt-4o`, `anthropic/claude-3-5-sonnet`). Bare model names default to OpenAI.
  • Function calling required: Only models supporting function calling work with Instructor's `Mode.TOOLS`. Non-function-calling models are filtered out in the models endpoint.
  • LiteLLM 1.x only: The `<2` constraint locks to the 1.x API surface. LiteLLM 2.x may break the Instructor integration.
  • Instructor Mode.TOOLS: Uses native function-calling/tool-use API, not JSON mode. Models without tool support will fail.
  • mypy stubs: Both `litellm` and `instructor` lack type stubs; `ignore_missing_imports = true` is set in `pyproject.toml`.

Related Pages

Page Connections

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