Kimi 2.7 API
Moonshot AI 驅動的 Kimi 2.7 LLM 模型完整 API 參考。
模型變體
此 API 支援兩種模型變體:
快速比較
Kimi 2.7 Text to Text
端點
POST /api/v1/chat/completions
請求參數
必需
訊息支援
可選
請求範例
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
端點
POST /api/v1/chat/completions
請求參數
必需
訊息支援
可選
請求範例
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。