# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roboflow.com/developer/python-sdk/train-a-model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
