> ## Documentation Index
> Fetch the complete documentation index at: https://novita.ai/docs/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.novitaRemoteData.llmModels.status === 'loaded') {
        const modelList = window.novitaRemoteData.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)">View More</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>;
  }
};

## 概要

ビジョン言語モデル（VLM）は、画像入力とテキスト入力の両方を処理できるマルチモーダル基盤モデルの一種です。これらのモデルは、言語による指示と組み合わせて視覚コンテンツを理解し、統合されたコンテキストに基づいて高品質な応答を生成します。画像認識、コンテンツ解釈、インテリジェントな視覚 Q\&A などのシナリオで広く利用されています。

### 一般的なユースケース

* **画像認識と説明**: 画像内のオブジェクト、色、シーン、空間的関係を自動的に識別し、自然言語の説明を生成します。
* **マルチモーダル理解**: 画像入力とコンテキストテキストを組み合わせ、マルチターン対話やタスク完了を実現します。
* **視覚的な質問応答**: 画像内に埋め込まれたテキストを認識・解釈することで、高度な OCR ツールとして機能します。
* **新しい応用分野**: インテリジェントなビジョンアシスタント、ロボット知覚、AR インターフェースなどでの利用に最適です。

***

## API 使用ガイド

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

### 画像詳細パラメータ

画像解像度を制御するには、`detail` フィールドを使用します。以下のモードを利用できます。

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

***

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

#### URL 経由の画像

```json theme={"system"}
{
  "role": "user",
  "content": [
    {
      "type": "image_url",
      "image_url": {
        "url": "https://example.com/image.png",
        "detail": "high"
      }
    },
    {
      "type": "text",
      "text": "Please describe the scene in the image."
    }
  ]
}
```

#### Base64 経由の画像

```json theme={"system"}
{
  "role": "user",
  "content": [
    {
      "type": "image_url",
      "image_url": {
        "url": "data:image/jpeg;base64,{base64_image}",
        "detail": "low"
      }
    },
    {
      "type": "text",
      "text": "What text is present in the image?"
    }
  ]
}
```

***

### Python コード: 画像を Base64 にエンコードする

```python theme={"system"}
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")
```

***

## 複数画像入力

API は、テキスト入力と併せて複数の画像を送信することをサポートしています。最良の結果を得るため、1 リクエストあたり 2 枚以下の画像を送信することを推奨します。

```json theme={"system"}
{
  "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": "Compare the common features of these two images."
    }
  ]
}
```

***

## サポートされているモデル

Novita プラットフォームでは、現在以下のビジョン言語モデルがサポートされています。

<VisionModels />

利用可能なモデルの完全かつ最新の一覧については、[Model Hub](https://novita.ai/models-console/library) を参照してください。

***

## 請求

画像入力はトークン化され、テキストと合わせて請求対象としてカウントされます。

* 各モデルは異なる画像からトークンへの変換方法を使用します。
* 詳細な請求およびトークンポリシーについては、各モデルの料金ページを参照してください。

***

## API 呼び出し例

### 単一画像の説明

```python theme={"system"}
from openai import OpenAI

client = OpenAI(api_key="YOUR_KEY", base_url="https://api.novita.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": "Describe the main buildings in the image."
                }
            ]
        }
    ],
    stream=True
)

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

### 複数画像の比較

```python theme={"system"}
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": "Please compare the key differences between these two products."
                }
            ]
        }
    ],
    stream=True
)

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

***

## 注意事項とトラブルシューティング

* 画像の解像度と鮮明さは、モデルの性能に大きく影響します。可能な場合は高品質なソースを使用してください。
* Base64 エンコードされた画像は、タイムアウトやエラーを避けるため、理想的には 1MB 未満にしてください。
* 詳細な使用方法については、必要に応じて[営業チームとの通話を予約](https://meet.brevo.com/novita-ai/contact-sales)するか、サポートにお問い合わせください。
