> 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/get-started/ko/guides/run-model-serverless-api.md).

# 모델 API 엔드포인트 사용

그 [서버리스 클라우드 API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api) Roboflow의 클라우드에서 GPU로 모델과 워크플로를 실행합니다. 이미지를 보내면 결과를 돌려받습니다. 설정할 하드웨어도, 계속 실행해 둘 서버도 없습니다.

이 가이드는 아무것도 모르는 상태에서 5분 만에 모델을 실행하는 단계까지 안내합니다. 이름만 지정해 이미지에서 객체를 찾고, 기성 모델로 일상적인 객체를 감지하고, 자신의 모델도 모두 동일한 Serverless Cloud API 엔드포인트로 실행할 수 있습니다.

## 이름을 지정해 객체 찾기

모델에 다음과 같은 몇 단어를 입력하세요 `"taxi"`, `"blue bus"`또는 `"bush"` 그러면 이미지에서 일치하는 모든 객체의 윤곽을 표시합니다. 먼저 설정하거나 학습할 것은 없습니다. 이것은 다음에서 실행됩니다 [SAM3](https://docs.roboflow.com/models/supported-models/sam3).

{% tabs %}
{% tab title="HTTP (Python)" icon="webhook" %}
{% stepper %}
{% step %}

### API 키 받기

Roboflow 계정을 만들고, 다음에서 키를 찾으세요 [Roboflow API 설정 페이지](https://app.roboflow.com/settings/api) 그리고 셸에서 사용할 수 있게 만드세요:

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

{% endstep %}

{% step %}

### 의존성 설치하기

`supervision` 는 다음을 가져옵니다 `cv2` 와 `numpy`:

```bash
pip install -U supervision
```

{% endstep %}

{% step %}

### 모델 실행하기

다음으로 POST 요청을 보내세요 `/sam3/concept_segment` 모델을 실행합니다. `sv.Detections.from_sam3` 는 해당 결과를 다음과 같은 형식으로 변환합니다 [`supervision`](https://supervision.roboflow.com) 그릴 수 있습니다:

```python
import os
import base64
import cv2
import requests
import supervision as sv

image = sv.load_image_from_url("https://media.roboflow.com/quickstart/traffic.jpg")
image_b64 = base64.b64encode(content).decode("utf-8")
h, w = image.shape[:2]

response = requests.post(
    "https://serverless.roboflow.com/sam3/concept_segment",
    headers={"Authorization": f"Bearer {os.environ['ROBOFLOW_API_KEY']}"},
    json={
        "image": {"type": "base64", "value": image_b64},
        "prompts": [
            {"type": "text", "text": "taxi"},
            {"type": "text", "text": "blue bus"},
            {"type": "text", "text": "bush"},
        ],
    },
)

detections = sv.Detections.from_sam3(response.json(), (w, h))
annotated = sv.MaskAnnotator().annotate(image.copy(), detections)
cv2.imwrite("sam3.jpg", annotated)
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="SDK (Python)" icon="python" %}
{% stepper %}
{% step %}

### API 키 받기

Roboflow 계정을 만들고, 다음에서 키를 찾으세요 [Roboflow API 설정 페이지](https://app.roboflow.com/settings/api) 그리고 셸에서 사용할 수 있게 만드세요:

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

{% endstep %}

{% step %}

### 의존성 설치하기

이 두 패키지는 모델을 호출하고 결과를 그려줍니다:

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

{% endstep %}

{% step %}

### 모델 실행하기

그 [Inference SDK](https://docs.roboflow.com/reference/inference/inference-sdk) 이미지를 클라우드로 보내고 결과를 반환합니다. `sv.Detections.from_sam3` 는 해당 결과를 다음과 같은 형식으로 변환합니다 [`supervision`](https://supervision.roboflow.com) 그릴 수 있습니다:

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

image = sv.load_image_from_url("https://media.roboflow.com/quickstart/traffic.jpg")
h, w = image.shape[:2]

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
).configure(InferenceConfiguration(api_key_transport="header"))

data = client.sam3_concept_segment(
    image,
    prompts=[
        {"type": "text", "text": "taxi"},
        {"type": "text", "text": "blue bus"},
        {"type": "text", "text": "bush"},
    ],
)

detections = sv.Detections.from_sam3(data, (w, h))
annotated = sv.MaskAnnotator().annotate(image.copy(), detections)
annotated = sv.BoxAnnotator().annotate(annotated, detections)
cv2.imwrite("sam3.jpg", annotated)
```

{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

응답에는 각 프롬프트에 대해 찾은 윤곽이 나열되며, 각 항목마다 신뢰도 점수가 포함됩니다. `sv.Detections.from_sam3` 그 모든 내용을 대신 읽어줍니다.

<figure><img src="/files/69ba22d57134f741e51a3bd032cb6dc24d703f36" alt="Outlines around taxis, a blue bus, and bushes from text prompts"><figcaption><p>텍스트 프롬프트에서 윤곽이 표시된 객체</p></figcaption></figure>

시각적 프롬프트, 예시 박스, RLE 출력을 포함한 전체 SAM3 API는 다음을 참조하세요 [SAM3 문서](https://docs.roboflow.com/models/supported-models/sam3).

## 기성 모델로 일상적인 객체 감지하기

{% tabs %}
{% tab title="HTTP (Python)" icon="webhook" %}
이름이 지정된 객체의 윤곽을 그리는 대신 일반적인 객체 주위에 박스를 그리려면 다음을 호출하세요 `POST /{project}/{version}` 다음 대신 모델 ID를 사용합니다 `POST /sam3/concept_segment`. 이 예제에서는 기성 [RF-DETR](https://docs.roboflow.com/models/supported-models/rf-detr) 모델을 사용하며, 차량, 사람, 반려동물 같은 일반적인 객체를 감지할 수 있습니다:

```python
result = requests.post(
    "https://serverless.roboflow.com/coco/40",  # coco/40은 rfdetr-medium 별칭입니다
    data=image_b64,  # 본문에 raw base64를 넣습니다. JSON이 아닙니다
    headers={
        "Authorization": f"Bearer {os.environ['ROBOFLOW_API_KEY']}",
        "Content-Type": "application/x-www-form-urlencoded",
    },
).json()
detections = sv.Detections.from_inference(result)

print(f"객체 {len(detections)}개를 찾았습니다")

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("rf-detr.jpg", annotated)
```

{% endtab %}

{% tab title="SDK (Python)" icon="python" %}
이름이 지정된 객체의 윤곽을 그리는 대신 일반적인 객체 주위에 박스를 그리려면 다음을 호출하세요 `client.infer()` 다음 대신 모델 ID를 사용합니다 `client.sam3_concept_segment()`. 이 예제에서는 기성 [RF-DETR](https://docs.roboflow.com/models/supported-models/rf-detr) 모델을 사용하며, 차량, 사람, 반려동물 같은 일반적인 객체를 감지할 수 있습니다:

```python
result = client.infer(image, model_id="rfdetr-medium")
detections = sv.Detections.from_inference(result)

print(f"객체 {len(detections)}개를 찾았습니다")

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("rf-detr.jpg", annotated)
```

{% endtab %}
{% endtabs %}

<figure><img src="/files/f48db6f6829eeca45ca7a3f57e62131e643d9cc9" alt="RF-DETR bounding boxes for cars, buses, people, and motorcycles"><figcaption><p>RF-DETR은 차량, 버스, 사람, 오토바이를 감지합니다</p></figcaption></figure>

## 자신의 모델이나 다른 모델 실행하기

동일한 `client.infer()` 또는 `POST /{project}/{version}` 호출은 모델의 `model_id`:

* Roboflow에서 학습한 모델입니다. 모델 ID를 복사하세요(형식은 `{project}/{version}`와 같음). [Roboflow 앱](https://app.roboflow.com)
* 다음의 공개 모델 [Roboflow Universe](https://docs.roboflow.com/datasets/universe/universe/what-is-roboflow-universe)
* 기성 [사전 학습된 모델](https://docs.roboflow.com/models/pretrained-aliases) 다음과 같은 별칭으로 `rfdetr-nano`, `rfdetr-seg-medium`또는 `yolo26l-640` (Inference SDK에서만)

## 다음 단계

클라우드에서 모델을 실행 중입니다. 여기서 할 수 있는 일:

* 동일한 모델을 자체 하드웨어에서 실행합니다. 다음을 참조하세요 [로컬에서 모델 실행](/get-started/ko/guides/run-a-model-locally.md)
* 대형 모델과 안정적인 트래픽을 위한 전용 단일 테넌트 엔드포인트를 다음과 함께 사용하세요 [전용 배포](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments)
* 모델과 로직을 다음과 결합해 애플리케이션을 구성하세요 [워크플로](https://docs.roboflow.com/workflows)
* 각 요청의 비용을 다음에서 확인하세요 [서버리스 요금 페이지](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api/pricing)
