Environment is the unified class for defining tools, connecting to services, and formatting for any LLM provider.
Environment
Constructor
| Parameter | Type | Description | Default |
|---|---|---|---|
name | str | Environment name | "environment" |
instructions | str | None | Description/instructions | None |
conflict_resolution | ConflictResolution | How to handle tool name conflicts | PREFIX |
Context Manager
Environment must be used as an async context manager to connect:Defining Tools
@env.tool()
Register functions as callable tools:Scenarios
Scenarios define evaluation logic with two yields:Connectors
Connect to external services as tool sources.connect_hub()
Connect to a deployed HUD environment:connect_fastapi()
Import FastAPI routes as tools:| Parameter | Type | Description | Default |
|---|---|---|---|
app | FastAPI | FastAPI application | Required |
name | str | None | Server name | app.title |
prefix | str | None | Tool name prefix | None |
include_hidden | bool | Include routes with include_in_schema=False | True |
connect_openapi()
Import from OpenAPI spec:connect_server()
Mount an MCPServer or FastMCP directly:connect_mcp_config()
Connect via MCP config dict:connect_image()
Connect to a Docker image via stdio:Tool Formatting
Convert tools to provider-specific formats.OpenAI
Anthropic/Claude
Gemini
LangChain
LlamaIndex
Google ADK
Calling Tools
call_tool()
Execute tools with auto-format detection:Mock Mode
Test without real connections:| Method | Description |
|---|---|
mock(enable=True) | Enable/disable mock mode |
unmock() | Disable mock mode |
mock_tool(name, output) | Set specific mock output |
is_mock | Check if mock mode is enabled |
Properties
| Property | Type | Description |
|---|---|---|
name | str | Environment name |
prompt | str | None | Default prompt (set by scenarios or agent code) |
is_connected | bool | True if in context |
connections | dict[str, Connector] | Active connections |
Creating Tasks
Call the environment to create a Task:hud.eval():
See Also
- Evals - hud.eval() reference
- MCPServer - Building MCP servers
- Environments Guide - Getting started guide