Documentation

Image Understanding

Quick Start

For preparations such as obtaining an API Key, please refer to First API Call.

Quickly experience the effect of image understanding by passing the model through the image URL method. The sample code is as follows.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("MIMO_API_KEY"),
    base_url="https://api.xiaomimimo.com/v1"
)

completion = client.chat.completions.create(
    model="mimo-v2.6-pro",
    messages=[
        {
            "role": "system",
            "content": "You are MiMo, an AI assistant developed by Xiaomi. Today is date: Tuesday, December 16, 2025. Your knowledge cutoff date is December 2024."
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://example-files.cnbj1.mi-fds.com/example-files/image/image_example.png"
                    }
                },
                {
                    "type": "text",
                    "text": "please describe the content of the image"
                }
            ]
        }
    ],
    max_completion_tokens=1024
)

print(completion.model_dump_json())

Response

{
    "id": "75a0045f-a28f-4b0f-8ddd-6c90c6ef6587_90e3b2e2dd1f410c8b5526a21526bdec",
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "This is a serene, enchanted-looking ancient forest scene, rich with detail:\n1.  **Foreground:** At the bottom left, lush, large green ferns with delicate fronds grow on a bed of moss-covered smooth river stones. A shallow, clear stream flows gently over the stones, its surface glinting brightly as it catches golden sunlight. Mossy rocks and small, leafy green shrubs line the right bank, their leaves glowing in the warm light.\n2.  **Midground:** The stream winds deeper into the woods, surrounded by thick, vibrant moss and lush low greenery. Dominating the left is a massive, gnarled ancient tree with thick, exposed roots gripping the earth, its dark, twisted trunk curving outward. Other tall, mature trees with textured dark bark fill the space, creating a dense, old-growth forest feel.\n3.  **Light & Atmosphere:** Warm, golden sunbeams (crepuscular rays) filter down through the forest canopy, cutting through a soft mist that hangs in the air. Tiny glowing particles, like sun dust or fireflies, drift in the sunlit space, adding a magical, dreamlike quality. The distant forest fades into soft haze, giving the scene deep, peaceful atmosphere.\n4.  **Overall feel:** The image evokes a sense of quiet, untouched wilderness, peaceful and full of life, with the gentle flow of the stream and warm, dappled light creating an intimate, enchanted natural space.",
                "role": "assistant",
                "tool_calls": null,
                "reasoning_content": "Got it, let's break down this beautiful forest scene step by step.\n\nFirst, the overall mood: it's a misty, sun-dappled ancient forest, with a sense of quiet, magic (the little light specks feel like fireflies or sun particles), peaceful and lush.\n\nForeground: At the bottom left, large, vibrant green ferns with feathery fronds sit on moss-covered, smooth rounded stones. The stream here is shallow, with clear water flowing over the stones, catching the golden sunlight. Mossy rocks line the right side, with small leafy green bushes growing on them, their leaves catching the warm light.\n\nMidground: A gentle stream winds its way deeper into the forest, its surface glinting with the sunbeams. The banks are thick with moss, ferns, and low greenery, all lush and healthy. Large, ancient trees dominate here: on the left, a massive tree with thick, gnarled, exposed roots gripping the ground, its dark trunk curving outward. Other tall trees with dark, textured bark fill the space, their trunks disappearing into the mist.\n\nBackground & lighting: The scene is backlit by warm, golden sunbeams (crepuscular rays) that filter through the tree canopy, cutting through the mist that hangs in the air, creating a soft, hazy glow. The light catches tiny particles in the air, making them look like glowing embers or fireflies, adding a magical touch. The distant forest fades into soft mist, giving the scene depth.\n\nAll elements come together to feel like a serene, untouched, enchanted forest space, full of life and soft, warm light, with the sound of the gentle stream almost imaginable."
            }
        }
    ],
    "created": 1790007893,
    "model": "mimo-v2.6-pro",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 656,
        "prompt_tokens": 1085,
        "total_tokens": 1741,
        "completion_tokens_details": {
            "reasoning_tokens": 351
        },
        "prompt_tokens_details": {
            "cached_tokens": 1024,
            "image_tokens": 1024
        }
    }
}

Supported models

Currently, the mimo-v2.6-flash, mimo-v2.6-pro, mimo-v2.6-pro-ultraspeed models are supported.

Image Input Method

Supported ways to upload images are as follows:

  • Image URL Input: A publicly accessible image URL address must be provided.

  • Base64 Encoding Input: Convert the image to a Base64-encoded string before passing it in.

Image URL Input

Directly pass in the image via the publicly accessible image URL, which is suitable for scenarios where the image is already stored in a publicly accessible environment. The file size of a single image cannot exceed 50 MB.

OpenAI Chat Completions API

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("MIMO_API_KEY"),
    base_url="https://api.xiaomimimo.com/v1"
)

completion = client.chat.completions.create(
    model="mimo-v2.6-pro",
    messages=[
        {
            "role": "system",
            "content": "You are MiMo, an AI assistant developed by Xiaomi. Today is date: Tuesday, December 16, 2025. Your knowledge cutoff date is December 2024."
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://example-files.cnbj1.mi-fds.com/example-files/image/image_example.png"
                    }
                },
                {
                    "type": "text",
                    "text": "please describe the content of the image"
                }
            ]
        }
    ],
    max_completion_tokens=1024
)

print(completion.model_dump_json())

Anthropic Messages API

import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("MIMO_API_KEY"),
    base_url="https://api.xiaomimimo.com/anthropic"
)

message = client.messages.create(
    model="mimo-v2.6-pro",
    max_tokens=1024,
    system="You are MiMo, an AI assistant developed by Xiaomi. Today is date: Tuesday, December 16, 2025. Your knowledge cutoff date is December 2024.",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image",
                    "source": {
                        "type": "url",
                        "url": "https://example-files.cnbj1.mi-fds.com/example-files/image/image_example.png"
                    }
                },
                {
                    "type": "text",
                    "text": "please describe the content of the image"
                }
            ]
        }
    ]
)

print(message.content)

Base64 Encoded Input

Convert the image file to a Base64-encoded string and then pass it in, which is suitable for scenarios where the image cannot be accessed via a public network URL. The size of the converted Base64-encoded string cannot exceed 50 MB.

In the following example, both {MIME_TYPE} and $BASE64_IMAGE are placeholders, please replace them with actual valid data before running.

OpenAI Chat Completions API

Please include the prefix before Base64 encoding: data:{MIME_TYPE};base64,$BASE64_IMAGE

  • {MIME_TYPE}: The MIME type (media type) of the image, used to identify the image format, needs to be replaced with the MIME value corresponding to the actual image.

  • $BASE64_IMAGE: A pure Base64-encoded string of the image file (without any prefix).

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("MIMO_API_KEY"),
    base_url="https://api.xiaomimimo.com/v1"
)

completion = client.chat.completions.create(
    model="mimo-v2.6-pro",
    messages=[
        {
            "role": "system",
            "content": "You are MiMo, an AI assistant developed by Xiaomi. Today is date: Tuesday, December 16, 2025. Your knowledge cutoff date is December 2024."
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "data:{MIME_TYPE};base64,$BASE64_IMAGE"
                    }
                },
                {
                    "type": "text",
                    "text": "please describe the content of the image"
                }
            ]
        }
    ],
    max_completion_tokens=1024
)

print(completion.model_dump_json())

Anthropic Messages API

import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("MIMO_API_KEY"),
    base_url="https://api.xiaomimimo.com/anthropic"
)

message = client.messages.create(
    model="mimo-v2.6-pro",
    max_tokens=1024,
    system="You are MiMo, an AI assistant developed by Xiaomi. Today is date: Tuesday, December 16, 2025. Your knowledge cutoff date is December 2024.",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image",
                    "source": {
                        "type": "base64",
                        "media_type": "{MIME_TYPE}",
                        "data": "$BASE64_IMAGE"
                    }
                },
                {
                    "type": "text",
                    "text": "please describe the content of the image"
                }
            ]
        }
    ]
)

print(message.content)

Multi-image Input

Supports simultaneously passing in public network URLs or Base64-encoded strings of multiple images, and the model can parse the image content and return responses that match the image semantics.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("MIMO_API_KEY"),
    base_url="https://api.xiaomimimo.com/v1"
)

completion = client.chat.completions.create(
    model="mimo-v2.6-pro",
    messages=[
        {
            "role": "system",
            "content": "You are MiMo, an AI assistant developed by Xiaomi. Today is date: Tuesday, December 16, 2025. Your knowledge cutoff date is December 2024."
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://example-files.cnbj1.mi-fds.com/example-files/image/image_example.png"
                    }
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "data:{MIME_TYPE};base64,$BASE64_IMAGE"
                    }
                },
                {
                    "type": "text",
                    "text": "please describe the connections and differences between these two pictures"
                }
            ]
        }
    ],
    max_completion_tokens=1024
)

print(completion.model_dump_json())

Image Restrictions

  • Image Formats: JPEG, PNG, GIF, WebP, BMP.

  • Image Size:

    • When passed in as a URL: single image file size does not exceed 50 MB.

    • When passed in as Base64 encoding: The size of the Base64 encoded string of a single image does not exceed 50 MB.

  • Number of images: When multiple images are passed in, the number of images is limited by the model's context length, and the total number of Tokens for all images and text must be less than the model's context length.

Note: For calculating image tokens, please refer to Explanation of Image Token Usage. For the model context length, please refer to Pricing and Rate Limits.

Explanation of Image Token Usage and Scaling Rules

The calculation rules for images are relatively complex. For Token conversion and scaling rules, please refer to the following code. The estimated results are for reference only, and the actual usage shall be subject to the API response.

import math
from PIL import Image

PATCH_SIZE = 16
SPATIAL_MERGE_SIZE = 2
TEMPORAL_PATCH_SIZE = 2
IMAGE_MIN_PIXELS = 8192
IMAGE_MAX_PIXELS = 8388608

def calc_image_tokens(image_path: str) -> dict:
    image = Image.open(image_path)
    height = image.height
    width = image.width

    factor = PATCH_SIZE * SPATIAL_MERGE_SIZE  # 32

    h_bar = round(height / factor) * factor
    w_bar = round(width / factor) * factor

    if h_bar * w_bar > IMAGE_MAX_PIXELS:
        beta = math.sqrt((height * width) / IMAGE_MAX_PIXELS)
        h_bar = math.floor(height / beta / factor) * factor
        w_bar = math.floor(width / beta / factor) * factor
    elif h_bar * w_bar < IMAGE_MIN_PIXELS:
        beta = math.sqrt(IMAGE_MIN_PIXELS / (height * width))
        h_bar = math.ceil(height / beta / factor) * factor
        w_bar = math.ceil(width / beta / factor) * factor

    grid_t = 1
    grid_h = h_bar // PATCH_SIZE
    grid_w = w_bar // PATCH_SIZE
    num_tokens = (grid_t * grid_h * grid_w) // (SPATIAL_MERGE_SIZE ** 2)
    return num_tokens

if __name__ == "__main__":
   token = calc_image_tokens(image_path="xxx/test.jpg")
   print(token)

Price

  • Billing: Total cost is calculated based on the number of input, input (cache hits), and output tokens; for pricing, please refer to Pricing and Rate Limits.

    • The Token consumption of images can be calculated through Explanation of Image Token Usage. The estimated results are for reference only, and the actual usage shall be subject to the API response.
  • View Bill: You can view your bill and usage on the Billing page in the Console.

FAQ

Does it support local file upload?

mimo-v2.6-flash, mimo-v2.6-pro, mimo-v2.6-pro-ultraspeed models don't currently support uploading local image files. For supported upload methods, please refer to Image Input Method.

Update Time October 20, 2026

Copyright©2026 Xiaomi. All Rights Reserved | Cookie Policy | Cookie Preferences

We use cookies and similar technologies of our own to ensure the proper functioning of the website, customize content according to user preferences and analyze users' interactions on the website, as well as their browsing habits. You can find more information in our Cookie Policy. Select an option or go to Cookie Settings to manage your preferences. Learn More.