> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jiekou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ビジョン言語モデル

export const VisionModels = () => {
  if (typeof document === "undefined") {
    return null;
  } else {
    let attempts = 0;
    const maxAttempts = 50;
    const INIT_DISPLAY_COUNT = 3;
    const interval = setInterval(() => {
      const clientComponent = document.getElementById("vision-models");
      if (clientComponent && window.jiekouRemoteData.llmModels.status === 'loaded') {
        const modelList = window.jiekouRemoteData.llmModels.data.filter(model => {
          return (model.features || []).includes('vision');
        });
        let displayModels = modelList.slice(0, INIT_DISPLAY_COUNT).map(model => {
          return `<li><span class="model-id-item">${model.id}</span></li>`;
        }).join('');
        let showMoreButton = '';
        if (modelList.length > INIT_DISPLAY_COUNT) {
          showMoreButton = `<button id="show-more-vision-model-btn" style="margin-left: 32px; color: rgb(40 116 255)">展示更多</button>`;
        }
        clientComponent.innerHTML = `
          <ul>${displayModels}</ul>
          ${showMoreButton}
        `;
        document.getElementById('show-more-vision-model-btn')?.addEventListener('click', () => {
          clientComponent.innerHTML = `
            <ul>${modelList.map(model => {
            return `<li><span class="model-id-item">${model.id}</span></li>`;
          }).join('')}</ul>
          `;
        });
        clearInterval(interval);
      }
      attempts++;
      if (attempts >= maxAttempts) {
        clearInterval(interval);
      }
    }, 200);
    return <div id="vision-models"></div>;
  }
};

## 機能紹介

ビジョン言語モデル（Vision-Language Model, VLM）は、画像とテキストの入力を同時にサポートするマルチモーダル大規模モデルの一種であり、画像内容の理解とクロスモーダル情報処理能力を備えています。モデルは画像とテキストを組み合わせた情報に基づき、高品質な応答内容を出力でき、画像認識、内容理解、インテリジェント QA などのシーンで広く利用されています。

### 代表的なユースケース

* **画像内容の認識と説明**：画像内の物体、色、シーン、空間関係を自動的に認識し、自然言語による説明を生成します。
* **画像とテキストの総合理解**：画像とテキスト入力を組み合わせ、コンテキストに応じた複数ターンの対話や複雑なタスクへの応答を実現します。
* **視覚支援 QA**：OCR ツールの補完として、画像内に埋め込まれたテキスト情報を認識し、質問応答を行えます。
* **将来的な拡張用途**：インテリジェント視覚アシスタント、ロボット知覚、拡張現実などのインタラクションシーンに適しています。

## API 呼び出し説明

ビジョン言語モデルを呼び出すには、`/chat/completions` エンドポイントを使用し、画像とテキストの混合入力をサポートします。

### 画像処理パラメータ

`detail` フィールドで画像処理の精度を設定します。以下のオプションをサポートしています。

* `high`：高解像度。より多くの詳細を保持し、精密なタスクに適しています。
* `low`：低解像度。処理速度が速く、リアルタイム応答に適しています。
* `auto`：システムが適切なモードを自動選択します。

### メッセージ形式の例

#### URL 画像形式

```json theme={null}
{
  "role": "user",
  "content": [
    {
      "type": "image_url",
      "image_url": {
        "url": "https://example.com/image.png",
        "detail": "high"
      }
    },
    {
      "type": "text",
      "text": "画像内のシーンを説明してください。"
    }
  ]
}
```

#### Base64 画像形式

```json theme={null}
{
  "role": "user",
  "content": [
    {
      "type": "image_url",
      "image_url": {
        "url": "data:image/jpeg;base64,{base64_image}",
        "detail": "low"
      }
    },
    {
      "type": "text",
      "text": "画像内にはどのような文字がありますか？"
    }
  ]
}
```

### Base64 画像エンコードのサンプルコード（Python）

```python theme={null}
import base64
from PIL import Image
import io

def image_to_base64(image_path):
    with Image.open(image_path) as img:
        buffered = io.BytesIO()
        img.save(buffered, format="JPEG")
        return base64.b64encode(buffered.getvalue()).decode('utf-8')

base64_image = image_to_base64("path/to/your/image.jpg")
```

## 複数画像モード

複数の画像とテキストをまとめて入力として送信できます。より良いパフォーマンスと理解精度を得るため、最大 2 枚までを推奨します。

```json theme={null}
{
  "role": "user",
  "content": [
    {
      "type": "image_url",
      "image_url": {
        "url": "https://example.com/image1.png"
      }
    },
    {
      "type": "image_url",
      "image_url": {
        "url": "data:image/jpeg;base64,{base64_image}"
      }
    },
    {
      "type": "text",
      "text": "この 2 枚の画像に共通する特徴を比較してください。"
    }
  ]
}
```

## 対応モデル

現在プラットフォームでサポートされているビジョン言語モデル（VLM）は以下のとおりです。

<VisionModels />

## 料金体系

ビジョン言語モデルの画像入力はトークンに変換され、テキストと合わせて呼び出し料金が計算されます。

* 画像トークンの見積もりルールはモデルごとに多少異なります。
* 詳細な料金基準は、各モデルの紹介ページで確認できます。

## API 呼び出しサンプルコード

### 単一画像の説明

```python theme={null}
from openai import OpenAI

client = OpenAI(api_key="YOUR_KEY", base_url="https://api.highwayapi.ai/openai")

response = client.chat.completions.create(
    model="qwen/qwen2.5-vl-72b-instruct",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "image_url", "image_url": {"url": "https://example.com/cityscape.jpg"}},
                {"type": "text", "text": "画像内の主な建物を説明してください。"}
            ]
        }
    ],
    stream=True
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="", flush=True)
```

### 複数画像の比較分析

```python theme={null}
response = client.chat.completions.create(
    model="qwen/qwen2.5-vl-72b-instruct",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "image_url", "image_url": {"url": "https://example.com/product1.jpg"}},
                {"type": "image_url", "image_url": {"url": "https://example.com/product2.jpg"}},
                {"type": "text", "text": "この 2 つの製品の主な違いを比較してください。"}
            ]
        }
    ],
    stream=True
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="", flush=True)
```

## よくある質問と説明

* 画像の解像度と鮮明度はモデルの認識精度に影響します。鮮明な画像ソースの使用を推奨します。
* Base64 エンコードはサイズが大きくなるため、画像は 1MB 以下を推奨します。
* 問題が発生した場合は、プラットフォームの開発者ドキュメントを参照するか、チケットを送信してサポートを受けてください。
