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

# सर्वरलेस क्लाउड API

## के बारे में

Roboflow पर तैनात मॉडल्स के लिए एक REST API उपलब्ध होती है, जिसके माध्यम से आप इमेजों पर इन्फ़रेंस चला सकते हैं। यह डिप्लॉयमेंट तरीका उन परिवेशों के लिए आदर्श है जहाँ आपके डिप्लॉयमेंट डिवाइस पर स्थायी इंटरनेट कनेक्शन होता है।

ऐप में, इस एंडपॉइंट को "Serverless Cloud API" कहा जाता है, या जहाँ जगह कम हो वहाँ "Cloud API" (उदा.: Workflow editor runtime picker)। एक [समर्पित डिप्लॉयमेंट](/deployment/hi/roboflow-cloud/dedicated-deployments.md) एंडपॉइंट (`*.roboflow.cloud`) को "Dedicated Cloud API" कहा जाता है, और पुराने v1 एंडपॉइंट को "Hosted API (Legacy)" कहा जाता है। ये लेबल पहले के "Serverless Hosted API" और "Serverless API V2" नामों की जगह लेते हैं।

आप Serverless Cloud API का उपयोग कर सकते हैं:

* [वर्कफ़्लोज़ में](/deployment/hi/roboflow-cloud/serverless-api/use-in-a-workflow.md)
* [REST API के साथ](#http-api)
* के साथ [Inference Python SDK](#python-sdk)

### Inference सर्वर

हमारा Serverless Cloud API द्वारा संचालित है [इन्फ़रेंस सर्वर](https://docs.roboflow.com/reference/platform/rest-api/inference-server-openapi). इसका मतलब है कि आप नीचे दिखाए अनुसार हमारे Serverless Cloud API और self-hosting विकल्प के बीच, और vice versa, आसानी से स्विच कर सकते हैं:

```python
from inference_sdk import InferenceHTTPClient, InferenceConfiguration

CLIENT = InferenceHTTPClient(
    # api_url="http://localhost:9001" # स्व-होस्टेड Inference server
    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` हेडर, जिससे यह URLs और लॉग्स में नहीं जाता: सभी नए कोड के लिए अनुशंसित। Inference 1.5.0 से पुराने सर्वर हेडर नहीं पढ़ते; उपयोग करें `api_key_transport="both"` जबकि आप अभी भी एक को कॉल करते हैं। देखें [API key transport](https://docs.roboflow.com/reference/inference/inference-sdk/configuration#api-key-transport).

### सीमाएँ

हमारा Serverless Cloud API 20MB तक फ़ाइल अपलोड का समर्थन करता है। उच्च रिज़ॉल्यूशन वाली इमेजों के साथ आपको सीमाओं का सामना करना पड़ सकता है। यदि आपको कोई समस्या आती है, तो कृपया अपने एंटरप्राइज़ सपोर्ट संपर्क से संपर्क करें या [फ़ोरम पर](https://discuss.roboflow.com).

{% hint style="info" %}
ऐसी स्थितियों में जहाँ अनुरोध बहुत बड़े हों, हम किसी भी संलग्न इमेज को छोटा करने की सलाह देते हैं। इससे आम तौर पर प्रदर्शन खराब नहीं होगा, क्योंकि इमेजें वैसे भी हमारे सर्वरों पर प्राप्त होने के बाद मॉडल आर्किटेक्चर द्वारा स्वीकार किए जाने वाले इनपुट आकार तक छोटा कर दी जाती हैं।\
\
हमारे कुछ SDKs, जैसे Python SDK, API को भेजे जाने से पहले ही इमेजों को मॉडल आर्किटेक्चर के इनपुट आकार तक स्वचालित रूप से छोटा कर देते हैं।
{% endhint %}

***

देखें [Serverless Cloud API v1](/deployment/hi/legacy/legacy-serverless.md) विरासती API दस्तावेज़ीकरण के लिए।

## HTTP API

### REST API के साथ उपयोग करें

Serverless Cloud API में सभी मॉडल्स और वर्कफ़्लोज़ के लिए एक ही एंडपॉइंट है:

```
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.5.0-post2"},"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":"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":"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":"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/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"},"image":{"anyOf":[{"items":{"$ref":"#/components/schemas/InferenceResponseImage"},"type":"array"},{"$ref":"#/components/schemas/InferenceResponseImage"}],"title":"Image"},"predictions":{"items":{"anyOf":[{"$ref":"#/components/schemas/InstanceSegmentationPrediction"},{"$ref":"#/components/schemas/InstanceSegmentationRLEPrediction"}]},"type":"array","title":"Predictions"}},"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."},"InferenceResponseImage":{"properties":{"width":{"type":"integer","title":"Width","description":"The original width of the image used in inference"},"height":{"type":"integer","title":"Height","description":"The original height of the image used in inference"}},"type":"object","required":["width","height"],"title":"InferenceResponseImage","description":"Inference response image information.\n\nAttributes:\n    width (int): The original width of the image used in inference.\n    height (int): The original height of the image used in inference."},"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"},"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"},"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"},"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"},"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"},"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."},"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."},"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"},"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"},"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"},"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 कई runtime के माध्यम से inference उपलब्ध कराता है - सही विकल्प इस बात पर निर्भर करता है कि आप एकल मॉडल या Workflow को कॉल कर रहे हैं, आपको कितना throughput चाहिए, और workload कहाँ चलता है।

यह पृष्ठ एक संक्षिप्त अवलोकन है। विस्तृत inference संदर्भ [उत्पाद दस्तावेज़ीकरण](/deployment/hi/readme.md)में मिलता है, जो उसी docs site का हिस्सा है। जहाँ विस्तृत सामग्री है, वहाँ cross-links दिए गए हैं।

#### Inference runtime

| Runtime                                             | कब उपयोग करें                                                                                                       | संदर्भ                                                                                                                                                              |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **सर्वरलेस क्लाउड API** (`serverless.roboflow.com`) | डिफ़ॉल्ट। होस्टेड, ऑटो-स्केलिंग, मॉडल्स और वर्कफ़्लोज़ का समर्थन करता है।                                           | [सर्वरलेस क्लाउड API](/deployment/hi/roboflow-cloud/serverless-api.md)                                                                                              |
| **समर्पित डिप्लॉयमेंट्स**                           | आपको पूर्वानुमेय latency, उच्च throughput, या pinned GPU type चाहिए। Roboflow द्वारा प्रबंधित।                      | [समर्पित डिप्लॉयमेंट्स](/deployment/hi/roboflow-cloud/dedicated-deployments.md#http-api) और [उत्पाद अवलोकन](/deployment/hi/roboflow-cloud/dedicated-deployments.md) |
| **Roboflow Inference** (self-hosted)                | ऑन-प्रिमाइसेस, edge devices, air-gapped environments, या ऐसे workloads जो आपकी VPC से बाहर नहीं जा सकते। ओपन सोर्स। | [स्व-होस्टेड डिप्लॉयमेंट](/deployment/hi/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"
```

एक Workflow चलाएँ:

```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` header आपकी कुंजी को URLs और लॉग्स से बाहर रखता है। देखें [REST API के साथ प्रमाणीकरण करें](https://docs.roboflow.com/reference/platform/rest-api/authenticate-with-the-rest-api).
{% endhint %}

लाइव वीडियो के लिए, देखें [Serverless Video Streaming API](/deployment/hi/roboflow-cloud/serverless-api/serverless-video-streaming-api.md). बड़े इमेज और वीडियो सेटों की असिंक्रोनस प्रोसेसिंग के लिए, देखें [बैच प्रोसेसिंग](/deployment/hi/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 key](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 को किसी अन्य मॉडल की तरह चला सकते हैं, बस ध्यान दें कि confidence threshold Instant Models के लिए संवेदनशील हो सकता है।

{% hint style="info" %}
एक इष्टतम confidence मॉडल को प्रशिक्षित की गई इमेजों की संख्या पर निर्भर करता है। इष्टतम confidence thresholds आम तौर पर 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 के साथ वीडियो स्ट्रीम करें

वीडियो पर object detection मॉडल चलाने के लिए Inference SDK WebRTC क्लाइंट का उपयोग करें। Serverless Video Streaming API वीडियो को Roboflow Cloud में प्रोसेस करता है और हर फ़्रेम के लिए predictions लौटाता है।

SDK को उसके WebRTC dependencies के साथ और `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("पूर्वानुमान", annotated)

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

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

बदलें `API_KEY` और `model-id/1` को अपनी API key और model ID से बदलें। जानें कि webcams और RTSP cameras से stream कैसे करें, हर फ़्रेम को process कैसे करें, या [Serverless Video Streaming API गाइड](/deployment/hi/roboflow-cloud/serverless-api/serverless-video-streaming-api.md).

## CLI

आप Roboflow पर प्रशिक्षित मॉडल चलाने के लिए Roboflow CLI का उपयोग कर सकते हैं, या [Roboflow Universe](https://universe.roboflow.com).

चलाकर `roboflow infer` कमांड लाइन में, CLI इमेज को Roboflow API पर भेजता है और predictions प्रिंट करता है।

### कमांड

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

#### विकल्प

| फ़्लैग               | विवरण                                                                                                                                  |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `-m`, `--model`      | में मॉडल ID `project/version` फ़ॉर्मेट (आवश्यक)                                                                                        |
| `-c`, `--confidence` | Confidence threshold, 0.0–1.0 (डिफ़ॉल्ट: 0.5)                                                                                          |
| `-o`, `--overlap`    | Overlap/NMS threshold, 0.0–1.0 (डिफ़ॉल्ट: 0.5)                                                                                         |
| `-t`, `--type`       | मॉडल प्रकार (auto-detection छोड़ें): `ऑब्जेक्ट डिटेक्शन`, `वर्गीकरण`, `इंस्टेंस सेगमेंटेशन`, `सिमैंटिक सेगमेंटेशन`, `कीपॉइंट डिटेक्शन` |

### उदाहरण

Roboflow Universe से किसी open source मॉडल का उपयोग करके inference चलाएँ - उदाहरण के लिए, [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
```

auto-detection API call को छोड़ने के लिए मॉडल प्रकार निर्दिष्ट करें:

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

### JSON आउटपुट

उपयोग करें `--json` स्क्रिप्टिंग और ऑटोमेशन के लिए संरचित prediction डेटा प्राप्त करने हेतु:

```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": "कैंची",
      "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>प्रशिक्षित मॉडल का उपयोग करके एक इमेज पर hosted inference चलाएँ।</td></tr><tr><td><code>workflows_run</code></td><td>एक या अधिक इमेजों पर सहेजा गया Workflow निष्पादित करें।</td></tr><tr><td><code>project_deployment_run</code></td><td>प्रोजेक्ट के स्थिर live endpoint के माध्यम से inference चलाएँ।</td></tr></tbody></table>
