# 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>

上で、次を指定してください: [model 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](https://docs.roboflow.com/roboflow/roboflow-jp/train/roboflow-instant)。Instant Model は他のモデルと同じように実行できますが、confidence threshold は Instant Model では影響を受けやすい点に注意してください。

{% 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")
```
