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

# OpenAI マルチモーダル チャットの例

> OpenAI Responses API のテキストと画像の混合例。

## 推奨エンドポイント

* [OpenAI /v1/responses](/ja/api-reference/endpoints/openai/responses)

## 最低限のお願い

```json theme={null}
{
  "model": "gpt-4.1",
  "input": [
    {
      "role": "user",
      "content": [
        { "type": "input_text", "text": "Describe the UI structure in this screenshot." },
        { "type": "input_image", "image_url": "https://example.com/ui.png" }
      ]
    }
  ]
}
```

## cURLの例

```bash theme={null}
curl https://maas.apigo.ai/v1/responses \
  -H "Authorization: Bearer $YOUR API KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4.1",
    "input": [
      {
        "role": "user",
        "content": [
          { "type": "input_text", "text": "Describe the UI structure in this screenshot." },
          { "type": "input_image", "image_url": "https://example.com/ui.png" }
        ]
      }
    ]
  }'
```

## Python の例

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

client = OpenAI(
    base_url="https://maas.apigo.ai/v1",
    api_key="<YOUR API KEY>",
)

response = client.responses.create(
    model="gpt-4.1",
    input=[
        {
            "role": "user",
            "content": [
                {"type": "input_text", "text": "Describe the UI structure in this screenshot."},
                {"type": "input_image", "image_url": "https://example.com/ui.png"},
            ],
        }
    ],
)

print(response.output_text)
```

## Node.js の例

```js theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://maas.apigo.ai/v1",
  apiKey: process.env.YOUR API KEY,
});

const response = await client.responses.create({
  model: "gpt-4.1",
  input: [
    {
      role: "user",
      content: [
        { type: "input_text", text: "Describe the UI structure in this screenshot." },
        { type: "input_image", image_url: "https://example.com/ui.png" }
      ]
    }
  ]
});

console.log(response.output_text);
```

## ベストプラクティス

* 再利用可能なアセットのファイル ID を優先する
* サーバー側で複数の画像の順序を正規化する
* OCR が多いリクエストまたは詳細が多いリクエストについては、イメージ トークンのコストを個別に評価します。
