# Kimi 2.7 API Moonshot AI 驱动的 Kimi 2.7 LLM 模型完整 API 参考。 ## 模型变体 此 API 支持两种模型变体: | 模型 | ID | 描述 | |-------|----|-------------| | **Kimi 2.7 Text to Text** | `kimi-2.7-text-to-text` | 通用文本推理和写作 | | **Kimi 2.7 Image to Text** | `kimi-2.7-image-to-text` | 结合文本指令进行图像理解 | ## 快速对比 | 功能 | Text to Text | Image to Text | |---------|--------------|---------------| | 文本输入 | 必需 ✅ | 可选 | | 图像输入 | 不支持 ❌ | 可选 | | 流式响应 | SSE | SSE | | `max_tokens` | 可选 | 可选 | | `top_p` | 可选 | 可选 | | `top_k` | 可选 | 可选 | ## Kimi 2.7 Text to Text ### 接口端点 ```http POST /api/v1/chat/completions ``` ### 请求参数 #### 必需 | 参数 | 类型 | 描述 | |-----------|------|-------------| | `model` | string | 必须为 `"kimi-2.7-text-to-text"` | | `messages` | array | 按顺序排列的消息。消息结构请参阅 LLM API。 | | `stream` | boolean | `true` 表示 SSE,`false` 表示单个 JSON 响应。 | #### 消息支持 | 字段 | 文本 | 文件 | 图像 | |-------|------|------|-------| | `messages` | 必需 ✅ | 不支持 ❌ | 不支持 ❌ | #### 可选 | 参数 | 类型 | 范围 | 描述 | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 0` | 最大输出 token 数。 | | `top_p` | number | `0.0` - `1.0` | 限制候选 token 的累积概率质量。 | | `top_k` | integer | `0` - `100` | 限制候选 token 数量。 | ### 请求示例 ```javascript const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Accept': 'text/event-stream', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'kimi-2.7-text-to-text', messages: [ { role: 'user', content: 'Write a concise Java beginner tutorial outline.' } ], stream: true, max_tokens: 2000, top_p: 0.9, top_k: 50 }) }); ``` ## Kimi 2.7 Image to Text ### 接口端点 ```http POST /api/v1/chat/completions ``` ### 请求参数 #### 必需 | 参数 | 类型 | 描述 | |-----------|------|-------------| | `model` | string | 必须为 `"kimi-2.7-image-to-text"` | | `messages` | array | 按顺序排列的消息。请参阅 LLM API 和 Message Attachments。 | | `stream` | boolean | `true` 表示 SSE,`false` 表示单个 JSON 响应。 | #### 消息支持 | 字段 | 文本 | 文件 | 图像 | |-------|------|------|-------| | `messages` | 可选 | 不支持 ❌ | 可选 | #### 可选 | 参数 | 类型 | 范围 | 描述 | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 0` | 最大输出 token 数。 | | `top_p` | number | `0.0` - `1.0` | 限制候选 token 的累积概率质量。 | | `top_k` | integer | `0` - `100` | 限制候选 token 数量。 | ### 请求示例 ```javascript const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Accept': 'text/event-stream', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'kimi-2.7-image-to-text', messages: [ { role: 'user', content: [ { type: 'text', text: 'What is roughly shown in this image?' }, { type: 'image_url', image_url: { url: 'https://example.com/sample-image.jpg' } } ] } ], stream: true, max_tokens: 300 }) }); ``` ## 响应格式 Kimi 2.7 LLM 模型返回与 OpenAI 兼容的补全响应。使用 `stream: true` 时,响应为服务器发送事件(SSE);使用 `stream: false` 时,响应为单个 JSON 对象。 ## 最佳实践 - 使用简洁的系统指令来定义特定任务行为。 - 对于图像理解,请在 `messages[].content` 中将清晰问题与图像附件内容搭配使用。 - 仅在需要更严格或更多样的输出时调整 `top_p` 和 `top_k`。