> 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/roboflow/roboflow-jp/depuroi/serverless-hosted-api-v2/use-with-python-sdk.md).

# Python SDK で使用する

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

を使用するには、 [Inference SDK](https://inference.roboflow.com/inference_helpers/inference_sdk/)、まずインストールしてください：

```
pip install inference-sdk
```

Serverless Hosted APIにリクエストを送るには、以下のコードを使用してください：

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

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

上記で、あなたの [モデルID](https://docs.roboflow.com/developer/authentication/workspace-and-project-ids) と [API key](https://docs.roboflow.com/developer/authentication/find-your-roboflow-api-key)。このコードはモデルを実行し、結果を返します。

#### Roboflow Instant Model

Serverless APIはRoboflowの実行もサポートしています [Instant Model](/roboflow/roboflow-jp/xue-xi/roboflow-instant.md)。Instant Modelは他のモデルと同じように実行できますが、confidence thresholdはInstant Modelsでは敏感になる場合があることに注意してください。

{% hint style="info" %}
最適なconfidenceは、モデルが学習した画像の数によって異なります。最適なconfidence thresholdは通常0.85から0.99の範囲です。
{% endhint %}

```python
configuration = InferenceConfiguration(
    confidence_threshold=0.95
)
CLIENT.configure(configuration)

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