多模态理解 (Vision)
Kimi K2.5 Vision 多模态模型,支持图片理解、文档解析和图文对话。
API 端点
POST
/chat/completions多模态对话
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 必填 | 模型名称:kimi-k2.5 |
messages | array | 必填 | 消息列表,content 可包含 text 和 image_url |
temperature | number | 可选 | 采样温度,默认 0.3 |
max_tokens | integer | 可选 | 最大生成 tokens 数量 |
请求示例
请求示例
{
"model": "kimi-k2.5",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "这张图片里有什么?"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image.jpg"
}
}
]
}
]
}响应示例
响应示例
{
"id": "chatcmpl-456",
"object": "chat.completion",
"created": 1677652288,
"model": "kimi-k2.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "这张图片显示的是一只可爱的猫咪..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1200,
"completion_tokens": 80,
"total_tokens": 1280
}
}代码示例
from openai import OpenAI
client = OpenAI(
api_key="your-api-key",
base_url="https://kimi-api.com/v1"
)
response = client.chat.completions.create(
model="kimi-k2.5",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "这张图片里有什么?"},
{
"type": "image_url",
"image_url": {"url": "https://example.com/image.jpg"}
}
]
}
]
)
print(response.choices[0].message.content)