Skip to main content

Python SDK and CLI for the Epsilab RL Environment Hub and Marketplace.

Project description

Epsilab Python SDK

Python SDK and CLI for the Epsilab RL Environment Hub.

What is Epsilab?

Epsilab is an open hub for RL environments — like HuggingFace, but for RL. Search, run, and export training data from hosted environments, or publish your own with a single command.

  • Researchers and teams training models — search and run environments, export GRPO/DPO/SFT/KTO training data, batch evaluation
  • Environment builders — publish with epsilab deploy, immutable content-addressed releases, usage analytics
  • Open by default — public, shared, unlisted, or private visibility; auto-qualified releases

Installation

pip install epsilab

Quick Start

Deploy an environment

epsilab login
epsilab env init my-environment
cd my-environment
# implement your logic in server.py, add tasks to tasks.json
epsilab deploy

One command builds, uploads, and registers. No registry credentials needed.

Run an environment

from epsilab import Epsilab

client = Epsilab(api_key="sk-...")

# Find environments
envs = client.search_environments(domain="coding", min_quality_score=0.8)

# Create a session and interact
session = client.create_environment_session("deployment-id", task_id="task-001", seed=42)
result = client.environment_step(
    session.session_id,
    "def fibonacci(n): ...",
    session_token=session.session_token,
)
print(f"Reward: {result.reward}, Done: {result.done}")

# Export training data
export = client.create_environment_export(deployment_id="deployment-id", format="grpo")

TRL GRPO integration

def reward_fn(completions, task_ids, **kwargs):
    rewards = []
    for completion, task_id in zip(completions, task_ids):
        session = client.create_environment_session("deployment-id", task_id=task_id)
        result = client.environment_step(
            session.session_id,
            completion,
            session_token=session.session_token,
        )
        rewards.append(result.reward or 0.0)
    return rewards

Creating an Environment

An RL environment is a containerized task server. At minimum it needs:

File Purpose
Dockerfile Builds the runtime container image
server.py HTTP server implementing the environment protocol
tasks.json JSON array defining the task set

Environment protocol

Your server must expose two HTTP endpoints:

POST /reset   -> {"observation": str}
POST /step    -> {"observation": str, "reward": float, "terminated": bool, "truncated": bool}

/reset receives {"task_id": "...", "seed": 42} and returns the initial observation. /step receives {"action": "..."} and returns the step result.

tasks.json format

[
  {
    "task_id": "find-the-bug-001",
    "prompt": "Find and fix the bug in the following code...",
    "difficulty": "easy",
    "split": "train",
    "max_steps": 10
  }
]

Creating an Application Tool

Application tools are reusable plugins (e.g. GitHub, Slack, Calendar) that environments can compose together. A tool needs:

File Purpose
plugin.py AppPlugin subclass defining the tool's identity and lifecycle
api.py API route handlers (FastAPI-style)
state.py Deterministic state model for the tool
cd my-tool/
epsilab deploy    # auto-detects tool structure

CLI Commands

Command Description
epsilab login Authenticate with your API key
epsilab logout Remove stored credentials
epsilab whoami Show current auth and profile status
epsilab deploy Build, upload, and register an environment or tool
epsilab env init [slug] Scaffold a new environment project
epsilab env list List your environment listings
epsilab env search [query] Search the hub
epsilab env verify Run local preflight checks
epsilab rl sessions List your RL sessions
epsilab rl trajectory <id> View step-by-step trajectory
epsilab namespace create <slug> Create a namespace

All commands support --json for machine-readable output and -v for verbose logging.

Configuration

Environment Variable Constructor Param Description
EPSILAB_API_KEY api_key Your API key
EPSILAB_API_BASE api_base API base URL (default: production)
EPSILAB_HTTP_TIMEOUT timeout_seconds Request timeout in seconds (default: 120)
max_retries Auto-retry count for 429/5xx (default: 3)
load_dotenv Also read a local .env file (default: false)

Error Handling

from epsilab import Epsilab, AuthError, InsufficientCreditsError, RateLimitError, ApiError

client = Epsilab(api_key="sk-...")

try:
    session = client.create_environment_session("dep-id", task_id="task-001")
except AuthError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except ApiError as e:
    print(f"API error: {e.status_code}")

The SDK retries automatically on rate limits (429) and transient server errors (500, 502, 503, 504) with exponential backoff and jitter.

Examples

Script Description
examples/run_environment.py Browse, run sessions, inspect trajectories, export data
examples/grpo_training.py Use environments as live reward functions for TRL GRPO
examples/batch_evaluation.py Batch evaluation across tasks with server-side parallelism
examples/marketplace_example.py Creator and buyer marketplace workflows

Documentation

Document Description
API Reference Full method reference for all SDK features
Evaluations & More Model evaluations, voice, routing, capability matrix

License

Apache 2.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

epsilab-0.15.1.tar.gz (78.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

epsilab-0.15.1-py3-none-any.whl (94.4 kB view details)

Uploaded Python 3

File details

Details for the file epsilab-0.15.1.tar.gz.

File metadata

  • Download URL: epsilab-0.15.1.tar.gz
  • Upload date:
  • Size: 78.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for epsilab-0.15.1.tar.gz
Algorithm Hash digest
SHA256 9bbbe8dce1a84b004e23e6abea344b12c58f9e8de38fcb425f6fbd39bc1ca68f
MD5 35232630d090b84db418c94d3960a9eb
BLAKE2b-256 32d6184123bddc17ff6bafde0f671868f018d8519fddad0a9cea0875c1565fa8

See more details on using hashes here.

Provenance

The following attestation bundles were made for epsilab-0.15.1.tar.gz:

Publisher: workflow.yml on EpsilabAI/epsilab-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file epsilab-0.15.1-py3-none-any.whl.

File metadata

  • Download URL: epsilab-0.15.1-py3-none-any.whl
  • Upload date:
  • Size: 94.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for epsilab-0.15.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40025088749376094b2f42e5cae8324c6236ad874088cae8b5da04c17351484d
MD5 cdf90586daa93ecf35fff800029e2290
BLAKE2b-256 737dfa6f4d1140e912a11f3d6ea47d2c462c09fa8363f07a422b636e923af1e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for epsilab-0.15.1-py3-none-any.whl:

Publisher: workflow.yml on EpsilabAI/epsilab-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page