# YOLO11

We support YOLO11 inferencing via our [Serverless Hosted API](/deploy/serverless-hosted-api-v2.md). YOLO11 is available in two task variants pretrained on COCO:

* Object detection (640 and 1280 input sizes)
* Instance segmentation (640 input size)

For self-hosted deployment, see [Roboflow Inference](https://inference.roboflow.com/).

## Code samples

Install the dependencies:

```bash
pip install inference-sdk supervision
```

Each sample below runs inference through the Serverless Hosted API, decodes the response with [`supervision`](https://supervision.roboflow.com/), and writes an annotated image to disk. Pass your [Roboflow API Key](https://app.roboflow.com/settings/api) via the `API_KEY` environment variable.

### Object detection

Run `yolov11n-640` on a sample image and annotate boxes and labels.

```python
import os
import urllib.request

import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient

image_url = "https://storage.googleapis.com/com-roboflow-marketing/notebooks/examples/cars-highway.png"
image_path = "cars-highway.png"
urllib.request.urlretrieve(image_url, image_path)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.getenv("API_KEY"),
)

image = cv2.imread(image_path)
results = client.infer(image, model_id="yolov11n-640")
detections = sv.Detections.from_inference(results)

box_annotator = sv.BoxAnnotator()
label_annotator = sv.LabelAnnotator()

annotated = box_annotator.annotate(scene=image.copy(), detections=detections)
annotated = label_annotator.annotate(scene=annotated, detections=detections)

cv2.imwrite("cars-highway-annotated.png", annotated)
```

<figure><img src="/files/sH0gQbIJicJg5R27FckA" alt=""><figcaption></figcaption></figure>

### Instance segmentation

Run `yolov11n-seg-640` on a sample image and annotate masks and labels.

```python
import os
import urllib.request

import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient

image_url = "https://storage.googleapis.com/com-roboflow-marketing/notebooks/examples/bicycle.png"
image_path = "bicycle.png"
urllib.request.urlretrieve(image_url, image_path)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.getenv("API_KEY"),
)

image = cv2.imread(image_path)
results = client.infer(image, model_id="yolov11n-seg-640")
detections = sv.Detections.from_inference(results)

mask_annotator = sv.MaskAnnotator()
label_annotator = sv.LabelAnnotator(text_position=sv.Position.CENTER_OF_MASS)

annotated = mask_annotator.annotate(scene=image.copy(), detections=detections)
annotated = label_annotator.annotate(scene=annotated, detections=detections)

cv2.imwrite("bicycle-annotated.png", annotated)
```

<figure><img src="/files/cvRZiIbY8xoyTnZ7DIQ5" alt=""><figcaption></figcaption></figure>

## Default COCO aliases

You can pass any of the following aliases as the `model_id`. The `inference-sdk` resolves each alias to a pretrained Roboflow Universe model.

| Task         | Alias              |
| ------------ | ------------------ |
| Detection    | `yolov11n-640`     |
| Detection    | `yolov11s-640`     |
| Detection    | `yolov11m-640`     |
| Detection    | `yolov11l-640`     |
| Detection    | `yolov11x-640`     |
| Detection    | `yolov11n-1280`    |
| Detection    | `yolov11s-1280`    |
| Detection    | `yolov11m-1280`    |
| Detection    | `yolov11l-1280`    |
| Detection    | `yolov11x-1280`    |
| Segmentation | `yolov11n-seg-640` |
| Segmentation | `yolov11s-seg-640` |
| Segmentation | `yolov11m-seg-640` |
| Segmentation | `yolov11l-seg-640` |
| Segmentation | `yolov11x-seg-640` |

The `yolo11*` prefix variants resolve to the same models.

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

* `https://serverless.roboflow.com` for the Serverless Hosted API.
* `http://localhost:9001` for a local [Inference](https://inference.roboflow.com/) server.
* Your [Dedicated Deployment](/deploy/dedicated-deployments.md) URL for a private endpoint.
  {% endhint %}


---

# 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/deploy/supported-models/yolo11.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.
