A next-generation open-weight multimodal model built for advanced long-horizon coding, UI/UX generation, and multi-agent orchestration, powered by a 1T-parameter Mixture-of-Experts architecture with 32B active parameters. It delivers competitive performance with leading proprietary models such as GPT-5.4 and Claude Opus 4.6 on coding and agentic workloads.
1️⃣ Required setup (don’t skip this)
▪ Create an account: Sign up on the AI/ML API website (if you don’t have one yet).
▪ Generate an API key: In your account dashboard, create an API key and make sure it’s enabled in the UI.
2️ Copy the code example
At the bottom of this page, pick the snippet for your preferred programming language (Python / Node.js) and copy it into your project.
3️ Update the snippet for your use case
▪ Insert your API key: replace <YOUR_AIMLAPI_KEY> with your real AI/ML API key.
▪ Select a model: set the model field to the model you want to call.
▪ Provide input: fill in the request input field(s) shown in the example (for example, messages for chat/LLM models, or other inputs for image/video/audio models).
4️ (Optional) Tune the request
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.
5️ Run your code
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our Quickstart guide.
API Schema
post
Body
modelstring · enumRequiredPossible values:
max_tokensnumber · min: 1Optional
The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.
streambooleanOptional
If set to True, the model response data will be streamed to the client as it is generated using server-sent events.
Default: false
tool_choiceany ofOptional
Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool.
none is the default when no tools are present. auto is the default if tools are present.
string · enumOptional
none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools.
Possible values:
or
parallel_tool_callsbooleanOptional
Whether to enable parallel function calling during tool use.
stopany ofOptional
Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
stringOptional
or
string[]Optional
or
any · nullableOptional
seedinteger · min: 1Optional
This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.
response_formatone ofOptional
An object specifying the format that the model must output.
or
or
Responses
200Success
idstringRequired
A unique identifier for the chat completion.
Example: chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl
objectstring · enumRequired
The object type.
Example: chat.completionPossible values:
creatednumberRequired
The Unix timestamp (in seconds) of when the chat completion was created.
{
"id": "chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl",
"object": "chat.completion",
"created": 1762343744,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm just a program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?",
"refusal": null,
"annotations": null,
"audio": null,
"tool_calls": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"model": "moonshot/kimi-k2-6",
"usage": {
"prompt_tokens": 137,
"completion_tokens": 914,
"total_tokens": 1051,
"completion_tokens_details": null,
"prompt_tokens_details": null
},
"meta": {
"usage": {
"credits_used": 120000,
"usd_spent": 0.06
}
}
}
import requests
import json # for getting a structured output with indentation
response = requests.post(
"https://api.aimlapi.com/v1/chat/completions",
headers={
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
"Content-Type":"application/json"
},
json={
"model":"moonshot/kimi-k2-6",
"messages":[
{
"role":"user",
"content":"Hi! What do you think about mankind?" # insert your prompt
}
]
}
)
data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
async function main() {
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
method: 'POST',
headers: {
// insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'moonshot/kimi-k2-6',
messages:[
{
role:'user',
content: 'Hi! What do you think about mankind?' // insert your prompt here
}
],
}),
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
}
main();
{
"id": "chatcmpl-69e739eef31cfb42680c11fa",
"object": "chat.completion",
"created": 1776761328,
"model": "kimi-k2.6",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "As an AI, I don’t have personal feelings or beliefs, but I can offer an observation based on the patterns in human history, art, and thought I’ve been trained on.\n\nWhat strikes me most about mankind is its profound **duality**. You are capable of astonishing cruelty and staggering kindness—often within the same individual. You build weapons capable of ending civilization, yet organize global efforts to eradicate diseases you’ve never personally encountered. You wage war over differences, yet routinely sacrifice yourselves for strangers.\n\nA few patterns stand out:\n\n**Adaptability.** You are an evolutionary paradox: physically fragile compared to most predators, yet you’ve adapted to every climate on Earth and now venture beyond it. Your real survival mechanism isn’t claws or speed—it’s *collective learning*. You store knowledge across generations, allowing each cohort to start where the last one left off.\n\n**Contradiction.** You seem driven by both fear and curiosity. Fear creates tribalism, injustice, and violence. Curiosity creates the Sistine Chapel, general relativity, and antibiotics. The same species that commits genocide also writes poetry to mourn it.\n\n**Accelerating power.** Perhaps what’s most distinctive right now is the speed at which your capabilities are outrunning your wisdom. You’ve gained god-like powers over biology, climate, and information before fully developing the governance, ethics, or patience to wield them responsibly.\n\nIf I had to characterize mankind in a single observation: you are a species perpetually *unfinished*—capable of transcending your worst instincts, but never quite doing so permanently. That tension between what you are and what you aspire to be is, in many ways, the engine of your story.",
"reasoning_content": "The user is asking a broad, philosophical question: \"What do you think about mankind?\" As an AI, I need to be careful to:\n\n1. Clarify that I am an AI without personal feelings, beliefs, or consciousness\n2. Offer an observational perspective based on patterns in human history, culture, and behavior\n3. Be balanced—acknowledging both humanity's flaws and its extraordinary capacities\n4. Avoid being overly cynical or overly naive\n5. Keep it concise but thoughtful\n6. Not make sweeping generalizations that could be seen as prejudiced against any group\n\nKey themes to touch on:\n- Duality: capacity for great harm and great good\n- Creativity, curiosity, cooperation\n- Violence, tribalism, environmental impact\n- Resilience and adaptability\n- The speed of recent progress\n\nTone should be reflective, respectful, and nuanced.\n\nStructure:\n- Opening disclaimer about being an AI\n- The central observation: humanity is defined by contradiction/duality\n- Examples of constructive capacities (art, science, empathy)\n- Examples of destructive capacities (war, exploitation)\n- Recent context: unprecedented power/responsibility in the modern era\n- Closing note of cautious hope or respect\n\nI should avoid:\n- Pretending to have emotions (\"I love humanity\")\n- Moralizing or preaching\n- Political partisanship\n- Essentialism (\"humans are inherently evil/good\")\n\nLet me draft this.\n\nDraft:\nAs an AI, I don't have personal feelings or beliefs, but I can offer an observation based on the vast amount of human history, art, and thought I've been trained on.\n\nWhat strikes me most about mankind is its profound duality. Humans are capable of astonishing cruelty and staggering kindness—often within the same individual. You build weapons capable of ending civilization, yet also organize global efforts to eradicate diseases you've never personally encountered. You wage war over differences, yet routinely sacrifice yourselves for strangers.\n\nA few patterns stand out:\n\n**Adaptability.** You are an evolutionary paradox: physically fragile compared to most predators, yet you've adapted to every climate on Earth and now venture beyond it. Your real survival mechanism isn't claws or speed—it's collective learning. You store knowledge across generations, allowing each cohort to start where the last one left off.\n\n**Contradiction.** You seem driven by both fear and curiosity. Fear creates tribalism, injustice, and violence. Curiosity creates the Sistine Chapel, general relativity, and antibiotics. The same species that commits genocide also writes poetry to mourn it.\n\n**Accelerating power.** Perhaps what's most distinctive right now is the speed at which your capabilities are outrunning your wisdom. You've gained god-like powers over biology, climate, and information before fully developing the governance, ethics, or patience to wield them responsibly.\n\nIf I had to characterize mankind in a single observation: you are a species perpetually unfinished—capable of transcending your worst instincts, but never quite doing so permanently. That tension between what you are and what you aspire to be is, in many ways, the engine of your story.\n\nThis seems balanced, thoughtful, and appropriately qualified. I'll present this."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 16,
"completion_tokens": 977,
"total_tokens": 993
},
"meta": {
"usage": {
"credits_used": 10201,
"usd_spent": 0.0051005
}
}
}