Install & Compatibility
Where this runs
tested against v0.2.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 2.901s · 448.6MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 19.0s · import 2.832s · 437MB
208MB installed
● package 208MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Environment
✓ from hud import Environment
Used to define RL environments and scenarios.
create_agent
✓ from hud.agents import create_agent
Used to instantiate AI agents for evaluation.
hud.eval
✓ import hud; async with hud.eval(task) as ctx:
Context manager for running evaluations on tasks.
This quickstart demonstrates defining a HUD environment with a custom tool and a scenario, then running an AI agent against that scenario using `hud.eval()`. Ensure your `HUD_API_KEY` environment variable is set for authentication.
import os
from hud import Environment
from hud.agents import create_agent
# Ensure your HUD_API_KEY is set as an environment variable
# Example: export HUD_API_KEY="your_api_key_here"
hud_api_key = os.environ.get('HUD_API_KEY', '')
# Define an environment
env = Environment("my-first-env")
# Define a scenario using a tool
@env.tool()
def add(a: int, b: int) -> int:
"""Adds two numbers."""
return a + b
@env.scenario("sum-check")
async def sum_check(num1: int, num2: int):
# Prompt the agent to use the 'add' tool
answer = yield f"What is the sum of {num1} and {num2}? Use the 'add' tool."
correct = num1 + num2
# Score the agent's answer
yield 1.0 if str(correct) in str(answer) else 0.0
async def run_evaluation():
# Create a task for the scenario
task = env("sum-check", num1=5, num2=7)
# Create an agent (e.g., using a model via HUD's gateway)
agent = create_agent("gpt-4o") # or "claude-sonnet-4-5", etc.
print(f"Running task: {task.scenario_slug} with {agent.model}")
async with hud.eval(task) as ctx:
result = await agent.run(ctx)
print(f"Agent response: {result.response}")
print(f"Reward: {result.reward}")
if __name__ == "__main__":
import asyncio
if not hud_api_key:
print("Error: HUD_API_KEY environment variable not set. Please set it to run the quickstart.")
else:
asyncio.run(run_evaluation())
hud --version
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'hud'
The `hud-python` library is either not installed or not installed in the active Python environment.
fixRun `pip install hud-python` (or `uv tool install hud-python --python 3.12` for CLI) to install the library.
E0004 - Hud init ran, HUD_KEY invalid
The `HUD_API_KEY` environment variable is set but contains an invalid or empty value, preventing authentication with the HUD platform.
fixEnsure `export HUD_API_KEY="your_valid_key_here"` is set with a correct, non-empty API key obtained from `hud.ai`.
Did not load as HUD_ENABLE is undefined. Please set HUD_ENABLE=true to run Hud.
The `HUD_ENABLE` environment variable is not defined, which is required for the SDK to initialize.
fixSet `export HUD_ENABLE=true` in your environment or service configuration.
E0007 - Hud init ran, HUD_TAGS invalid JSON
The optional `HUD_TAGS` environment variable is provided but its value is not a valid JSON string, which is required for metadata tagging.
fixEnsure `HUD_TAGS` is a valid JSON-formatted string, e.g., `export HUD_TAGS='{"env":"dev", "owner":"team_x"}'`. Upgrade
Version history
0.5.41latest on PyPI · released Apr 28, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.11 or 3.12 for compatibility.