# Kimi 2.7 API Complete API reference for Kimi 2.7 LLM models powered by Moonshot AI. ## Model Variants This API supports two model variants: | Model | ID | Description | |-------|----|-------------| | **Kimi 2.7 Text to Text** | `kimi-2.7-text-to-text` | General text reasoning and writing | | **Kimi 2.7 Image to Text** | `kimi-2.7-image-to-text` | Image understanding with text instructions | ## Quick Comparison | Feature | Text to Text | Image to Text | |---------|--------------|---------------| | Text input | Required ✅ | Optional | | Image input | Not supported ❌ | Optional | | Streaming response | SSE | SSE | | `max_tokens` | Optional | Optional | | `top_p` | Optional | Optional | | `top_k` | Optional | Optional | ## Kimi 2.7 Text to Text ### Endpoint ```http POST /api/v1/chat/completions ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model` | string | Must be `"kimi-2.7-text-to-text"` | | `messages` | array | Ordered messages. See LLM API for the message structure. | | `stream` | boolean | `true` for SSE, `false` for a single JSON response. | #### Message Support | Field | Text | File | Image | |-------|------|------|-------| | `messages` | Required ✅ | Not supported ❌ | Not supported ❌ | #### Optional | Parameter | Type | Range | Description | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 0` | Maximum output tokens. | | `top_p` | number | `0.0` - `1.0` | Limits cumulative probability mass for candidate tokens. | | `top_k` | integer | `0` - `100` | Limits the number of candidate tokens. | ### Example Request ```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 ### Endpoint ```http POST /api/v1/chat/completions ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model` | string | Must be `"kimi-2.7-image-to-text"` | | `messages` | array | Ordered messages. See LLM API and Message Attachments. | | `stream` | boolean | `true` for SSE, `false` for a single JSON response. | #### Message Support | Field | Text | File | Image | |-------|------|------|-------| | `messages` | Optional | Not supported ❌ | Optional | #### Optional | Parameter | Type | Range | Description | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 0` | Maximum output tokens. | | `top_p` | number | `0.0` - `1.0` | Limits cumulative probability mass for candidate tokens. | | `top_k` | integer | `0` - `100` | Limits the number of candidate tokens. | ### Example Request ```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 }) }); ``` ## Response Format Kimi 2.7 LLM models return OpenAI-compatible completion responses. With `stream: true`, the response is Server-Sent Events; with `stream: false`, the response is a single JSON object. ## Best Practices - Use concise system instructions for task-specific behavior. - For image understanding, pair a clear question with image attachment content in `messages[].content`. - Tune `top_p` and `top_k` only when you need stricter or more varied output.