> ## Documentation Index
> Fetch the complete documentation index at: https://docs.novita.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Novita AI model APIs are OpenAI-compatible. Base URL: https://api.novita.ai/openai. Anthropic-compatible base URL: https://api.novita.ai/anthropic.
> Authenticate with `Authorization: Bearer <API_KEY>`; with Anthropic SDKs or Claude Code, pass the same key as `ANTHROPIC_AUTH_TOKEN`. Users create keys at https://novita.ai/settings/key-management. Never print or hardcode a real key.
> Get current model IDs from GET https://api.novita.ai/openai/v1/models instead of reusing model names from memory.

# Miles

> Run agent task environments on Novita Sandbox through Miles' Harbor and OpenEnv recipes.

[Miles](https://github.com/radixark/miles) is RadixArk's open-source framework for large-scale reinforcement learning and model post-training. It pairs SGLang for high-throughput rollout with Megatron-LM (or FSDP2 / torchtitan) for training, and ships connectors for agentic environments such as Harbor, HUD, NeMo Gym, OpenEnv and Verifiers.

Novita Sandbox is listed as a sandbox provider in Miles. The current integration covers the experimental Harbor and OpenEnv recipes on Miles' `main` branch.

Training a tool-using agent means giving it somewhere to act: run a command, inspect a file, observe what happened, and try again. Miles coordinates the reinforcement learning workflow, and its environment connectors link agent interactions to tasks and feedback. Novita supplies the sandboxes where the supported tasks execute.

The split is simple. The training stack handles model generation and policy updates, and the sandbox provides the task execution environment. You connect the two with the documented recipes instead of writing a provider integration of your own.

## Supported paths

| Recipe | What it does |
| - | - |
| Harbor | Runs Harbor trials from the Miles rollout worker, with the task environment hosted on Novita. Task data, dependencies and network requirements follow the Miles Harbor recipe. |
| OpenEnv | Uses Novita with the Terminal-Bench-2 recipe. This path builds a named template for each task and starts each episode's sandbox from that template. Templates can be prepared ahead of a training run. |

## Prerequisites

* A Novita account and API key. Set it as `NOVITA_API_KEY`, or point `NOVITA_API_KEY_FILE` at a file containing the key. The default lookup path is `~/.config/novita/api_key`.
* A working Miles installation with the model and GPU environment prepared, following the [Miles installation guide](https://miles.radixark.com/docs/getting-started/installation). Selecting a sandbox backend is only one part of the setup. The full training command follows the Miles recipe.
* For the OpenEnv path: a Terminal-Bench-2 task checkout and the OpenEnv `tbench2_env` client. See [Hugging Face OpenEnv](https://docs.novita.ai/guides/sandbox-integrations-openenv.md) for how OpenEnv environments run on Novita Sandbox.
* For the Harbor path: the `harbor-miles-v0.20.0` branch of `harbor-framework/harbor`, installed with uv and the `harbor[novita]` extra. See [Harbor Integration](https://docs.novita.ai/guides/sandbox-integrations-harbor.md) for the Novita side of the Harbor configuration.

## Quickstart

### OpenEnv

Run the following from the Miles repository. Replace the placeholder with your real key.

```bash CLI icon="terminal" theme={"system"}
export NOVITA_API_KEY="<YOUR_NOVITA_API_KEY>"
pip install -e ".[novita]"

cd examples/experimental/openenv
export OPENENV_TB2_TASKS_DIR=/path/to/terminal-bench-2
export OPENENV_SANDBOX_BACKEND=novita
python run-openenv-tbench2.py
```

The `novita` extra installs `novita-sandbox>=2.0.7`. Setting `OPENENV_SANDBOX_BACKEND=novita` selects Novita as the provider.

You can build the per-task templates ahead of time so the first training episode does not wait for the image build:

```bash CLI icon="terminal" theme={"system"}
python tb2_sandbox_novita.py --tasks-dir /path/to/terminal-bench-2 --all
```

Start with a small task set and check that the environments come up before you commit GPU time to a longer run or build templates for every task.

### Harbor

Install Harbor from the `harbor-miles-v0.20.0` branch with the `harbor[novita]` extra, then launch with `HARBOR_ENV_TYPE=novita`:

```bash CLI icon="terminal" theme={"system"}
export NOVITA_API_KEY="<YOUR_NOVITA_API_KEY>"
uv pip install "harbor[novita] @ git+https://github.com/harbor-framework/harbor@harbor-miles-v0.20.0"

HARBOR_ENV_TYPE=novita python examples/experimental/harbor/run.py \
    --harbor-tasks-dir /path/to/harbor_tasks \
    --prompt-data /path/to/tb2_train.jsonl \
    --session-server-external-host <trainer-address-reachable-from-the-sandboxes>
```

Data preparation, model and GPU arguments, and network layout follow the [Miles Harbor recipe](https://github.com/radixark/miles/tree/main/examples/experimental/harbor).

## Configuration

| Variable | Purpose |
| - | - |
| `NOVITA_API_KEY` | Novita API key. Takes precedence over the key file. |
| `NOVITA_API_KEY_FILE` | Path to a file containing the key. Default `~/.config/novita/api_key`. |
| `NOVITA_DOMAIN` | Region domain. Default `us-phx-1.sandbox.novita.ai`. `sandbox.novita.ai` is the legacy `us-virginia-1` endpoint. |
| `NOVITA_API_URL` / `NOVITA_SANDBOX_URL` | Endpoint overrides, read by the SDK itself. Forwarded by Miles when set. |
| `OPENENV_SANDBOX_BACKEND` | Set to `novita` to use this provider for OpenEnv per-episode sandboxes. |
| `HARBOR_ENV_TYPE` | Set to `novita` to use this provider for Harbor trials. |
| `OPENENV_NOVITA_SANDBOX_TTL_S` | Sandbox TTL in seconds. Default `1800`. See [How it works](#how-it-works). |

## How it works

* **Deterministic templates.** Each task's template name is derived from the task ID plus a digest of the build recipe (base image, build commands, resources, build user and start command). Repeated episodes reuse the template. Editing the recipe produces a new template name instead of silently serving a stale one.
* **Per-episode sandboxes.** Each episode starts a sandbox from the template, launches the env server as root, waits for its health endpoint on the sandbox's public host, and kills the sandbox when the episode ends.
* **TTL with keepalive.** Sandboxes are created with a bounded lifetime. A keepalive thread re-arms the TTL while the creating process is alive. If the caller is hard-killed, the sandbox is reclaimed within the TTL instead of running forever.
* **Concurrency and rate limits.** Sandbox creation is bounded by a configurable concurrency limit, and rate-limit responses from the Novita API are retried.

## Links

* [Miles: Sandbox Providers](https://miles.radixark.com/docs/user-guide/sandbox-providers)
* [Miles: Harbor recipe](https://github.com/radixark/miles/tree/main/examples/experimental/harbor)
* [Miles: OpenEnv recipe](https://github.com/radixark/miles/tree/main/examples/experimental/openenv)
* [Miles on GitHub](https://github.com/radixark/miles)
* [Integration PR](https://github.com/radixark/miles/pull/4435)
* [Harbor Integration](https://docs.novita.ai/guides/sandbox-integrations-harbor.md)
* [Hugging Face OpenEnv](https://docs.novita.ai/guides/sandbox-integrations-openenv.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.