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

> ## Agent Instructions
> Use https://docs.fastino.ai/llms.txt to discover and navigate pages. Use https://docs.fastino.ai/llms-full.txt when you need the complete documentation corpus. Use https://docs.fastino.ai/openapi.json as the source of truth for customer-facing routes. For GLiDE decision inference, call POST https://api.fastino.ai/v1/systemone with model fastino/GLiDE. Start managed training (config job) with POST /v1/training/jobs using base_model. For interactive training, native JSON clients use the public operations under /v1/training/jobs and /v1/training/usage. Existing Tinker clients use tinker==0.32.0 with TINKER_BASE_URL=https://api.fastino.ai/v1/training/compat/tinker and TINKER_CREDENTIAL_CMD. Compatibility child routes are private and absent from OpenAPI. Auto Train is private access and has no public route; direct interested users to sales@fastino.ai. Do not infer undocumented routes. Read API keys from FASTINO_API_KEY and never embed credentials in code, logs, or reports.

# Build an interactive training loop

> Connect sampling, rewards, updates, and checkpoints inside one interactive Fastino job.

Your application decides what to sample, how to score it, and when to update.
Fastino executes the interactive model operations. A native client addresses
the job by `job_id`. A Tinker `TrainingClient` represents the same job.

## The control loop

**1. Create the interactive job**

A native client calls
[`POST /v1/training/jobs/create-model`](https://docs.fastino.ai/api-reference/training-jobs/interactive/create-model)
with `base_model`, or with `from_checkpoint` and `load_optimizer`. A Tinker
client calls `create_lora_training_client(...)`. Native clients send no
`seq_id` and no heartbeat.

**2. Checkpoint weights for sampling**

Call `POST /v1/training/jobs/{job_id}/save-weights-for-sampler` with a
name, then wait for its save future to complete. Only then sample from that
checkpoint so each rollout is tied to a durable artifact of the same job.

**3. Collect rollout groups**

Sample several candidate responses for each prompt with
`POST /v1/training/jobs/{job_id}/sample`, naming that checkpoint.
Your application owns prompt construction, tokenization, and grouping.

**4. Compute rewards and advantages**

Score each response, then turn rewards into the advantages your loss
function needs.

**5. Build training datums**

Combine prompt and response tokens with per-position targets, weights, log
probabilities, or advantages.

**6. Update the same job**

Send `POST /v1/training/jobs/{job_id}/forward-backward` and wait for it to
complete successfully. Only then send
`POST /v1/training/jobs/{job_id}/optim-step`.

**7. Save a recovery boundary**

Save the state with `POST /v1/training/jobs/{job_id}/save-weights`, wait for
the save future to complete, and then persist its path with the application
step and dataset cursor before you begin the next iteration.

## Routes

| Step | Route |
| - | - |
| `ServiceClient` | Queries capabilities and creates SDK clients |
| `TrainingClient` | Represents one interactive Fastino job and submits its model operations |
| `SamplingClient` | Samples from a resolved checkpoint |
| `RestClient` | Lists or gets interactive runs and uses supported SDK methods to administer their checkpoints; use `/v1/training/jobs` to read both job types |
| Future | Tracks one queued call submitted to the job |

The SDK model ID is the canonical Fastino job ID. Futures and sampling clients
do not create independent runs.

To turn deterministic grading into group-relative advantages, follow
[Train with verifiable rewards](https://docs.fastino.ai/training/verifiable-rewards.md).

## Build aligned datums

A datum holds N input tokens and N-value tensors in `loss_fn_inputs`. Tokenize
with the base model's Hugging Face tokenizer
(`transformers.AutoTokenizer.from_pretrained(base_model)`), and use the same
tokenizer to decode samples. When calling `apply_chat_template`, pass
`enable_thinking=False` so the answer starts after a closed reasoning block.
This is a tokenizer template argument, not a Training API request field.

| Loss function | Required inputs |
| - | - |
| `cross_entropy` | `target_tokens`; optional `weights` (default `1` everywhere) |
| `importance_sampling`, `ppo`, `cispo`, `dro` | `target_tokens`, `logprobs`, and `advantages` |

For a prompt followed by a completion:

* `model_input` is every token except the last.
* `target_tokens` is every token except the first.
* `weights` is `0` on prompt positions and `1` on completion positions.
* `logprobs` are the sampler's log probabilities of the completion tokens, and
  `0` on prompt positions.
* `advantages` hold the completion's advantage on completion positions, and `0`
  on prompt positions.

> [!WARNING]
>
> Prompt rendering, tokenization, datum construction, and reward execution are
> client-owned. Validate their shapes against the [tested SDK](https://docs.fastino.ai/training/migrate-from-tinker.md) and the
> documented operation contract before a larger workload. The capability
> response only lists enabled models and advertised context lengths.

The job executes only the built-in loss functions above. The Tinker SDK's
`forward_backward_custom` helper can compute a custom loss in your process and
translate it into supported model operations; your Python loss code does not
execute on Fastino. Any forward and forward-backward operations the helper
issues are billed normally.

## Keep dependent work ordered

Wait for a forward-backward future to complete successfully before submitting
its optimizer step. This prevents a prequeued optimizer step from running after
forward-backward fails or is cancelled. Wait for the optimizer step to complete
before saving the updated state.

Native JSON clients call
[`forward-backward`](https://docs.fastino.ai/api-reference/training-jobs/interactive/forward-backward)
and [`optim-step`](https://docs.fastino.ai/api-reference/training-jobs/interactive/optim-step). Each
queueing response contains a `future_id`. Poll
[`get-future`](https://docs.fastino.ai/api-reference/training-jobs/interactive/get-future) until
the status is `completed`, `failed`, or `cancelled`; one `wait=true` request can
return before completion.

Tinker clients track each future returned by a supported call and resolve
futures individually. Only sample futures can be cancelled on either
interface. Batch retrieval through `retrieve_futures` is not supported.

## Recover the loop

Persist the job ID, the application step, the dataset cursor, and the latest
checkpoint path. A restarted controller can then tell which work completed
without replaying an update.

Future results remain available for one hour. Within that window, poll the
known `future_id` to resolve uncertain work. A `410` means the result is no
longer recoverable; do not blindly replay the operation. For long-term
recovery, use only a completed checkpoint whose path was written to your
durable application record after its save future completed.

For the recovery sequence and checkpoint kinds, follow
[Checkpoints and recovery](https://docs.fastino.ai/training/checkpoints.md).

One controller updates one job during its lifetime. A native client can create
from a checkpoint, and a Tinker client can create from saved state. Both paths
start a new interactive job seeded from the source checkpoint, so persist both
job IDs as application-owned lineage.


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