😺
【Azure OpenAI】- detail パラメータの使い方について
執筆日
2025/7/15
解像度制御オプションとは?
Azure OpenAIのVision対応モデルでは、画像の処理精度と速度/コストをバランスよく制御するために、detail パラメータで解像度の指定ができます。指定可能な値は以下の3つです。
| オプション | 内容 | 
|---|---|
auto | 
既定の設定。 モデルは、画像入力のサイズに基づいて、lowまたはhighを決定します。 | 
low | 
512×512 の低解像度で高速処理、トークン消費を節約 できます。その結果、微細さが重要ではないシナリオでは応答が速くなり、トークンの消費量が少なくなります。 | 
high | 
高解像度でより正確な解析を実行。 この場合、モデルは最初に低解像度画像を表示し、次に入力画像から詳細な 512x512 セグメントを生成します。 各セグメントではトークンの予算が 2 倍使用されるため、画像をより詳細に解釈できます。 | 
実装サンプル(Python)
import base64
from openai import AzureOpenAI
llm_client = AzureOpenAI(
    api_key="YOUR_API_KEY",
    azure_endpoint="https://YOUR_RESOURCE_NAME.openai.azure.com/",
    azure_deployment="モデル名",
    api_version="2025-01-01-preview"
)
def encode_image_to_data_url(image_path):
    with open(image_path, "rb") as f:
        image_data = f.read()
    base64_image = base64.b64encode(image_data).decode("utf-8")
    return f"data:image/png;base64,{base64_image}"
# 入力画像をBase64変換
image_path = "ファイルパス"
image_url = encode_image_to_data_url(image_path)
# detail: "high" を明示的に指定
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {
        "role": "user",
        "content": [
            {"type": "text", "text": "この画像の内容を説明してください"},
            {
                "type": "image_url",
                "image_url": {
                    "url": image_url,
                    "detail": "high"  # auto / low / high が選択可能
                }
            }
        ]
    }
]
response = llm_client.chat.completions.create(
    model="モデル名",
    messages=messages
)
print(response.choices[0].message.content)
参考記事
Discussion