REST APIで使用する

サーバーレスホストAPI V2は、すべてのモデルとワークフローに対して1つのエンドポイントがあります:

https://serverless.roboflow.com
モデルタイプ
サーバーレスホステッドAPI V2
ホストAPI V1

物体検出、キーポイント検出

https://serverless.roboflow.com

https://detect.roboflow.com

インスタンスセグメンテーション

https://serverless.roboflow.com

https://outline.roboflow.com

分類

https://serverless.roboflow.com

https://classify.roboflow.com

セマンティックセグメンテーション

現在サポートされていません

https://segment.roboflow.com

ファウンデーションモデル(例:CLIP、OCR、YOLO-World)

https://serverless.roboflow.com

https://infer.roboflow.com

HTTPでリクエストを送信する

Endpoint to run predefined workflow

post

Checks Roboflow API for workflow definition, once acquired - parses and executes injecting runtime parameters from request body

Path parameters
workspace_namestringRequired
workflow_idstringRequired
Body
api_keyany ofOptional

Roboflow API Key that will be passed to the model during initialization for artifact retrieval

stringOptional
or
nullOptional
excluded_fieldsany ofOptional

List of field that shall be excluded from the response (among those defined in workflow specification)

string[]Optional
or
nullOptional
enable_profilingbooleanOptional

Flag to request Workflow run profiling. Enables Workflow profiler only when server settings allow profiling traces to be exported to clients. Only applies for Workflows definitions saved on Roboflow platform.

Default: false
workflow_idany ofOptional

Optional identifier of workflow

stringOptional
or
nullOptional
use_cachebooleanOptional

Controls usage of cache for workflow definitions. Set this to False when you frequently modify definition saved in Roboflow app and want to fetch the newest version for the request.

Default: true
Responses
200

Successful Response

application/json
post
POST /{workspace_name}/workflows/{workflow_id} HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 156

{
  "api_key": "text",
  "inputs": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "excluded_fields": [
    "text"
  ],
  "enable_profiling": false,
  "workflow_id": "text",
  "use_cache": true
}
{
  "outputs": [
    {
      "ANY_ADDITIONAL_PROPERTY": "anything"
    }
  ],
  "profiler_trace": [
    {
      "ANY_ADDITIONAL_PROPERTY": "anything"
    }
  ]
}

Python SDKでリクエストを送信する

Pythonで作業している場合、サーバーレスAPIとやり取りする最も便利な方法は、Inference Python SDKを使用することです。

SDKを使用するには、まずインストールしてください:

pip install inference-sdk

サーバーレスホストAPI V2にリクエストを送信するには、次のコードを使用します:

from inference_sdk import InferenceHTTPClient

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

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

上記で、あなたの モデルIDAPIキー.

Last updated

Was this helpful?