Skip to content

Getting Started

Abhishek Gahlot edited this page Mar 27, 2026 · 1 revision

Getting Started

Installation

Local mode (no external dependencies)

pip install deepgym

With Daytona sandbox support

pip install deepgym[daytona]

Full dev install

git clone https://github.com/DeepGym/deepgym.git
cd deepgym
pip install -e ".[all]"

Dependency groups

Extra What it adds
daytona Daytona SDK for sandboxed execution
dev pytest, pytest-asyncio, ruff, mypy
hf huggingface_hub, datasets
lm-eval lm-eval harness integration
all Everything above

First run

from deepgym import DeepGym, load_environment

# Create a client in local mode (no Daytona needed)
dg = DeepGym(mode='local')

# Load a built-in environment
env = load_environment('coin_change')

# Write a solution
solution = '''
def coin_change(coins, amount):
    dp = [float('inf')] * (amount + 1)
    dp[0] = 0
    for coin in coins:
        for x in range(coin, amount + 1):
            dp[x] = min(dp[x], dp[x - coin] + 1)
    return dp[amount] if dp[amount] != float('inf') else -1
'''

# Run and get a score
result = dg.run(env, model_output=solution)
print(f'Score: {result.score}')        # 1.0
print(f'Passed: {result.passed}')      # True
print(f'Time: {result.execution_time_ms:.0f}ms')

What comes back

dg.run() returns a RunResult:

Field Type What it is
score float 0.0 to 1.0
passed bool Whether all tests passed
output str Verifier stdout
stderr str Verifier stderr
exit_code int 0=pass, 1=fail, 2=error
execution_time_ms float Wall-clock time
reward_components dict Shaped rewards (correctness, efficiency, etc.)
cases list[CaseResult] Per-test breakdown
error_type str timeout, verifier_error, sandbox_error, or None

Choosing a sandbox mode

# Local: fast, no isolation, fine for dev
dg = DeepGym(mode='local')

# Daytona: full container isolation, use for untrusted code
dg = DeepGym(mode='daytona')

# Auto (default): tries Daytona if DAYTONA_API_KEY is set, falls back to local
dg = DeepGym(mode='auto')

More details in Sandbox Modes.


Setting up Daytona

Option A: Self-hosted (local Docker)

git clone https://github.com/daytonaio/daytona
cd daytona
docker compose -f docker/docker-compose.yaml up -d

Dashboard at http://localhost:3000 (dev@daytona.io / password).

export DAYTONA_API_URL=http://localhost:3000
export DAYTONA_API_KEY=your-local-key

Option B: Daytona Cloud

  1. Sign up at app.daytona.io
  2. Grab your API key from the dashboard
export DAYTONA_API_KEY=your-cloud-key

Next steps

Clone this wiki locally