Skip to main content
An environment is a small Python module that packages everything Flash needs to teach and grade your model: the data it practices on, how it interacts, and how its answers are scored. It is the single source of truth for what the model learns and what counts as good.

What an environment packages

Behind one load_environment() entrypoint it bundles a dataset (the prompts your model practices on, as input/output records), an interaction model (the class you subclass: one response, or a multi-turn exchange), and a reward (score_response, returning a RewardResult). That one environment drives SFT (learn from gold answers), GRPO (learn from reward scores), OPD (practice on the prompts while a managed teacher scores the model’s tokens), and eval. Swap one line in the config; the environment stays put. For SFT, each row’s output is the gold completion, appended after the environment’s initial episode so system prompts and tool transcripts stay part of the example (see Datasets for the output shapes). You write that file; Flash owns everything else, from the training loop and managed compute to checkpointing, the versioned Environments Hub, and per-token serving. The quality of your dataset and reward sets the ceiling on what training can achieve. The environment supplies the prompts for every algorithm, and the score for GRPO and eval; see How Flash works for the algorithm side.

Single-turn and multi-turn

The base class you subclass sets the interaction model:
  • EnvironmentSingleTurn: prompt in, completion out, reward computed. Most tasks start here. If your prompt messages do not include a system message, the SDK prepends the run’s prompt text as one.
  • EnvironmentMultiTurn: for conversations or tool use, where the model takes several steps before the whole sequence (its trajectory) is scored. You implement the episode hooks — start_episode (opening messages), step_episode (react to each action and decide whether the episode continues), max_episode_turns (the bound), and score_episode (reward the trajectory). See Multi-turn environments for the full loop, an action protocol, and the stateless-step pattern.
See Environments for the full SDK: prompt builders, loading dataset files, parameters, and secrets. With thinking = true, response_text is the answer text by default. It also exposes the separated reasoning trace and raw output when a reward needs them (see Environments).

From local file to managed run

You author an environment locally, but training runs on managed infrastructure, so it must be reachable by id: flash env push uploads the folder and prints an id, you put that id in [environment] id, and Flash imports it at run time. See Package & publish.

Next

Build an environment

The full SDK: author a dataset and reward, then publish it.

Datasets

Package task records and data files inside an environment.