Moonshot API 的 base url 是 直连聊天接口时使用 /chat/completions。 不要凭产品名猜 model,也不要把 OpenRouter、AIMLAPI 的 ID 直接搬到 Moonshot;先调用 GET /models,使用返回的 id。

Create a landscape editorial hero image for this Studio Global article: Cách dùng Kimi K2.6 qua API Moonshot: endpoint đúng và model ID. Article summary: Dùng Kimi K2.6 qua API Moonshot bằng OpenAI SDK với base url https://api.moonshot.ai/v1, rồi gọi /chat/completions; điểm cần kiểm chứng là model ID, nên gọi /models trong tài khoản thay vì đoán.. Topic tags: ai, kimi, moonshot ai, llm, api. Reference image context from search candidates: Reference image 1: visual subject "# Moonshot AI (Kimi K2.6). ## Step 1: Create a Moonshot API account. Go to and create a new Moonshot API account. ## Step 2: Set up Moonshot API account. To use the model via API," source context "Moonshot AI (Kimi K2.6)" Reference image 2: visual subject "Connect and use Kimi K2.6 from Moonshot AI with API Key - Featured image. # How to use Kimi K2.6 from Moonshot AI with API Key on TypingMind. Learn how to access and
接入 Kimi K2.6 时,最容易出错的往往不是端点地址,而是 model 填错。Kimi 开放平台文档说明,它提供与 OpenAI 格式兼容的 HTTP API,可以直接使用 OpenAI SDK;用 SDK 时把 base_url 设为 https://api.moonshot.ai/v1,如果直接发 HTTP 请求,Chat Completions 的完整路径是 https://api.moonshot.ai/v1/chat/completions。
真正需要先核对的是模型 ID。List Models 页面提示 Kimi K2.6 已发布,但文档示例里的返回 id 仍以 kimi-k2.5 演示。因此,不要凭产品名猜 model,也不要直接复制第三方网关的写法;先在自己的 Moonshot 账号下调用 GET /modelsid。
Authorization: Bearer ...base_url 改成 https://api.moonshot.ai/v1。/models。 List Models endpoint 用来列出当前可用模型,并在响应中提供 id;将这个值填入后续请求的 model 字段。model 和 messages 组织,HTTP 直连则发到 /chat/completions。/users/me/balance 检查,batch 任务可通过 /batches 创建。下面示例固定的是 Kimi 文档给出的 base_url;KIMI_MODEL_ID 应来自 GET /modelsid,不要手写猜测,也不要从别的网关复制。
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ['MOONSHOT_API_KEY'],
base_url='https://api.moonshot.ai/v1',
)
response = client.chat.completions.create(
model=os.environ['KIMI_MODEL_ID'],
messages=[
{'role': 'user', 'content': '你好,请用一句话介绍一下自己。'}
],
)
print(response)第一步建议先列出你自己账号可用的模型,因为 /models 的响应会给出可直接使用的 id。
curl -sS https://api.moonshot.ai/v1/models \
-H "Authorization: Bearer $MOONSHOT_API_KEY"选定响应里的 id 后,再调用 Chat Completions。Kimi 文档确认了 /chat/completions 的完整路径,以及 model、messages 这种请求结构。
curl -sS https://api.moonshot.ai/v1/chat/completions \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "PASTE_MODEL_ID_FROM_MODELS",
"messages": [
{"role": "user", "content": "请用一句话介绍 Kimi K2.6。"}
]
}'如果请求失败像是 billing 问题,或你想在接入前确认账户状态,可以调用 Kimi 的余额接口 /users/me/balance;文档示例同样使用 Bearer token。
curl -sS https://api.moonshot.ai/v1/users/me/balance \
-H "Authorization: Bearer $MOONSHOT_API_KEY"有些中间服务会为 Kimi K2.6 使用自己的模型 ID 和入口。AIMLAPI 的示例 endpoint 是 https://api.aimlapi.com/v1/chat/completions,model 写作 moonshot/kimi-k2-6。 OpenRouter 的 Kimi K2.6 API 页面显示的模型名是
moonshotai/kimi-k2.6。
这些写法只应在调用对应平台时使用。回到 Moonshot 的 https://api.moonshot.ai/v1/chat/completions,更稳妥的做法始终是先请求 GET https://api.moonshot.ai/v1/modelsid 填入 model。
最稳的接入顺序是:拿到 API key,设置 OpenAI SDK 的 base_url 为 https://api.moonshot.ai/v1,调用 /models 核准 Kimi K2.6 的模型 ID,然后向 /chat/completions 发送带 model 和 messages 的请求。这样既符合 Kimi 的 OpenAI-compatible 文档,也能避开把 AIMLAPI 或 OpenRouter 的 model ID 误填到 Moonshot 端点里的常见错误。
Studio Global AI
Use this topic as a starting point for a fresh source-backed answer, then compare citations before you share it.
Moonshot API 的 base url 是 https://api.moonshot.ai/v1;HTTP 直连聊天接口时使用 /chat/completions。
Moonshot API 的 base url 是 https://api.moonshot.ai/v1;HTTP 直连聊天接口时使用 /chat/completions。 不要凭产品名猜 model,也不要把 OpenRouter、AIMLAPI 的 ID 直接搬到 Moonshot;先调用 GET /models,使用返回的 id。
常用端点包括 /models、/chat/completions、/users/me/balance 和 /batches,可分别用于列模型、聊天、查余额和创建 batch。