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

# Vision and Multimodal

Vision and Multimodal models can understand both text and images. They provide capabilities through a unified OpenAI-compatible Chat Completions API and are suitable for vision-language tasks such as image description, visual Q\&A, and text-image workflows.

Representative models include:

* `Qwen/Qwen2.5-VL-72B-Instruct`
* `google/gemma-4-31B-it`

For the full model list and pricing, refer to [Models](https://console.scitix.ai/model-inference/models).

## Core Capabilities

* **Image understanding**: Describe images, extract text (OCR), and answer questions about visual content.
* **Visual Q\&A**: Ask follow-up questions about diagrams, screenshots, or product images.
* **Multimodal conversation**: Mix text and images in a single conversation, such as "compare these two charts."
* **Content moderation**: Classify or flag image content using natural language instructions.

## Image Message Format

When sending images, set `content` in `messages` to an array. Array items can be of type `text` or `image_url`. The `image_url` can be either a publicly accessible image URL or a `data:` URL, which is a base64-encoded image.

Example structure:

```python theme={null}
messages = [
    {
        "role": "user",
        "content": [
            {"type": "text", "text": "What is shown in this image?"},
            {
                "type": "image_url",
                "image_url": {
                    "url": "https://images.unsplash.com/photo-1506748686214-e9df14d4d9d0",
                },
            },
        ],
    }
]
```

## Key Parameters

* **Parameters**

  * `temperature`: Controls output randomness.

  * `max_completion_tokens`: Limits generation length and helps avoid truncated output.

  * `stream=True`: Returns responses as a stream. Recommended for long responses to reduce timeout risk.

* **Context**

  The maximum context length supported by each model can be viewed in [Models](https://console.scitix.ai/model-inference/models).

* **Image limits**

  Supported image formats and size limits vary by model. For details, refer to [Models](https://console.scitix.ai/model-inference/models).

## Billing

* **Formula**: Total cost = (input tokens x input unit price) + (output tokens x output unit price)

* **Pricing**: The input unit price for vision models, measured by token, may differ from text-only models. Check the model detail page in [Models](https://console.scitix.ai/model-inference/models) for specific vision input pricing and whether any per-image caps or minimums apply.

* **Token calculation notes**
  Total input tokens = text tokens + image tokens.

  * Images and other vision inputs are converted into input tokens for billing. The pixel-to-token mapping differs by model: higher resolution and more images usually produce more input tokens.
  * Text in the same request is still counted in the standard way.
  * If there are multiple images, each image is counted separately.

* **Token calculation examples**
  The following representative models illustrate how visual content is converted into tokens:

  | Model                          | Visual tokenization (brief)                                                                                                                                                                                                |
  | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `Qwen/Qwen2.5-VL-72B-Instruct` | The image is divided into patches/tiles, and each tile is encoded as tokens. The total number of image tokens depends on the resolution and the maximum size allowed by the model, such as 1280 x 1280 or a similar value. |
  | `google/gemma-4-31B-it`        | The vision encoder maps the image to a sequence of tokens based on patches. The sequence length depends on the input resolution and model configuration.                                                                   |

## Examples

The examples read the API key from an environment variable to avoid writing secrets into code.

```bash theme={null}
export API_KEY="YOUR_API_KEY"
```

### Image Description

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

client = OpenAI(
    api_key=os.environ["API_KEY"],
    base_url="https://api.scitix.ai/model-api",
)

response = client.chat.completions.create(
    model="Qwen/Qwen2.5-VL-72B-Instruct",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Describe this image in one or two sentences."},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://images.unsplash.com/photo-1506748686214-e9df14d4d9d0",
                    },
                },
            ],
        }
    ],
    max_completion_tokens=256,
)

print(response.choices[0].message.content)
```

### Visual Q\&A with Base64 Images

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


def image_to_data_url(path: str) -> str:
    with open(path, "rb") as f:
        b64 = base64.standard_b64encode(f.read()).decode()
    return f"data:image/jpeg;base64,{b64}"


client = OpenAI(
    api_key=os.environ["API_KEY"],
    base_url="https://api.scitix.ai/model-api",
)

url = image_to_data_url("myphoto.jpeg")

response = client.chat.completions.create(
    model="Qwen/Qwen2.5-VL-72B-Instruct",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "What is the main message or call-to-action on this screen?",
                },
                {"type": "image_url", "image_url": {"url": url}},
            ],
        }
    ],
    max_completion_tokens=512,
)

print(response.choices[0].message.content)
```

### Multiple Images in One Request

To send multiple images in a single request, add more `image_url` entries to the same `content` array. The model receives these images together and can use them for tasks such as comparison and summarization.

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

client = OpenAI(
    api_key=os.environ["API_KEY"],
    base_url="https://api.scitix.ai/model-api",
)

response = client.chat.completions.create(
    model="Qwen/Qwen2.5-VL-72B-Instruct",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Compare these two images in one or two sentences. What do they have in common or how do they differ?",
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://images.unsplash.com/photo-1551963831-b3b1ca40c98e",
                    },
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://images.unsplash.com/photo-1472214103451-9374bd1c798e",
                    },
                },
            ],
        }
    ],
    max_completion_tokens=512,
)

print(response.choices[0].message.content)
```
