Visual Understanding
The LongCat-2.5-Preview model accepts images and videos alongside text. You can ask the model to describe an image, read text from a screenshot, analyze a chart, or understand video content.
Passing Images
There are two ways to provide images. Both use the standard OpenAI-compatible chat completions format, where content is an array of blocks rather than a plain string.
Method 1: Base64-Encoded Image (Inline)
Encode the image and embed it directly in the request as a data: URL — the simplest option for local files. Base64 data counts toward the request body size limit (see Limits).
import base64
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.longcat.chat/openai"
)
with open("image.jpg", "rb") as f:
b64 = base64.b64encode(f.read()).decode("utf-8")
response = client.chat.completions.create(
model="LongCat-2.5-Preview",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{
"type": "image_url",
"image_url": {"url": f"data:image/jpeg;base64,{b64}"},
},
],
}
],
)
print(response.choices[0].message.content)curl https://api.longcat.chat/openai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "LongCat-2.5-Preview",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,<BASE64_DATA>"}}
]
}
]
}'Method 2: External Image URL
Pass a publicly accessible http(s) link, and the model downloads the image automatically.
response = client.chat.completions.create(
model="LongCat-2.5-Preview",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "Describe this image."},
{
"type": "image_url",
"image_url": {"url": "https://example.com/image.jpg"},
},
],
}
],
)
print(response.choices[0].message.content)Passing Videos
Videos can only be passed via URL. The model downloads and parses the video content automatically. Videos are carried in video_url blocks within the same content block array:
response = client.chat.completions.create(
model="LongCat-2.5-Preview",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What happens in this video?"},
{
"type": "video_url",
"video_url": {"url": "https://example.com/video.mp4"},
},
],
}
],
)
print(response.choices[0].message.content)Token Usage
Images and videos are converted to tokens based on their dimensions and billed together with text tokens.
Estimation formula: N_image = total image pixels ÷ 784 (each visual token covers 28 × 28 pixels). For actual PromptTokens accounting, add the two special tokens <img_start> and <img_end>, so the PromptTokens increase per image ≈ N_image + 2.
You can also use the calculator below to estimate the token cost of a single image:
Image Token Calculator
Formula: N = (W × H) ÷ 784
Estimate only. Actual token count is subject to the usage field in the API response.
Limits
Image Limits
| Item | Value |
|---|---|
| Supported formats | PNG, JPG, JPEG, WebP, GIF (SVG, HEIC/HEIF not supported) |
| Input methods | Base64 encoding, URL |
| Original aspect ratio | Over 200:1 returns an error |
| Max size per image | 10 MB |
| Max images per request | 50 (tentative) |
Video Limits (tentative)
| Item | Value |
|---|---|
| Supported formats | MP4, MOV, MKV, AVI, WebM |
| Input method | URL only |
| Max size per video | 50 MB |
| Max duration | 1 hour |
API Information
OpenAI-Compatible API
Image and video understanding uses the standard OpenAI-compatible chat completions endpoint:
- Request path:
POST https://api.longcat.chat/openai/v1/chat/completions - Model name:
LongCat-2.5-Preview - Image content block:
{"type": "image_url", "image_url": {"url": "..."}}— url accepts a public URL or adata:URL (Base64) - Video content block:
{"type": "video_url", "video_url": {"url": "..."}}— url accepts public URLs only
Anthropic-Compatible API
Besides the OpenAI-compatible endpoint, images can also be passed via the Anthropic-compatible /messages endpoint (base_url: https://api.longcat.chat/anthropic). The difference lies in the image content block structure: Anthropic uses an image block whose source object has a type of either base64 or url:
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.longcat.chat/anthropic"
)
message = client.messages.create(
model="LongCat-2.5-Preview",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "<BASE64_DATA>",
},
},
],
}
],
)
print(message.content)