Authorization: Bearer ...base_url को https://api.moonshot.ai/v1 करना है। /models call करें। List Models endpoint current models की सूची और उनका id लौटाता है; यही value model parameter में जानी चाहिए। model और messages आते हैं, और API overview /chat/completions full path बताता है। /users/me/balance और batch processing के लिए /batches endpoint उपलब्ध हैं। नीचे example में वही base_url है जो Kimi ने OpenAI SDK के लिए बताया है। ध्यान रखें:
KIMI_MODEL_ID में वही id रखें जो आपके account में GET /models
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)सबसे पहले अपने Moonshot/Kimi account में model list देखें, क्योंकि इसी response में model का id मिलता है।
curl -sS 'https://api.moonshot.ai/v1/models' -H "Authorization: Bearer $MOONSHOT_API_KEY"अब response से सही id चुनकर Chat Completions endpoint पर request भेजें। Full path /chat/completions और request का model + messages format Kimi docs में बताया गया है।
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 पर छोटा परिचय लिखें।"}]}'अगर request billing की वजह से fail हो रही है, या integration शुरू करने से पहले account status देखना है, तो Kimi का balance endpoint /users/me/balance इस्तेमाल करें। Documentation में इसे Bearer token के साथ दिखाया गया है।
curl -sS 'https://api.moonshot.ai/v1/users/me/balance' -H "Authorization: Bearer $MOONSHOT_API_KEY"कुछ intermediary providers Kimi K2.6 के लिए अपना अलग model ID देते हैं। AIMLAPI अपने endpoint https://api.aimlapi.com/v1/chat/completions के साथ model moonshot/kimi-k2-6 दिखाता है। OpenRouter अपने API पेज पर
moonshotai/kimi-k2.6 model दिखाता है।
ये ID उन्हीं gateways के लिए हैं। अगर आप official Moonshot endpoint https://api.moonshot.ai/v1/chat/completions call कर रहे हैं, तो सबसे कम risk वाला तरीका है: GET https://api.moonshot.ai/v1/modelsid आपके account के लिए लौटाए, वही इस्तेमाल करें।
Kimi K2.6 को Moonshot API से जोड़ने का साफ रास्ता है: API key लें, OpenAI SDK में base_url को https://api.moonshot.ai/v1 set करें, /models से actual model ID verify करें, और फिर /chat/completions पर model और messages के साथ request भेजें। इससे documentation के OpenAI-compatible flow का पालन होता है और AIMLAPI या OpenRouter जैसे gateways के model ID को official Moonshot endpoint पर गलती से इस्तेमाल करने का जोखिम घटता है।