> 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/deploy/supported-models/roboflow-3.md).

# Roboflow 3.0

## Roboflow 3.0 Object Detection

Roboflow 3.0 is Roboflow's in-house model architecture. You train Roboflow 3.0 models on the Roboflow platform and deploy them through the [Serverless Hosted API](/deploy/serverless-hosted-api-v2.md). The sample below runs Roboflow's public [COCO model](https://universe.roboflow.com/microsoft/coco) (`coco/3`) so you can try it immediately. For self-hosted deployment, see [Roboflow Inference](https://inference.roboflow.com/).

### Code sample

{% 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](https://inference.roboflow.com/) and [supervision](https://supervision.roboflow.com/):

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

{% endstep %}

{% step %}
**Run the model**

Run detection on a sample image and annotate boxes and labels:

```python
import os
import cv2
import numpy as np
import requests
import supervision as sv
from inference_sdk import InferenceHTTPClient

content = requests.get("https://media.roboflow.com/quickstart/traffic.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.infer(image, model_id="coco/3")

detections = sv.Detections.from_inference(result)

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("output.png", annotated)
```

<figure><img src="/files/OKAxih1139CtysPC2PUk" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

{% 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 %}

## Roboflow 3.0 Instance Segmentation

Train a Roboflow 3.0 instance segmentation model, then replace `your-project/1` with your own `{workspace}/{model-slug}` ID (see [Versions, Trainings, and Models](/train/versions-trainings-and-models.md)). Set your API key and install the dependencies as shown above.

### Code sample

```python
import os
import cv2
import numpy as np
import requests
import supervision as sv
from inference_sdk import InferenceHTTPClient

content = requests.get("https://media.roboflow.com/quickstart/traffic.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
# No pretrained aliases: train your own model and replace "your-project/1" with your model ID.
result = client.infer(image, model_id="your-project/1")

detections = sv.Detections.from_inference(result)

annotated = sv.MaskAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("output.png", annotated)
```

## Roboflow 3.0 Keypoint Detection

This example runs the public [rf-handpose](https://universe.roboflow.com/erik-pe6au/rf-handpose) hand keypoint model, then draws the 21-point hand skeleton. Swap in your own `{workspace}/{model-slug}`. Set your API key and install the dependencies as shown above.

### Code sample

```python
import os
import cv2
import numpy as np
import requests
import supervision as sv
from inference_sdk import InferenceHTTPClient

content = requests.get("https://media.roboflow.com/docs/hand.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.infer(image, model_id="rf-handpose/1")

key_points = sv.KeyPoints.from_inference(result)

# Hand skeleton: wrist (0), thumb (1-4), index (5-8), middle (9-12), ring (13-16), pinky (17-20)
hand_edges = [
    (0, 1), (1, 2), (2, 3), (3, 4),
    (0, 5), (5, 6), (6, 7), (7, 8),
    (5, 9), (9, 10), (10, 11), (11, 12),
    (9, 13), (13, 14), (14, 15), (15, 16),
    (13, 17), (17, 18), (18, 19), (19, 20), (0, 17),
]
annotated = image.copy()
vertices = key_points.xy[0].astype(int)
for start, end in hand_edges:
    cv2.line(annotated, tuple(vertices[start]), tuple(vertices[end]), (255, 0, 0), 2)
annotated = sv.VertexAnnotator(color=sv.Color.GREEN, radius=5).annotate(annotated, key_points)
cv2.imwrite("output.png", annotated)
```

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

## Roboflow 3.0 Classification

Classification responses contain a list of class predictions with confidences, so visualization is not applicable. Read the top class directly from the response. Replace `your-project/1` with your trained model ID, and set your API key and install the dependencies as shown above.

### Code sample

```python
import os
import cv2
import numpy as np
import requests
from inference_sdk import InferenceHTTPClient

content = requests.get("https://media.roboflow.com/quickstart/traffic.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
# No pretrained aliases: train your own model and replace "your-project/1" with your model ID.
result = client.infer(image, model_id="your-project/1")

print(f"Top class: {result['top']} ({result['confidence']:.4f})")
```
