> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/developer/python-sdk/train-a-model.md).

# Train a Model

`Version.train()` schedules training on the Roboflow platform. The call returns once the job is queued - training itself runs asynchronously.

{% tabs %}
{% tab title="Python SDK" %}

```python
import roboflow

rf = roboflow.Roboflow(api_key="YOUR_API_KEY")
project = rf.workspace().project("my-detector")

# Create a version with preprocessing and augmentation if you don't have one yet.
new_version = project.generate_version({
    "preprocessing": {
        "auto-orient": True,
        "resize": {"width": 640, "height": 640, "format": "Stretch to"},
    },
    "augmentation": {},
})
version = project.version(new_version)

# Schedule training.
model = version.train(
    model_type="rfdetr-nano",   # pass an invalid value to get the full list back as an error
    checkpoint=None,             # optional: resume from a previous checkpoint
    epochs=100,                  # optional: defaults are model-type-dependent
    plot_in_notebook=False,      # display a training-progress plot (notebook only)
)
```

{% endtab %}

{% tab title="CLI" %}

```bash
roboflow train start my-workspace/my-detector/3 -m rfdetr-nano --epochs 100
```

See [Train a Model (CLI)](/developer/command-line-interface/train-a-model.md).
{% endtab %}

{% tab title="REST API" %}

```bash
curl -X POST "https://api.roboflow.com/my-workspace/my-detector/jobs?api_key=$ROBOFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"version": 3, "model_type": "rfdetr-nano", "epochs": 100}'
```

See [Train a Model (REST)](/developer/rest-api/train-a-model.md).
{% endtab %}
{% endtabs %}

## Parameters

* `model_type` (str) - architecture identifier. Common values: `rfdetr-nano`, `rfdetr-base`, `yolov8`, `yolov11`. Project-type dependent. Pass an invalid value to get the full list back as an error.
* `speed` (str, optional) - `"fast"` (default) or `"accurate"`. Accurate training is a paid feature.
* `checkpoint` (str, optional) - id of a checkpoint to resume from.
* `epochs` (int, optional) - number of epochs. Defaults are model-type-dependent.
* `plot_in_notebook` (bool, default `False`) - display training progress inline (notebook only).

## After training

Once training completes, the `Version`'s `.model` property returns the hosted model:

```python
predictions = version.model.predict("photo.jpg", confidence=40, overlap=30).json()
```

See [Run a Model on an Image](/developer/python-sdk/run-a-model-on-an-image.md) for the full inference reference.
