What Programming Languages Does OpenEnv Support? A Complete Guide to Python SDK and Docker Environments
OpenEnv provides a Python-first SDK for client interactions while supporting any programming language inside Docker-isolated environments through its language-agnostic container architecture.
OpenEnv is a HuggingFace framework designed for interacting with agentic execution environments via simple Gymnasium-style APIs. While the primary tooling and client libraries are implemented in Python, the underlying architecture leverages Docker containers to enable developers to write environment logic in virtually any programming language. This dual-layer approach makes OpenEnv accessible to Python developers while remaining flexible enough for polyglot system implementations.
Python-First Client SDK
The OpenEnv ecosystem is built around a core Python SDK that handles all client-side interactions. According to the OpenEnv source code, the repository provides standard Python modules that expose both asynchronous and synchronous APIs for environment management.
Core Python Implementation
The heart of the client-side implementation resides in src/openenv_core/__init__.py, which exposes the primary EnvClient class and associated helper utilities. The public client libraries—including EchoEnv and CodingEnv—are Python modules that wrap WebSocket communication with containerized environments.
When you import from the OpenEnv ecosystem, you are working with pure Python interfaces:
from echo_env import CallToolAction, EchoEnv
async def main() -> None:
async with EchoEnv(base_url="https://openenv-echo-env.hf.space") as client:
result = await client.reset()
print(result.observation.echoed_message)
result = await client.step(
CallToolAction(
tool_name="echo_message",
arguments={"message": "Hello, OpenEnv!"},
)
)
print(result.observation.result)
Synchronous and Asynchronous APIs
OpenEnv supports both sync and async Python patterns. The asynchronous client uses async/await syntax for non-blocking operations, while the synchronous wrapper provides a blocking interface for simpler scripts:
from echo_env import CallToolAction, EchoEnv
with EchoEnv(base_url="https://openenv-echo-env.hf.space").sync() as client:
result = client.reset()
result = client.step(
CallToolAction(
tool_name="echo_message",
arguments={"message": "Sync call!"},
)
)
print(result.observation.result)
The sync() method returns a blocking client instance that mirrors the async API but executes calls synchronously, making it compatible with standard procedural Python code.
Language-Agnostic Environment Architecture
While the client libraries are Python-specific, OpenEnv environments themselves are language-agnostic. Each environment runs inside an isolated Docker container, decoupling the client language from the environment implementation language.
Docker Container Isolation
The architecture diagram in README.md illustrates how the Python-based client communicates over WebSockets with Docker containers hosting the actual environments. This containerization layer means any language that can execute within a Docker image—such as C++, Java, Rust, JavaScript, or Go—can implement environment logic.
The container-based approach offers complete runtime flexibility. Developers write environment servers in their preferred language, package them as Docker images, and expose them via WebSocket endpoints that the Python client consumes.
WebSocket Communication Protocol
The communication protocol between client and environment is transport-agnostic at the language level. As implemented in envs/echo_env/client.py and envs/coding_env/client.py, the Python clients establish WebSocket connections to the containerized servers, sending action objects and receiving observation states regardless of the server's implementation language.
Implementing Custom Environments in Any Language
Creating a new OpenEnv environment involves two distinct layers: the Python client scaffolding and the Docker-based server implementation.
Python Scaffolding with openenv init
The openenv init <env_name> command generates a Python package structure including pyproject.toml, models.py, and client.py files. This scaffolding provides the Python interface that users will import, even when the underlying environment logic is written in another language.
Key generated files include:
README.md- High-level overview and quick-start examplessrc/openenv_core/__init__.py- Core package exposing Python client APIenvs/<env_name>/client.py- Concrete Python client implementationexamples/- Sample Python scripts demonstrating environment interaction
Multi-Language Docker Examples
The actual environment server can be implemented in any language capable of handling WebSocket connections and HTTP requests. For example, a Rust-based environment would use a Dockerfile like this:
# Example Dockerfile for a Rust environment
FROM rust:1.78-slim
COPY src/ /app/
WORKDIR /app
RUN cargo build --release
CMD ["./target/release/my_env_server"]
The server implementation inside the container handles the Gymnasium-style API endpoints (reset, step, close) while the Python client remains unaware of the implementation language. The envs/coding_env/server/ directory in the repository provides templates for building these multi-language environments.
Summary
- Primary SDK Language: OpenEnv's client libraries (
EnvClient,EchoEnv,CodingEnv) and core tooling are implemented in Python with both async and sync APIs. - Environment Language Support: Any programming language runnable in Docker (Rust, C++, Java, JavaScript, Go, etc.) can implement environment logic.
- Architecture Pattern: Python clients communicate via WebSockets with containerized environments, creating a language-agnostic boundary.
- Development Workflow: The
openenv initcommand scaffolds Python client code while Docker configurations determine the environment's implementation language.
Frequently Asked Questions
Is OpenEnv only for Python developers?
No, while the client SDK requires Python to interact with environments, the environments themselves can be written in any language. Non-Python developers can implement environment servers in their preferred language using Docker containers, while Python developers use the provided client libraries to interact with those environments through standardized APIs.
Can I write an OpenEnv environment in Rust or C++?
Yes. Since environments run inside Docker containers, you can implement the server logic in Rust, C++, or any compiled or interpreted language. The container must expose the required HTTP/WebSocket endpoints that the Python client expects, but the internal implementation is language-agnostic.
How does the Python client communicate with non-Python environments?
The Python client establishes WebSocket connections to the containerized environment servers. As shown in envs/echo_env/client.py, the client sends serialized action objects (like CallToolAction) and receives observation states over this connection. The transport protocol is language-neutral JSON over WebSockets, allowing seamless communication regardless of the server's implementation language.
What files are generated when initializing a new environment?
Running openenv init <env_name> creates a Python package structure including pyproject.toml for dependency management, models.py for data structures, and client.py for the client implementation. The scaffolding also includes Docker configuration files in envs/<env_name>/server/ where you define the runtime environment for your chosen implementation language.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →