> 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/models/supported-models/yolov8.md).

# YOLOv8

YOLOv8 is an object detection, instance segmentation, and keypoint detection model family from Ultralytics. Roboflow serves COCO-pretrained YOLOv8 checkpoints under short aliases, and you can [upload your own weights](/models/model-weights/upload-custom-weights.md) to run a model you trained elsewhere.

Training YOLOv8 is not supported on Roboflow. For a Roboflow-trained detector, see [RF-DETR](/models/supported-models/rf-detr.md), [YOLO26](/models/supported-models/yolo26.md), or [YOLO11](/models/supported-models/yolo11.md).

## YOLOv8 pretrained aliases

Pass one of these IDs as `model_id` to run a COCO-pretrained checkpoint without training anything. The full list lives on the [Pretrained Model Aliases](/models/pretrained-aliases.md) page.

| Model                         | Input size | Task                  | Model ID            | Test                                                                                   |
| ----------------------------- | ---------- | --------------------- | ------------------- | -------------------------------------------------------------------------------------- |
| YOLOv8n                       | 640        | Object Detection      | `yolov8n-640`       | [Test in browser](https://universe.roboflow.com/microsoft/coco/model/3)                |
| YOLOv8n                       | 1280       | Object Detection      | `yolov8n-1280`      | [Test in browser](https://universe.roboflow.com/microsoft/coco/model/9)                |
| YOLOv8s                       | 640        | Object Detection      | `yolov8s-640`       | [Test in browser](https://universe.roboflow.com/microsoft/coco/model/6)                |
| YOLOv8s                       | 1280       | Object Detection      | `yolov8s-1280`      | [Test in browser](https://universe.roboflow.com/microsoft/coco/model/10)               |
| YOLOv8m                       | 640        | Object Detection      | `yolov8m-640`       | [Test in browser](https://universe.roboflow.com/microsoft/coco/model/8)                |
| YOLOv8m                       | 1280       | Object Detection      | `yolov8m-1280`      | [Test in browser](https://universe.roboflow.com/microsoft/coco/model/11)               |
| YOLOv8l                       | 640        | Object Detection      | `yolov8l-640`       | [Test in browser](https://universe.roboflow.com/microsoft/coco/model/7)                |
| YOLOv8l                       | 1280       | Object Detection      | `yolov8l-1280`      | [Test in browser](https://universe.roboflow.com/microsoft/coco/model/12)               |
| YOLOv8x                       | 640        | Object Detection      | `yolov8x-640`       | [Test in browser](https://universe.roboflow.com/microsoft/coco/model/5)                |
| YOLOv8x                       | 1280       | Object Detection      | `yolov8x-1280`      | [Test in browser](https://universe.roboflow.com/microsoft/coco/model/13)               |
| YOLOv8n Instance Segmentation | 640        | Instance Segmentation | `yolov8n-seg-640`   | [Test in browser](https://universe.roboflow.com/microsoft/coco-dataset-vdnr1/model/2)  |
| YOLOv8n Instance Segmentation | 1280       | Instance Segmentation | `yolov8n-seg-1280`  | [Test in browser](https://universe.roboflow.com/microsoft/coco-dataset-vdnr1/model/7)  |
| YOLOv8s Instance Segmentation | 640        | Instance Segmentation | `yolov8s-seg-640`   | [Test in browser](https://universe.roboflow.com/microsoft/coco-dataset-vdnr1/model/4)  |
| YOLOv8m Instance Segmentation | 1280       | Instance Segmentation | `yolov8s-seg-1280`  | [Test in browser](https://universe.roboflow.com/microsoft/coco-dataset-vdnr1/model/8)  |
| YOLOv8m Instance Segmentation | 640        | Instance Segmentation | `yolov8m-seg-640`   | [Test in browser](https://universe.roboflow.com/microsoft/coco-dataset-vdnr1/model/5)  |
| YOLOv8m Instance Segmentation | 1280       | Instance Segmentation | `yolov8m-seg-1280`  | [Test in browser](https://universe.roboflow.com/microsoft/coco-dataset-vdnr1/model/9)  |
| YOLOv8l Instance Segmentation | 640        | Instance Segmentation | `yolov8l-seg-640`   | [Test in browser](https://universe.roboflow.com/microsoft/coco-dataset-vdnr1/model/6)  |
| YOLOv8l Instance Segmentation | 1280       | Instance Segmentation | `yolov8l-seg-1280`  | [Test in browser](https://universe.roboflow.com/microsoft/coco-dataset-vdnr1/model/10) |
| YOLOv8x Instance Segmentation | 640        | Instance Segmentation | `yolov8x-seg-640`   | [Test in browser](https://universe.roboflow.com/microsoft/coco-dataset-vdnr1/model/3)  |
| YOLOv8x Instance Segmentation | 1280       | Instance Segmentation | `yolov8x-seg-1280`  | [Test in browser](https://universe.roboflow.com/microsoft/coco-dataset-vdnr1/model/11) |
| YOLOv8x Keypoint Detection    | 1280       | Keypoint Detection    | `yolov8x-pose-1280` | [Test in browser](https://universe.roboflow.com/microsoft/coco-pose-detection/6)       |
| YOLOv8x Keypoint Detection    | 640        | Keypoint Detection    | `yolov8x-pose-640`  | [Test in browser](https://universe.roboflow.com/microsoft/coco-pose-detection/5)       |
| YOLOv8l Keypoint Detection    | 640        | Keypoint Detection    | `yolov8l-pose-640`  | [Test in browser](https://universe.roboflow.com/microsoft/coco-pose-detection/4)       |
| YOLOv8m Keypoint Detection    | 640        | Keypoint Detection    | `yolov8m-pose-640`  | [Test in browser](https://universe.roboflow.com/microsoft/coco-pose-detection/3)       |
| YOLOv8s Keypoint Detection    | 640        | Keypoint Detection    | `yolov8s-pose-640`  | [Test in browser](https://universe.roboflow.com/microsoft/coco-pose-detection/2)       |
| YOLOv8n Keypoint Detection    | 640        | Keypoint Detection    | `yolov8n-pose-640`  | [Test in browser](https://universe.roboflow.com/microsoft/coco-pose-detection/1)       |

## YOLOv8 API

{% stepper %}
{% step %}

### Get your API Key

Create a Roboflow account, find your key on the [Roboflow API settings page](https://app.roboflow.com/settings/api) and make it available to your shell:

```bash
export ROBOFLOW_API_KEY="your-key-here"
```

{% endstep %}

{% step %}

### Install the dependencies

Install the Inference SDK and [supervision](https://supervision.roboflow.com/) for decoding and drawing predictions:

```bash
pip install -U inference-sdk supervision opencv-python
```

{% endstep %}

{% step %}

### Run the model

This example runs the pretrained `yolov8n-640` checkpoint. To serve your own weights, swap in your `{workspace}/{model-slug}` ID (see [Versions, Trainings, and Models](/models/versions-trainings-and-models.md)).

```python
import os
import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient

image = sv.load_image_from_url("https://media.roboflow.com/inference/people-walking.jpg")

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
results = client.infer(image, model_id="yolov8n-640")

detections = sv.Detections.from_inference(results)

labels = [
    f"{name} {conf:.2f}"
    for name, conf in zip(detections.data["class_name"], detections.confidence)
]
annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections, labels=labels)
cv2.imwrite("annotated.png", annotated)
```

{% endstep %}
{% endstepper %}

{% hint style="info" %}
Set `api_url` to match your deployment target:

* `https://serverless.roboflow.com` for the Serverless Cloud API.
* `http://localhost:9001` for a local [Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) server.
* Your [Dedicated Deployment](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) URL for a private endpoint.
  {% endhint %}

You can also load the checkpoint in-process with the [`inference`](https://docs.roboflow.com/deployment/self-hosted/self-hosted) package:

```python
from inference import get_model

model = get_model(model_id="yolov8n-640")
results = model.infer("https://media.roboflow.com/inference/people-walking.jpg")
```
