Skip to content

API Server

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

API Server

DeepGym includes a FastAPI server for remote scoring.

Starting it

Dev

DEEPGYM_NO_AUTH=true deepgym serve \
  --host 127.0.0.1 \
  --port 8000 \
  --reload \
  --allow-local-exec

Production

DEEPGYM_API_KEY=your-secret-key \
DAYTONA_API_KEY=your-daytona-key \
deepgym serve --port 8000

Authentication

All production requests need an X-API-Key header:

curl -H "X-API-Key: your-secret-key" \
  -X POST http://localhost:8000/v1/run \
  -H "Content-Type: application/json" \
  -d '{"task": "...", "verifier_code": "...", "model_output": "..."}'
Env var What
DEEPGYM_API_KEY Required for production
DEEPGYM_NO_AUTH true disables auth (dev only)
DEEPGYM_ALLOW_LOCAL_EXEC true enables local execution

Endpoints

POST /v1/run

Run a single solution.

// Request
{
  "task": "Write a function coin_change...",
  "verifier_code": "import importlib.util...",
  "model_output": "def coin_change(coins, amount): ...",
  "timeout": 30
}

// Response
{
  "score": 1.0,
  "passed": true,
  "output": "{\"schema_version\": \"1.0\", ...}",
  "execution_time_ms": 142.5,
  "cases": [...]
}

POST /v1/run-batch

Run multiple solutions.

// Request
{
  "task": "...",
  "verifier_code": "...",
  "model_outputs": ["solution1", "solution2", "solution3"],
  "max_parallel": 10
}

// Response
{
  "results": [...],
  "total": 3,
  "passed": 2,
  "failed": 1,
  "avg_score": 0.67,
  "execution_time_ms": 450.0
}

POST /v1/run-async

Submit an async job. Returns a job ID.

// Response
{"job_id": "abc-123", "status": "pending"}

GET /v1/job/{job_id}

Poll for result.

{"job_id": "abc-123", "status": "completed", "result": { ... }}

GET /health

Health check (no auth).

{"status": "ok"}

Clone this wiki locally