YOLOv8

Use the YOLOv8 model family through our Serverless Cloud API

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 to run a model you trained elsewhere.

Training YOLOv8 is not supported on Roboflow. For a Roboflow-trained detector, see RF-DETR, YOLO26, or YOLO11.

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

ModelInput sizeTaskModel IDTest
YOLOv8n640Object Detectionyolov8n-640Test in browser
YOLOv8n1280Object Detectionyolov8n-1280Test in browser
YOLOv8s640Object Detectionyolov8s-640Test in browser
YOLOv8s1280Object Detectionyolov8s-1280Test in browser
YOLOv8m640Object Detectionyolov8m-640Test in browser
YOLOv8m1280Object Detectionyolov8m-1280Test in browser
YOLOv8l640Object Detectionyolov8l-640Test in browser
YOLOv8l1280Object Detectionyolov8l-1280Test in browser
YOLOv8x640Object Detectionyolov8x-640Test in browser
YOLOv8x1280Object Detectionyolov8x-1280Test in browser
YOLOv8n Instance Segmentation640Instance Segmentationyolov8n-seg-640Test in browser
YOLOv8n Instance Segmentation1280Instance Segmentationyolov8n-seg-1280Test in browser
YOLOv8s Instance Segmentation640Instance Segmentationyolov8s-seg-640Test in browser
YOLOv8m Instance Segmentation1280Instance Segmentationyolov8s-seg-1280Test in browser
YOLOv8m Instance Segmentation640Instance Segmentationyolov8m-seg-640Test in browser
YOLOv8m Instance Segmentation1280Instance Segmentationyolov8m-seg-1280Test in browser
YOLOv8l Instance Segmentation640Instance Segmentationyolov8l-seg-640Test in browser
YOLOv8l Instance Segmentation1280Instance Segmentationyolov8l-seg-1280Test in browser
YOLOv8x Instance Segmentation640Instance Segmentationyolov8x-seg-640Test in browser
YOLOv8x Instance Segmentation1280Instance Segmentationyolov8x-seg-1280Test in browser
YOLOv8x Keypoint Detection1280Keypoint Detectionyolov8x-pose-1280Test in browser
YOLOv8x Keypoint Detection640Keypoint Detectionyolov8x-pose-640Test in browser
YOLOv8l Keypoint Detection640Keypoint Detectionyolov8l-pose-640Test in browser
YOLOv8m Keypoint Detection640Keypoint Detectionyolov8m-pose-640Test in browser
YOLOv8s Keypoint Detection640Keypoint Detectionyolov8s-pose-640Test in browser
YOLOv8n Keypoint Detection640Keypoint Detectionyolov8n-pose-640Test in browser

YOLOv8 API

1

Get your API Key

Create a Roboflow account, find your key on the Roboflow API settings page and make it available to your shell:

export ROBOFLOW_API_KEY="your-key-here"
2

Install the dependencies

Install the Inference SDK and supervision for decoding and drawing predictions:

pip install -U inference-sdk supervision opencv-python
3

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

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)

Set api_url to match your deployment target:

  • https://serverless.roboflow.com for the Serverless Cloud API.
  • http://localhost:9001 for a local Inference server.
  • Your Dedicated Deployment URL for a private endpoint.

You can also load the checkpoint in-process with the inference package:

from inference import get_model

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