Rate this Page
★ ★ ★ ★ ★

Your First Environment#

Note

Coming Soon — this page will contain a streamlined guide to building your first OpenEnv environment. For now, see the full environment builder guide.

Overview#

Building an OpenEnv environment involves:

  1. Define your models - Action, Observation, and State types

  2. Implement the environment - Core logic in a Python class

  3. Create the server - FastAPI wrapper for HTTP access

  4. Package for deployment - Docker container and manifest

Quick Example#

Here’s a minimal environment that echoes back messages:

from pydantic import BaseModel
from openenv.core import Environment

class EchoAction(BaseModel):
    message: str

class EchoObservation(BaseModel):
    echo: str

class EchoState(BaseModel):
    last_message: str = ""

class EchoEnvironment(Environment[EchoAction, EchoObservation, EchoState]):
    def reset(self) -> EchoObservation:
        self.state = EchoState()
        return EchoObservation(echo="Ready!")

    def step(self, action: EchoAction) -> tuple[EchoObservation, float, bool]:
        self.state.last_message = action.message
        return EchoObservation(echo=action.message), 0.0, False

Next Steps#