> 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/deployment/ko/roboflow-cloud/serverless-api.md).

# Serverless Cloud API

Roboflow 클라우드의 GPU 가속 자동 확장 인프라에서 워크플로와 모델 추론을 실행합니다.

## 소개

Roboflow에 배포된 모델은 이미지에 대해 추론을 실행할 수 있는 REST API를 사용할 수 있습니다. 이 배포 방식은 배포 장치에 지속적인 인터넷 연결이 있는 환경에 적합합니다.

앱에서는 이 엔드포인트가 "Serverless Cloud API"로 표시되며, 공간이 좁을 때(예: Workflow 편집기 런타임 선택기)에는 "Cloud API"로 표시됩니다. A [전용 배포](/deployment/ko/roboflow-cloud/dedicated-deployments.md) 엔드포인트(`*.roboflow.cloud`)는 "Dedicated Cloud API"로 표시되며, 이전 v1 엔드포인트는 "Hosted API (Legacy)"로 표시됩니다. 이러한 레이블은 이전의 "Serverless Hosted API" 및 "Serverless API V2" 이름을 대체합니다.

Serverless Cloud API는 다음과 같이 사용할 수 있습니다:

* [Workflows에서](/deployment/ko/roboflow-cloud/serverless-api/use-in-a-workflow.md)
* [REST API로](#http-api)
* 와 함께 [Inference Python SDK](#python-sdk)

### Inference 서버

저희 Serverless Cloud API는 다음으로 구동됩니다. [Inference Server](https://docs.roboflow.com/reference/platform/rest-api/inference-server-openapi). 즉, 아래와 같이 저희 Serverless Cloud API와 자체 호스팅 옵션 간에 손쉽게 전환할 수 있습니다:

```python
from inference_sdk import InferenceHTTPClient, InferenceConfiguration

CLIENT = InferenceHTTPClient(
    # api_url="http://localhost:9001" # 자체 호스팅 Inference 서버
    api_url="https://serverless.roboflow.com", # 저희 Serverless Cloud API
    api_key="API_KEY" # 개인 모델과 데이터에 접근하기 위한 선택 항목
).configure(InferenceConfiguration(api_key_transport="header"))

result = CLIENT.infer("image.jpg", model_id="model-id/1")
print(result)
```

설정 `api_key_transport="header"` 은 키를 오직 `Authorization: Bearer` 헤더로만 전송하여 URL과 로그에 남지 않게 합니다. 새 코드에는 권장됩니다. Inference 1.5.0 이전의 서버는 이 헤더를 읽지 않으므로, `api_key_transport="both"` 를 사용하는 동안에도 하나는 계속 호출하세요. 참조: [API 키 전송](https://docs.roboflow.com/reference/inference/inference-sdk/configuration#api-key-transport).

### 제한 사항

이미지 추론은 모델에 의해 정해진 요율로 이미지당 크레딧이 청구됩니다. 참조: [요금](/deployment/ko/roboflow-cloud/serverless-api/pricing.md) 및 [모델 요금](/deployment/ko/roboflow-cloud/serverless-api/model-pricing.md).

저희 Serverless Cloud API는 최대 20MB까지의 파일 업로드를 지원합니다. 더 높은 해상도의 이미지에서는 제한에 걸릴 수 있습니다. 문제가 발생하면 엔터프라이즈 지원 담당자에게 문의하거나 다음 [포럼](https://discuss.roboflow.com).

{% hint style="info" %}
에 메시지를 남겨 주세요.\
\
요청이 너무 큰 경우에는 첨부된 이미지를 축소하는 것을 권장합니다. 이미지는 서버에 수신된 후 모델 아키텍처가 허용하는 입력 크기로 다시 축소되므로, 일반적으로 성능 저하는 없습니다.\
\
Python SDK와 같은 일부 SDK는 API로 전송되기 전에 자동으로 이미지를 모델 아키텍처의 입력 크기로 축소합니다.
{% endhint %}

***

참조: [Serverless Cloud API v1](/deployment/ko/legacy/legacy-serverless.md) 의 레거시 API 문서입니다.

## HTTP API

### REST API와 함께 사용

Serverless Cloud API는 모든 모델과 Workflows에 대해 하나의 엔드포인트를 제공합니다:

```
https://serverless.roboflow.com
```

#### HTTP 엔드포인트

## Legacy Infer From Request

> Legacy inference endpoint for object detection, instance segmentation, and classification.\
> \
> Args:\
> &#x20;   background\_tasks: (BackgroundTasks) pool of fastapi background tasks\
> &#x20;   dataset\_id (str): ID of a Roboflow dataset corresponding to the model to use for inference OR workspace ID\
> &#x20;   version\_id (str): ID of a Roboflow dataset version corresponding to the model to use for inference OR model ID\
> &#x20;   api\_key (Optional\[str], default None): Roboflow API Key passed to the model during initialization for artifact retrieval.\
> &#x20;   \# Other parameters described in the function signature...\
> \
> Returns:\
> &#x20;   Union\[InstanceSegmentationInferenceResponse, KeypointsDetectionInferenceRequest, ObjectDetectionInferenceResponse, ClassificationInferenceResponse, MultiLabelClassificationInferenceResponse, SemanticSegmentationInferenceResponse, Any]: The response containing the inference results.

```json
{"openapi":"3.1.0","info":{"title":"Roboflow Inference Server","version":"1.8.2"},"paths":{"/{dataset_id}/{version_id}":{"post":{"summary":"Legacy Infer From Request","description":"Legacy inference endpoint for object detection, instance segmentation, and classification.\n\nArgs:\n    background_tasks: (BackgroundTasks) pool of fastapi background tasks\n    dataset_id (str): ID of a Roboflow dataset corresponding to the model to use for inference OR workspace ID\n    version_id (str): ID of a Roboflow dataset version corresponding to the model to use for inference OR model ID\n    api_key (Optional[str], default None): Roboflow API Key passed to the model during initialization for artifact retrieval.\n    # Other parameters described in the function signature...\n\nReturns:\n    Union[InstanceSegmentationInferenceResponse, KeypointsDetectionInferenceRequest, ObjectDetectionInferenceResponse, ClassificationInferenceResponse, MultiLabelClassificationInferenceResponse, SemanticSegmentationInferenceResponse, Any]: The response containing the inference results.","operationId":"legacy_infer_from_request__dataset_id___version_id__post","parameters":[{"name":"dataset_id","in":"path","required":true,"schema":{"type":"string","description":"ID of a Roboflow dataset corresponding to the model to use for inference OR workspace ID","title":"Dataset Id"},"description":"ID of a Roboflow dataset corresponding to the model to use for inference OR workspace ID"},{"name":"version_id","in":"path","required":true,"schema":{"type":"string","description":"ID of a Roboflow dataset version corresponding to the model to use for inference OR model ID","title":"Version Id"},"description":"ID of a Roboflow dataset version corresponding to the model to use for inference OR model ID"},{"name":"api_key","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Roboflow API Key that will be passed to the model during initialization for artifact retrieval","title":"Api Key"},"description":"Roboflow API Key that will be passed to the model during initialization for artifact retrieval"},{"name":"confidence","in":"query","required":false,"schema":{"anyOf":[{"type":"number"},{"enum":["best","default"],"type":"string"}],"description":"The confidence threshold used to filter out predictions. Pass a float in [0, 1], or \"best\" to use F1-optimal thresholds from model evaluation, or \"default\" to use the model's built-in default.","default":0.4,"title":"Confidence"},"description":"The confidence threshold used to filter out predictions. Pass a float in [0, 1], or \"best\" to use F1-optimal thresholds from model evaluation, or \"default\" to use the model's built-in default."},{"name":"keypoint_confidence","in":"query","required":false,"schema":{"type":"number","description":"The confidence threshold used to filter out keypoints that are not visible based on model confidence","default":0,"title":"Keypoint Confidence"},"description":"The confidence threshold used to filter out keypoints that are not visible based on model confidence"},{"name":"format","in":"query","required":false,"schema":{"type":"string","description":"One of 'json' or 'image'. If 'json' prediction data is return as a JSON string. If 'image' prediction data is visualized and overlayed on the original input image.","default":"json","title":"Format"},"description":"One of 'json' or 'image'. If 'json' prediction data is return as a JSON string. If 'image' prediction data is visualized and overlayed on the original input image."},{"name":"image","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The publically accessible URL of an image to use for inference.","title":"Image"},"description":"The publically accessible URL of an image to use for inference."},{"name":"image_type","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"One of base64 or numpy. Note, numpy input is not supported for Roboflow Hosted Inference.","default":"base64","title":"Image Type"},"description":"One of base64 or numpy. Note, numpy input is not supported for Roboflow Hosted Inference."},{"name":"class_filter","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Action recognition only: comma separated classes. The subset of a fine-tuned model's classes to report. A zero-shot model answers in its own words and ignores it.","title":"Class Filter"},"description":"Action recognition only: comma separated classes. The subset of a fine-tuned model's classes to report. A zero-shot model answers in its own words and ignores it."},{"name":"include_candidates","in":"query","required":false,"schema":{"type":"boolean","description":"Action recognition: return raw scored candidates","default":false,"title":"Include Candidates"},"description":"Action recognition: return raw scored candidates"},{"name":"labels","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"If true, labels will be include in any inference visualization.","default":false,"title":"Labels"},"description":"If true, labels will be include in any inference visualization."},{"name":"mask_decode_mode","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"One of 'accurate' or 'fast'. If 'accurate' the mask will be decoded using the original image size. If 'fast' the mask will be decoded using the original mask size. 'accurate' is slower but more accurate.","default":"accurate","title":"Mask Decode Mode"},"description":"One of 'accurate' or 'fast'. If 'accurate' the mask will be decoded using the original image size. If 'fast' the mask will be decoded using the original mask size. 'accurate' is slower but more accurate."},{"name":"allow_reduced_mask_resolution","in":"query","required":false,"schema":{"type":"boolean","description":"Opt into mask_decode_mode and tradeoff_factor on inference_models. Otherwise masks stay at image resolution. Legacy backend decoding is unchanged.","default":false,"title":"Allow Reduced Mask Resolution"},"description":"Opt into mask_decode_mode and tradeoff_factor on inference_models. Otherwise masks stay at image resolution. Legacy backend decoding is unchanged."},{"name":"tradeoff_factor","in":"query","required":false,"schema":{"anyOf":[{"type":"number"},{"type":"null"}],"description":"The amount to tradeoff between 0='fast' and 1='accurate'","default":0,"title":"Tradeoff Factor"},"description":"The amount to tradeoff between 0='fast' and 1='accurate'"},{"name":"max_detections","in":"query","required":false,"schema":{"type":"integer","description":"The maximum number of detections to return. This is used to limit the number of predictions returned by the model. The model may return more predictions than this number, but only the top `max_detections` predictions will be returned.","default":300,"title":"Max Detections"},"description":"The maximum number of detections to return. This is used to limit the number of predictions returned by the model. The model may return more predictions than this number, but only the top `max_detections` predictions will be returned."},{"name":"overlap","in":"query","required":false,"schema":{"type":"number","description":"The IoU threhsold that must be met for a box pair to be considered duplicate during NMS","default":0.3,"title":"Overlap"},"description":"The IoU threhsold that must be met for a box pair to be considered duplicate during NMS"},{"name":"stroke","in":"query","required":false,"schema":{"type":"integer","description":"The stroke width used when visualizing predictions","default":1,"title":"Stroke"},"description":"The stroke width used when visualizing predictions"},{"name":"disable_preproc_auto_orient","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"If true, disables automatic image orientation","default":false,"title":"Disable Preproc Auto Orient"},"description":"If true, disables automatic image orientation"},{"name":"disable_preproc_contrast","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"If true, disables automatic contrast adjustment","default":false,"title":"Disable Preproc Contrast"},"description":"If true, disables automatic contrast adjustment"},{"name":"disable_preproc_grayscale","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"If true, disables automatic grayscale conversion","default":false,"title":"Disable Preproc Grayscale"},"description":"If true, disables automatic grayscale conversion"},{"name":"disable_preproc_static_crop","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"If true, disables automatic static crop","default":false,"title":"Disable Preproc Static Crop"},"description":"If true, disables automatic static crop"},{"name":"disable_active_learning","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"If true, the predictions will be prevented from registration by Active Learning (if the functionality is enabled)","default":false,"title":"Disable Active Learning"},"description":"If true, the predictions will be prevented from registration by Active Learning (if the functionality is enabled)"},{"name":"active_learning_target_dataset","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Parameter to be used when Active Learning data registration should happen against different dataset than the one pointed by model_id","title":"Active Learning Target Dataset"},"description":"Parameter to be used when Active Learning data registration should happen against different dataset than the one pointed by model_id"},{"name":"include_anomaly_map","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Anomaly detection only: include the raw anomaly heatmap at the network input resolution","default":false,"title":"Include Anomaly Map"},"description":"Anomaly detection only: include the raw anomaly heatmap at the network input resolution"},{"name":"source","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The source of the inference request","default":"external","title":"Source"},"description":"The source of the inference request"},{"name":"source_info","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The detailed source information of the inference request","default":"external","title":"Source Info"},"description":"The detailed source information of the inference request"},{"name":"response_mask_format","in":"query","required":false,"schema":{"anyOf":[{"enum":["polygon","rle"],"type":"string"},{"type":"null"}],"description":"The format of the prediction mask - polygon (default) or rle - applicable for instance segmentation models.","default":"polygon","title":"Response Mask Format"},"description":"The format of the prediction mask - polygon (default) or rle - applicable for instance segmentation models."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/InstanceSegmentationInferenceResponse"},{"$ref":"#/components/schemas/KeypointsDetectionInferenceResponse"},{"$ref":"#/components/schemas/ObjectDetectionInferenceResponse"},{"$ref":"#/components/schemas/AnomalyDetectionResponse"},{"$ref":"#/components/schemas/ClassificationInferenceResponse"},{"$ref":"#/components/schemas/MultiLabelClassificationInferenceResponse"},{"$ref":"#/components/schemas/SemanticSegmentationInferenceResponse"},{"$ref":"#/components/schemas/StubResponse"},{}],"title":"Response Legacy Infer From Request  Dataset Id   Version Id  Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"InstanceSegmentationInferenceResponse":{"properties":{"visualization":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Visualization","description":"Base64 encoded string containing prediction visualization image data"},"inference_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Inference Id","description":"Unique identifier of inference"},"frame_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Frame Id","description":"The frame id of the image used in inference if the input was a video"},"time":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Time","description":"The time in seconds it took to produce the predictions including image preprocessing"},"resolved_model":{"anyOf":[{"$ref":"#/components/schemas/ResolvedModel"},{"type":"null"}],"description":"Model identity and available package details for this result."},"image":{"anyOf":[{"items":{"$ref":"#/components/schemas/InferenceResponseImage"},"type":"array"},{"$ref":"#/components/schemas/InferenceResponseImage"}],"title":"Image","description":"Dimensions of the coordinate frame shared by bounding boxes, polygon points and RLE masks. With opt-in this is the selected mask grid; otherwise it is the original image. Multi-image responses may provide a list."},"predictions":{"items":{"anyOf":[{"$ref":"#/components/schemas/InstanceSegmentationPrediction"},{"$ref":"#/components/schemas/InstanceSegmentationRLEPrediction"}]},"type":"array","title":"Predictions"},"original_image":{"anyOf":[{"$ref":"#/components/schemas/InferenceResponseImage"},{"type":"null"}],"description":"Original image dimensions retained for opted-in responses, including when the selected grid has the same dimensions."},"mask_metadata":{"anyOf":[{"$ref":"#/components/schemas/MaskCoordinateMetadata"},{"type":"null"}],"description":"Present for opted-in responses in either format. All prediction geometry uses this grid. Multiply x coordinates and widths by scale_x, and y coordinates and heights by scale_y, to map to original_image."}},"type":"object","required":["image","predictions"],"title":"InstanceSegmentationInferenceResponse","description":"Instance Segmentation inference response.\n\nAttributes:\n    predictions (List[Union[\n        inference.core.entities.responses.inference.InstanceSegmentationPrediction,\n        inference.core.entities.responses.inference.InstanceSegmentationRLEPrediction\n    ]]): List of instance segmentation predictions."},"ResolvedModel":{"properties":{"model_id":{"type":"string","title":"Model Id","description":"ID of the loaded model, using the canonical ID when available."},"model_package_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model Package Id","description":"ID of the package that loaded successfully and produced this result, including after a loading fallback."},"backend":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Backend","description":"Backend of the loaded package, such as onnx, trt, or torch."},"quantization":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Quantization","description":"Package quantization, such as fp32 or fp16, or unknown when unavailable. This does not specify the input tensor dtype or the precision of every runtime operation."}},"type":"object","required":["model_id"],"title":"ResolvedModel","description":"Identity of the model and available package details used for inference.\n\nAttributes:\n    model_id (str): ID of the loaded model, using the canonical ID when available.\n    model_package_id (Optional[str]): ID of the loaded model package.\n    backend (Optional[str]): Backend of the loaded package.\n    quantization (Optional[str]): Quantization of the loaded package."},"InferenceResponseImage":{"properties":{"width":{"type":"integer","title":"Width","description":"The width of the represented image coordinate frame"},"height":{"type":"integer","title":"Height","description":"The height of the represented image coordinate frame"}},"type":"object","required":["width","height"],"title":"InferenceResponseImage","description":"Inference response image information.\n\nAttributes:\n    width (int): The width of the represented image coordinate frame.\n    height (int): The height of the represented image coordinate frame."},"InstanceSegmentationPrediction":{"properties":{"x":{"type":"number","title":"X","description":"The center x-axis pixel coordinate of the prediction"},"y":{"type":"number","title":"Y","description":"The center y-axis pixel coordinate of the prediction"},"width":{"type":"number","title":"Width","description":"The width of the prediction bounding box in number of pixels"},"height":{"type":"number","title":"Height","description":"The height of the prediction bounding box in number of pixels"},"confidence":{"type":"number","title":"Confidence","description":"The detection confidence as a fraction between 0 and 1"},"class":{"type":"string","title":"Class","description":"The predicted class label"},"class_id":{"type":"integer","title":"Class Id","description":"The class id of the prediction"},"detection_id":{"type":"string","title":"Detection Id","description":"Unique identifier of detection"},"parent_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Id","description":"Identifier of parent image region"},"class_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Class Confidence","description":"The class label confidence as a fraction between 0 and 1"},"points":{"items":{"$ref":"#/components/schemas/Point-Output"},"type":"array","title":"Points","description":"The list of points that make up the instance polygon"},"mask_format":{"type":"string","const":"polygon","title":"Mask Format","description":"Type of mask format","default":"polygon"}},"type":"object","required":["x","y","width","height","confidence","class","class_id","points"],"title":"InstanceSegmentationPrediction"},"Point-Output":{"properties":{"x":{"type":"number","title":"X","description":"The x-axis pixel coordinate of the point"},"y":{"type":"number","title":"Y","description":"The y-axis pixel coordinate of the point"}},"type":"object","required":["x","y"],"title":"Point","description":"Point coordinates.\n\nAttributes:\n    x (float): The x-axis pixel coordinate of the point.\n    y (float): The y-axis pixel coordinate of the point."},"InstanceSegmentationRLEPrediction":{"properties":{"x":{"type":"number","title":"X","description":"The center x-axis pixel coordinate of the prediction"},"y":{"type":"number","title":"Y","description":"The center y-axis pixel coordinate of the prediction"},"width":{"type":"number","title":"Width","description":"The width of the prediction bounding box in number of pixels"},"height":{"type":"number","title":"Height","description":"The height of the prediction bounding box in number of pixels"},"confidence":{"type":"number","title":"Confidence","description":"The detection confidence as a fraction between 0 and 1"},"class":{"type":"string","title":"Class","description":"The predicted class label"},"class_id":{"type":"integer","title":"Class Id","description":"The class id of the prediction"},"detection_id":{"type":"string","title":"Detection Id","description":"Unique identifier of detection"},"parent_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Id","description":"Identifier of parent image region"},"rle":{"additionalProperties":true,"type":"object","title":"Rle","description":"RLE-encoded mask in COCO format: {'size': [H, W], 'counts': '...'}"},"mask_format":{"type":"string","const":"rle","title":"Mask Format","description":"Type of mask format","default":"rle"}},"type":"object","required":["x","y","width","height","confidence","class","class_id","rle"],"title":"InstanceSegmentationRLEPrediction"},"MaskCoordinateMetadata":{"properties":{"coordinate_system":{"type":"string","const":"mask_grid","title":"Coordinate System","description":"All prediction geometry uses this grid, matching response image dimensions.","default":"mask_grid"},"width":{"type":"integer","exclusiveMinimum":0,"title":"Width","description":"Mask-grid width in pixels."},"height":{"type":"integer","exclusiveMinimum":0,"title":"Height","description":"Mask-grid height in pixels."},"scale_x":{"type":"number","exclusiveMinimum":0,"title":"Scale X","description":"Original image width divided by output-grid width."},"scale_y":{"type":"number","exclusiveMinimum":0,"title":"Scale Y","description":"Original image height divided by output-grid height."}},"type":"object","required":["width","height","scale_x","scale_y"],"title":"MaskCoordinateMetadata","description":"Describe the prediction grid and its mapping to the original image.\n\nAttributes:\n    coordinate_system (str): Coordinate frame shared by boxes, polygons and encoded RLE masks.\n    width (int): Width of the encoded mask grid.\n    height (int): Height of the encoded mask grid.\n    scale_x (float): Multiply mask x coordinates by this to obtain image x.\n    scale_y (float): Multiply mask y coordinates by this to obtain image y."},"KeypointsDetectionInferenceResponse":{"properties":{"visualization":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Visualization","description":"Base64 encoded string containing prediction visualization image data"},"inference_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Inference Id","description":"Unique identifier of inference"},"frame_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Frame Id","description":"The frame id of the image used in inference if the input was a video"},"time":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Time","description":"The time in seconds it took to produce the predictions including image preprocessing"},"resolved_model":{"anyOf":[{"$ref":"#/components/schemas/ResolvedModel"},{"type":"null"}],"description":"Model identity and available package details for this result."},"image":{"anyOf":[{"items":{"$ref":"#/components/schemas/InferenceResponseImage"},"type":"array"},{"$ref":"#/components/schemas/InferenceResponseImage"}],"title":"Image"},"predictions":{"items":{"$ref":"#/components/schemas/KeypointsPrediction"},"type":"array","title":"Predictions"}},"type":"object","required":["image","predictions"],"title":"KeypointsDetectionInferenceResponse"},"KeypointsPrediction":{"properties":{"x":{"type":"number","title":"X","description":"The center x-axis pixel coordinate of the prediction"},"y":{"type":"number","title":"Y","description":"The center y-axis pixel coordinate of the prediction"},"width":{"type":"number","title":"Width","description":"The width of the prediction bounding box in number of pixels"},"height":{"type":"number","title":"Height","description":"The height of the prediction bounding box in number of pixels"},"confidence":{"type":"number","title":"Confidence","description":"The detection confidence as a fraction between 0 and 1"},"class":{"type":"string","title":"Class","description":"The predicted class label"},"class_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Class Confidence","description":"The class label confidence as a fraction between 0 and 1"},"class_id":{"type":"integer","title":"Class Id","description":"The class id of the prediction"},"tracker_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Tracker Id","description":"The tracker id of the prediction if tracking is enabled"},"detection_id":{"type":"string","title":"Detection Id","description":"Unique identifier of detection"},"parent_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Id","description":"Identifier of parent image region. Useful when stack of detection-models is in use to refer the RoI being the input to inference"},"keypoints":{"items":{"$ref":"#/components/schemas/Keypoint"},"type":"array","title":"Keypoints"}},"type":"object","required":["x","y","width","height","confidence","class","class_id","keypoints"],"title":"KeypointsPrediction"},"Keypoint":{"properties":{"x":{"type":"number","title":"X","description":"The x-axis pixel coordinate of the point"},"y":{"type":"number","title":"Y","description":"The y-axis pixel coordinate of the point"},"confidence":{"type":"number","title":"Confidence","description":"Model confidence regarding keypoint visibility."},"class_id":{"type":"integer","title":"Class Id","description":"Identifier of keypoint."},"class":{"type":"string","title":"Class","description":"Type of keypoint."}},"type":"object","required":["x","y","confidence","class_id","class"],"title":"Keypoint"},"ObjectDetectionInferenceResponse":{"properties":{"visualization":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Visualization","description":"Base64 encoded string containing prediction visualization image data"},"inference_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Inference Id","description":"Unique identifier of inference"},"frame_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Frame Id","description":"The frame id of the image used in inference if the input was a video"},"time":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Time","description":"The time in seconds it took to produce the predictions including image preprocessing"},"resolved_model":{"anyOf":[{"$ref":"#/components/schemas/ResolvedModel"},{"type":"null"}],"description":"Model identity and available package details for this result."},"image":{"anyOf":[{"items":{"$ref":"#/components/schemas/InferenceResponseImage"},"type":"array"},{"$ref":"#/components/schemas/InferenceResponseImage"}],"title":"Image"},"predictions":{"items":{"$ref":"#/components/schemas/ObjectDetectionPrediction"},"type":"array","title":"Predictions"}},"type":"object","required":["image","predictions"],"title":"ObjectDetectionInferenceResponse","description":"Object Detection inference response.\n\nAttributes:\n    predictions (List[inference.core.entities.responses.inference.ObjectDetectionPrediction]): List of object detection predictions."},"ObjectDetectionPrediction":{"properties":{"x":{"type":"number","title":"X","description":"The center x-axis pixel coordinate of the prediction"},"y":{"type":"number","title":"Y","description":"The center y-axis pixel coordinate of the prediction"},"width":{"type":"number","title":"Width","description":"The width of the prediction bounding box in number of pixels"},"height":{"type":"number","title":"Height","description":"The height of the prediction bounding box in number of pixels"},"confidence":{"type":"number","title":"Confidence","description":"The detection confidence as a fraction between 0 and 1"},"class":{"type":"string","title":"Class","description":"The predicted class label"},"class_confidence":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Class Confidence","description":"The class label confidence as a fraction between 0 and 1"},"class_id":{"type":"integer","title":"Class Id","description":"The class id of the prediction"},"tracker_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Tracker Id","description":"The tracker id of the prediction if tracking is enabled"},"detection_id":{"type":"string","title":"Detection Id","description":"Unique identifier of detection"},"parent_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Id","description":"Identifier of parent image region. Useful when stack of detection-models is in use to refer the RoI being the input to inference"}},"type":"object","required":["x","y","width","height","confidence","class","class_id"],"title":"ObjectDetectionPrediction","description":"Object Detection prediction.\n\nAttributes:\n    x (float): The center x-axis pixel coordinate of the prediction.\n    y (float): The center y-axis pixel coordinate of the prediction.\n    width (float): The width of the prediction bounding box in number of pixels.\n    height (float): The height of the prediction bounding box in number of pixels.\n    confidence (float): The detection confidence as a fraction between 0 and 1.\n    class_name (str): The predicted class label.\n    class_confidence (Union[float, None]): The class label confidence as a fraction between 0 and 1.\n    class_id (int): The class id of the prediction"},"AnomalyDetectionResponse":{"properties":{"visualization":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Visualization","description":"Base64 encoded string containing prediction visualization image data"},"inference_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Inference Id","description":"Unique identifier of inference"},"frame_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Frame Id","description":"The frame id of the image used in inference if the input was a video"},"time":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Time","description":"The time in seconds it took to produce the predictions including image preprocessing"},"resolved_model":{"anyOf":[{"$ref":"#/components/schemas/ResolvedModel"},{"type":"null"}],"description":"Model identity and available package details for this result."},"image":{"anyOf":[{"items":{"$ref":"#/components/schemas/InferenceResponseImage"},"type":"array"},{"$ref":"#/components/schemas/InferenceResponseImage"}],"title":"Image"},"predictions":{"items":{"$ref":"#/components/schemas/ClassificationPrediction"},"type":"array","title":"Predictions"},"top":{"type":"string","title":"Top","description":"The top predicted class label","default":""},"confidence":{"type":"number","title":"Confidence","description":"The confidence of the top predicted class label","default":0},"parent_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Id","description":"Identifier of parent image region. Useful when stack of detection-models is in use to refer the RoI being the input to inference"},"anomaly_score":{"type":"number","title":"Anomaly Score","description":"Raw anomaly score; larger means more anomalous"},"anomaly_threshold":{"type":"number","title":"Anomaly Threshold","description":"Decision threshold fitted on validation images"},"anomaly_scale":{"type":"number","title":"Anomaly Scale","description":"Calibration scale: the anomalous confidence is sigmoid((anomaly_score - anomaly_threshold) / anomaly_scale)"},"is_anomalous":{"type":"boolean","title":"Is Anomalous","description":"Whether the anomalous confidence reached the request confidence"},"anomaly_map":{"anyOf":[{"$ref":"#/components/schemas/AnomalyMapPayload"},{"type":"null"}],"description":"Raw local anomaly evidence at the network input resolution"}},"type":"object","required":["image","predictions","anomaly_score","anomaly_threshold","anomaly_scale","is_anomalous"],"title":"AnomalyDetectionResponse"},"ClassificationPrediction":{"properties":{"class":{"type":"string","title":"Class","description":"The predicted class label"},"class_id":{"type":"integer","title":"Class Id","description":"Numeric ID associated with the class label"},"confidence":{"type":"number","title":"Confidence","description":"The class label confidence as a fraction between 0 and 1"}},"type":"object","required":["class","class_id","confidence"],"title":"ClassificationPrediction","description":"Classification prediction.\n\nAttributes:\n    class_name (str): The predicted class label.\n    class_id (int): Numeric ID associated with the class label.\n    confidence (float): The class label confidence as a fraction between 0 and 1."},"AnomalyMapPayload":{"properties":{"shape":{"items":{"type":"integer"},"type":"array","title":"Shape","description":"[height, width] of the map"},"dtype":{"type":"string","const":"float32","title":"Dtype","description":"Element type of the decoded `data`"},"data":{"type":"string","title":"Data","description":"Base64 of the row-major little-endian float32 map values"}},"type":"object","required":["shape","dtype","data"],"title":"AnomalyMapPayload","description":"Raw anomaly heatmap at the network input resolution.\n\n`data` is base64 of the row-major little-endian float32 values. The map covers\nthe whole image as the network saw it (resized to a square), so resizing it to\nthe image's width and height is a plain stretch. Values share the units of\n`anomaly_score` and are unbounded above."},"ClassificationInferenceResponse":{"properties":{"visualization":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Visualization","description":"Base64 encoded string containing prediction visualization image data"},"inference_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Inference Id","description":"Unique identifier of inference"},"frame_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Frame Id","description":"The frame id of the image used in inference if the input was a video"},"time":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Time","description":"The time in seconds it took to produce the predictions including image preprocessing"},"resolved_model":{"anyOf":[{"$ref":"#/components/schemas/ResolvedModel"},{"type":"null"}],"description":"Model identity and available package details for this result."},"image":{"anyOf":[{"items":{"$ref":"#/components/schemas/InferenceResponseImage"},"type":"array"},{"$ref":"#/components/schemas/InferenceResponseImage"}],"title":"Image"},"predictions":{"items":{"$ref":"#/components/schemas/ClassificationPrediction"},"type":"array","title":"Predictions"},"top":{"type":"string","title":"Top","description":"The top predicted class label","default":""},"confidence":{"type":"number","title":"Confidence","description":"The confidence of the top predicted class label","default":0},"parent_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Id","description":"Identifier of parent image region. Useful when stack of detection-models is in use to refer the RoI being the input to inference"}},"type":"object","required":["image","predictions"],"title":"ClassificationInferenceResponse","description":"Classification inference response.\n\nAttributes:\n    predictions (List[inference.core.entities.responses.inference.ClassificationPrediction]): List of classification predictions.\n    top (str): The top predicted class label.\n    confidence (float): The confidence of the top predicted class label."},"MultiLabelClassificationInferenceResponse":{"properties":{"visualization":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Visualization","description":"Base64 encoded string containing prediction visualization image data"},"inference_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Inference Id","description":"Unique identifier of inference"},"frame_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Frame Id","description":"The frame id of the image used in inference if the input was a video"},"time":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Time","description":"The time in seconds it took to produce the predictions including image preprocessing"},"resolved_model":{"anyOf":[{"$ref":"#/components/schemas/ResolvedModel"},{"type":"null"}],"description":"Model identity and available package details for this result."},"image":{"anyOf":[{"items":{"$ref":"#/components/schemas/InferenceResponseImage"},"type":"array"},{"$ref":"#/components/schemas/InferenceResponseImage"}],"title":"Image"},"predictions":{"additionalProperties":{"$ref":"#/components/schemas/MultiLabelClassificationPrediction"},"type":"object","title":"Predictions"},"predicted_classes":{"items":{"type":"string"},"type":"array","title":"Predicted Classes","description":"The list of predicted classes"},"parent_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Id","description":"Identifier of parent image region. Useful when stack of detection-models is in use to refer the RoI being the input to inference"}},"type":"object","required":["image","predictions","predicted_classes"],"title":"MultiLabelClassificationInferenceResponse","description":"Multi-label Classification inference response.\n\nAttributes:\n    predictions (Dict[str, inference.core.entities.responses.inference.MultiLabelClassificationPrediction]): Dictionary of multi-label classification predictions.\n    predicted_classes (List[str]): The list of predicted classes."},"MultiLabelClassificationPrediction":{"properties":{"confidence":{"type":"number","title":"Confidence","description":"The class label confidence as a fraction between 0 and 1"},"class_id":{"type":"integer","title":"Class Id","description":"Numeric ID associated with the class label"}},"type":"object","required":["confidence","class_id"],"title":"MultiLabelClassificationPrediction","description":"Multi-label Classification prediction.\n\nAttributes:\n    confidence (float): The class label confidence as a fraction between 0 and 1."},"SemanticSegmentationInferenceResponse":{"properties":{"visualization":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Visualization","description":"Base64 encoded string containing prediction visualization image data"},"inference_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Inference Id","description":"Unique identifier of inference"},"frame_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Frame Id","description":"The frame id of the image used in inference if the input was a video"},"time":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Time","description":"The time in seconds it took to produce the predictions including image preprocessing"},"resolved_model":{"anyOf":[{"$ref":"#/components/schemas/ResolvedModel"},{"type":"null"}],"description":"Model identity and available package details for this result."},"image":{"anyOf":[{"items":{"$ref":"#/components/schemas/InferenceResponseImage"},"type":"array"},{"$ref":"#/components/schemas/InferenceResponseImage"}],"title":"Image"},"predictions":{"$ref":"#/components/schemas/SemanticSegmentationPrediction"}},"type":"object","required":["image","predictions"],"title":"SemanticSegmentationInferenceResponse","description":"Semantic Segmentation inference response.\n\nAttributes:\n    predictions (inference.core.entities.responses.inference.SemanticSegmentationPrediction): Semantic segmentation predictions."},"SemanticSegmentationPrediction":{"properties":{"segmentation_mask":{"type":"string","title":"Segmentation Mask","description":"base64-encoded PNG of predicted class label at each pixel. When the request sets response_mask_format='numpy' (in-process fast path), this carries the raw uint8 numpy label map instead; JSON serialization always yields the base64 PNG string."},"class_map":{"additionalProperties":{"type":"string"},"type":"object","title":"Class Map","description":"Map of pixel intensity value to class label"},"confidence_mask":{"type":"string","title":"Confidence Mask","description":"base64-encoded PNG of predicted class confidence at each pixel. When the request sets response_mask_format='numpy' (in-process fast path), this carries the raw uint8 numpy confidence map instead; JSON serialization always yields the base64 PNG string."},"present_class_ids":{"anyOf":[{"items":{"type":"integer"},"type":"array"},{"type":"null"}],"title":"Present Class Ids","description":"Sorted list of pixel values present in segmentation_mask, including background (0) when present. Optimization hint that lets consumers skip scanning the full-resolution mask; consumers must fall back to scanning when this field is absent."}},"type":"object","required":["segmentation_mask","class_map","confidence_mask"],"title":"SemanticSegmentationPrediction"},"StubResponse":{"properties":{"visualization":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Visualization","description":"Base64 encoded string containing prediction visualization image data"},"inference_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Inference Id","description":"Unique identifier of inference"},"frame_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Frame Id","description":"The frame id of the image used in inference if the input was a video"},"time":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Time","description":"The time in seconds it took to produce the predictions including image preprocessing"},"resolved_model":{"anyOf":[{"$ref":"#/components/schemas/ResolvedModel"},{"type":"null"}],"description":"Model identity and available package details for this result."},"is_stub":{"type":"boolean","title":"Is Stub","description":"Field to mark prediction type as stub"},"model_id":{"type":"string","title":"Model Id","description":"Identifier of a model stub that was called"},"task_type":{"type":"string","title":"Task Type","description":"Task type of the project"}},"type":"object","required":["is_stub","model_id","task_type"],"title":"StubResponse"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}
```

### 이미지에서 모델 실행

Roboflow는 여러 런타임을 통해 추론을 제공합니다. 적절한 선택은 단일 모델을 호출하는지, Workflow를 호출하는지, 필요한 처리량이 얼마나 되는지, 그리고 워크로드가 어디에서 실행되는지에 따라 달라집니다.

이 페이지는 간단한 개요입니다. 자세한 추론 참조는 같은 문서 사이트의 [제품 문서](/deployment/ko/readme.md)에 있습니다. 더 깊은 내용이 있는 곳에는 상호 링크가 제공됩니다.

#### 추론 런타임

| 런타임                                                  | 다음과 같은 경우 사용                                                     | 참조                                                                                                                                         |
| ---------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| **Serverless Cloud API** (`serverless.roboflow.com`) | 기본값. 호스팅되며 자동 확장되고, 모델과 Workflows를 지원합니다.                        | [Serverless Cloud API](/deployment/ko/roboflow-cloud/serverless-api.md)                                                                    |
| **전용 배포**                                            | 예측 가능한 지연 시간, 높은 처리량 또는 고정 GPU 유형이 필요할 때 사용합니다. Roboflow가 관리합니다. | [전용 배포](/deployment/ko/roboflow-cloud/dedicated-deployments.md#http-api) 및 [제품 개요](/deployment/ko/roboflow-cloud/dedicated-deployments.md) |
| **Roboflow Inference** (자체 호스팅)                      | 온프레미스, 엣지 장치, 에어갭 환경, 또는 VPC 밖으로 나갈 수 없는 워크로드. 오픈 소스.            | [자체 호스팅 배포](/deployment/ko/self-hosted/self-hosted.md)                                                                                     |

#### Serverless Cloud API 호출

모델 실행:

```bash
curl -F "file=@photo.jpg" \
  -H "Authorization: Bearer $ROBOFLOW_API_KEY" \
  "https://serverless.roboflow.com/<project>/<version>?confidence=0.5"
```

워크플로 실행:

```bash
curl -X POST "https://serverless.roboflow.com/infer/workflows/<workspace>/<workflow>" \
  -H "Authorization: Bearer $ROBOFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": { "image": { "type": "url", "value": "https://example.com/photo.jpg" } }
  }'
```

{% hint style="info" %}
키를 다음으로 보내는 것은 `?api_key=` 쿼리 매개변수 또는 `api_key` 본문 필드는 레거시 채널입니다. 여전히 작동하지만, `Authorization: Bearer` 헤더는 키가 URL과 로그에 남지 않게 합니다. 참조: [REST API로 인증](https://docs.roboflow.com/reference/platform/rest-api/authenticate-with-the-rest-api).
{% endhint %}

실시간 비디오는 다음을 참조하세요. [Serverless Video Streaming API](/deployment/ko/roboflow-cloud/serverless-api/serverless-video-streaming-api.md). 대규모 이미지 및 비디오 세트의 비동기 처리는 다음을 참조하세요. [일괄 처리](/deployment/ko/roboflow-cloud/batch-processing.md).

#### 지원 종료: Serverless v1

기존의 작업별 엔드포인트인 `detect.roboflow.com`, `classify.roboflow.com`, `outline.roboflow.com`, `segment.roboflow.com` 는 **지원 종료되었습니다**. 하위 호환성을 위해 여전히 응답하지만, 새 코드는 `serverless.roboflow.com` 를 대신 사용해야 합니다.

다음으로 가리키는 스니펫을 찾으면 `*.roboflow.com` 작업 호스트로 간주하고, 레거시로 처리하여 위의 Serverless Cloud API 형식으로 변환하세요.

## Python SDK

### Python SDK와 함께 사용

Python에서 작업하는 경우, Serverless Cloud API와 상호작용하는 가장 편리한 방법은 Inference Python SDK를 사용하는 것입니다.

다음을 사용하려면 [Inference SDK](https://docs.roboflow.com/reference/inference/inference-sdk)를 먼저 설치하세요:

```
pip install inference-sdk
```

Serverless Cloud API에 요청을 보내려면 다음 코드를 사용하세요:

<pre class="language-python"><code class="lang-python"><strong>from inference_sdk import InferenceHTTPClient, InferenceConfiguration
</strong>
CLIENT = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key="API_KEY"
).configure(InferenceConfiguration(api_key_transport="header"))

result = CLIENT.infer("image.jpg", model_id="model-id/1")
print(result)
</code></pre>

위에서 [모델 ID](https://docs.roboflow.com/reference/authentication/authentication/workspace-and-project-ids) 및 [API 키](https://docs.roboflow.com/reference/authentication/authentication/find-your-roboflow-api-key)를 지정하세요. 이 코드는 모델을 실행하고 결과를 반환합니다.

#### Roboflow Instant Model

Serverless Cloud API는 Roboflow [Instant Model](https://docs.roboflow.com/models/train/roboflow-instant)실행도 지원합니다. Instant Model은 다른 모델처럼 실행할 수 있지만, 신뢰도 임계값이 Instant Model에 민감할 수 있다는 점에 유의하세요.

{% hint style="info" %}
최적의 신뢰도는 모델이 학습된 이미지 수에 따라 달라집니다. 최적의 신뢰도 임계값은 보통 0.85에서 0.99 사이입니다.
{% endhint %}

```python
configuration = InferenceConfiguration(
    confidence_threshold=0.95,
    api_key_transport="header",
)
CLIENT.configure(configuration)

result = CLIENT.infer("image.jpg", model_id="roboflow-instant-model-id/1")
```

`configure(...)` 는 전체 구성을 대체하므로, `api_key_transport` 를 적용하는 모든 구성에 포함하세요.

### Python SDK로 비디오 스트리밍

Inference SDK WebRTC 클라이언트를 사용하여 비디오에서 객체 탐지 모델을 실행하세요. Serverless Video Streaming API는 Roboflow Cloud에서 비디오를 처리하고 각 프레임에 대한 예측을 반환합니다.

SDK를 WebRTC 종속성과 함께 설치하고 `supervision`:

```bash
pip install "inference-sdk[webrtc]" supervision
```

```python
import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient
from inference_sdk.webrtc import VideoFileSource

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

session = client.webrtc.stream(
    source=VideoFileSource("video.mp4"),
    model_id="model-id/1",
)

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

@session.on_frame
def show(frame, data):
    if data is None:
        return

    detections = sv.Detections.from_inference(data)
    annotated = box_annotator.annotate(frame.copy(), detections)
    annotated = label_annotator.annotate(annotated, detections)
    cv2.imshow("Predictions", annotated)

    if cv2.waitKey(1) & 0xFF == ord("q"):
        session.close()

session.run()
cv2.destroyAllWindows()
```

다음을 대체하세요 `API_KEY` 및 `model-id/1` 를 여러분의 API 키와 모델 ID로 바꾸세요. 웹캠과 RTSP 카메라에서 스트리밍하는 방법, 모든 프레임을 처리하는 방법, 또는 다음의 Workflow를 실행하는 방법을 알아보세요. [Serverless Video Streaming API 가이드](/deployment/ko/roboflow-cloud/serverless-api/serverless-video-streaming-api.md).

## CLI

Roboflow CLI를 사용하면 Roboflow에서 학습된 모델이나 [Roboflow Universe](https://universe.roboflow.com).

의 오픈 소스 모델로 모델을 실행할 수 있습니다. `roboflow infer` 를 명령줄에서 실행하면 CLI가 이미지를 Roboflow API로 보내고 예측을 출력합니다.

### 명령

```bash
roboflow infer <image-path> -m <project/version>
```

#### 옵션

| 플래그                  | 설명                                                                                                                            |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `-m`, `--model`      | 다음 형식의 모델 ID `project/version` (필수)                                                                                           |
| `-c`, `--confidence` | 신뢰도 임계값, 0.0–1.0(기본값: 0.5)                                                                                                    |
| `-o`, `--overlap`    | 중복/NMS 임계값, 0.0–1.0(기본값: 0.5)                                                                                                 |
| `-t`, `--type`       | 모델 유형(자동 감지 생략): `object-detection`, `classification`, `instance-segmentation`, `semantic-segmentation`, `keypoint-detection` |

### 예시

Roboflow Universe의 오픈 소스 모델을 사용하여 추론을 실행합니다. 예를 들어, [poker-cards](https://universe.roboflow.com/roboflow-100/poker-cards-cxcvz/model/1) 데이터셋:

```bash
roboflow infer ~/Downloads/ace.jpg -m poker-cards-cxcvz/1 -c 0.7
```

작업공간은 기본적으로 구성된 작업공간으로 설정됩니다. 다른 작업공간의 모델을 사용하려면:

```bash
roboflow infer photo.jpg -m poker-cards-cxcvz/1 -w roboflow-100
```

자동 감지 API 호출을 생략하려면 모델 유형을 지정하세요:

```bash
roboflow infer photo.jpg -m my-project/3 -t object-detection
```

### JSON 출력

사용 `--json` 를 사용하여 스크립팅 및 자동화를 위한 구조화된 예측 데이터를 가져오세요:

```bash
roboflow infer photo.jpg -m my-project/3 --json
```

```json
{
  "predictions": [
    {
      "x": 1230.0,
      "y": 814.5,
      "width": 840.0,
      "height": 1273.0,
      "confidence": 0.882,
      "class": "Scissors",
      "class_id": 2
    }
  ]
}
```

지원되는 모든 매개변수는 다음에서 확인하세요. `roboflow infer --help`.

## MCP 서버

AI 에이전트를 다음에 연결하세요. [MCP 서버](https://docs.roboflow.com/agents/mcp-server) 그러면 다음 도구로 이미지에서 모델을 실행할 수 있습니다:

<table data-search="false"><thead><tr><th width="290">도구</th><th>설명</th></tr></thead><tbody><tr><td><code>models_infer</code></td><td>학습된 모델을 사용하여 이미지에서 호스팅 추론을 실행합니다.</td></tr><tr><td><code>workflows_run</code></td><td>저장된 Workflow를 하나 이상의 이미지에 대해 실행합니다.</td></tr><tr><td><code>project_deployment_run</code></td><td>프로젝트의 안정적인 라이브 엔드포인트를 통해 추론을 실행합니다.</td></tr></tbody></table>
