Your privacy choices

Allow optional cookies for referral attribution, visit analytics, and Google Ads purchase measurement.

Back to blog

Kimi K3.1 Pro API Integration and Agent Guide

Kimi K3.1 ProMoonshot APIAgentModel integration

Kimi K3.1 Pro is part of Moonshot AI’s K3.1 model family, designed for coding, 3D creation, financial research, and long-running Agent workflows. When called through the official API, its model ID is kimi-k3.1-pro, and the OpenAI SDK Base URL is https://api.moonshot.cn/v1. Thinking mode is always enabled. You can set the reasoning effort to low, high, or max; the default is max.Official quick start

This guide covers integration, reasoning, vision, and tool loops based on the official API documentation. Vendor-published benchmark results are reported by the vendor; they are not tests conducted by Guishu Intelligence.

At a glance

Item Verified information
Official model ID kimi-k3.1-pro
Official API Base URL https://api.moonshot.cn/v1
Reasoning effort low, high, and max; default: max
Thinking mode Always enabled
Context Official documentation says it supports 1 million tokens
High-speed variant kimi-k3.1-pro-highspeed; a separate model. Check the relevant platform catalog for availability and pricing.
Documentation checked 2026-10-24

These capabilities and model details are based on the official Kimi K3.1 Pro documentation. Model versions, access eligibility, and fees may change. See model pricing for current availability and prices on our platform.

What is this upgrade useful for?

K3.1 Pro is aimed at multi-step work: interpreting requirements, generating an artifact, checking the result, and revising it based on feedback. A 1-million-token context can accommodate more material, but success on long tasks still depends on the tools, environment, and acceptance criteria. The official introduction highlights coding, 3D creation, and financial research. The examples below come from a third-party account and vendor demonstrations, not runs by our team.

3D camera: Does the structure actually change with the parameters?

In “Domestic models have taken another big step forward: hands-on testing of Kimi K3.1 Pro,” Liu Xiaopai asked several models to build an interactive camera. The author reported that K3.1 Pro generated 34 selectable components and a nine-blade aperture, and that 35 optical readings met the author’s checks. In a second round, changing the lens from 50 mm to 85 mm also changed the geometry rather than just the label.

The same example had shortcomings: the export units did not follow the requirement, and there were clearance issues between the body frame and the aperture. For design tasks, a more useful acceptance check covers dimensions, interaction, exported files, and follow-up edits—not just a rendered image. The author used different coding-tool environments, so these experiences are not a controlled, apples-to-apples model ranking.

Game map: Generate a tool, then have the Agent use it

The same author also built a browser-based Terraria map editor, requiring block placement to follow the game’s rules and exported maps to work when loaded back into the game. The author then asked K3.1 Pro to use the generated editor to build a scene. This kind of task combines file-format understanding, interface development, and tool use, making it closer to a real workflow than generating a code snippet for display. The author felt that Kimi and the comparison models each had visual strengths; that is a personal observation, not a universal judgment about aesthetics.

Financial research: Check formulas and citations, not just conclusions

Materials introduced by Zenan, Zhang Qian, and Panda of the media outlet 机器之心 (Machine Heart) describe financial modeling, research reports, and 3D engineering examples. The official documentation also demonstrates a financial model with adjustable business assumptions and a research report with cited sources. The useful acceptance criteria are whether formulas update when assumptions change, key figures can be traced back to source files, and each report citation opens to its source. A vendor demonstration is not a guarantee of accuracy for arbitrary financial tasks.Official capabilities and examples

As of the documentation check for this article, the vendor says it plans to make the full weights available before November 4. This is a plan, not a release announcement. The 3D features in the official app should also not be taken to mean that the API includes a built-in 3D modeling tool.

Basic API call

The official example uses Python 3.9+ and the OpenAI SDK. Store your API key in an environment variable; do not put it in source code or commit it to version control.

python3 -m pip install --upgrade 'openai>=1.0'
export MOONSHOT_API_KEY="your-api-key"
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["MOONSHOT_API_KEY"],
    base_url="https://api.moonshot.cn/v1",
)

result = client.chat.completions.create(
    model="kimi-k3.1-pro",
    messages=[{"role": "user", "content": "List three ways to design a reliable code review process."}],
    reasoning_effort="high",
)
print(result.choices[0].message.content)

For a direct connection to Moonshot, use a key issued by Moonshot and the official Base URL above. When using a third-party OpenAI-compatible service, replace the Base URL, key, and model with the values provided by that service; do not give it your Moonshot credentials. For models and billing currently supported by Guishu Intelligence, see the model pricing page.

Choosing a reasoning effort

K3.1 Pro is always in thinking mode. reasoning_effort controls the reasoning level; it does not turn thinking on or off. The official options are low, high, and max, with max as the default.Official reasoning-effort documentation

  • For short Q&A or clearly structured transformation tasks, try low first.
  • For multi-step code changes, analysis, and planning, start with high.
  • For complex tasks that need deeper reasoning, compare max for quality, latency, and actual cost.

These are workflow suggestions, not performance guarantees. In production, evaluate accuracy, latency, and cost on your own task set.

Multi-turn conversations: Preserve the complete assistant message

For multi-turn conversations and tool responses, the official guidance says to add the complete assistant message returned by the API to the next request, rather than keeping only the text in content. Structured fields such as tool calls may be needed by later steps.Official multi-turn conversation guidance

messages = [{"role": "user", "content": "First outline a migration plan, then explain the risks."}]
first = client.chat.completions.create(
    model="kimi-k3.1-pro",
    messages=messages,
    reasoning_effort="high",
)
messages.append(first.choices[0].message)
messages.append({"role": "user", "content": "Turn the risk section into a checklist."})
second = client.chat.completions.create(model="kimi-k3.1-pro", messages=messages)
print(second.choices[0].message.content)

If your application persists conversations across requests, save the message fields required by the protocol and verify how your SDK serializes message objects against the official documentation.

Tool calls and the Agent loop

The application defines and executes tools: the model produces a tool call, the application validates its arguments and invokes the actual function, then returns the tool result to the model. Do not execute model output as a trusted command.

import json

tools = [{
    "type": "function",
    "function": {
        "name": "lookup_order",
        "description": "Look up an order's status",
        "parameters": {
            "type": "object",
            "properties": {"order_id": {"type": "string"}},
            "required": ["order_id"],
        },
    },
}]
messages = [{"role": "user", "content": "Check the status of order A-104"}]
response = client.chat.completions.create(
    model="kimi-k3.1-pro", messages=messages, tools=tools
)
assistant = response.choices[0].message
messages.append(assistant)  # Preserve the complete assistant message

for call in assistant.tool_calls or []:
    args = json.loads(call.function.arguments)
    # In a real application, validate arguments and user permissions before
    # calling a controlled business function.
    tool_result = {"order_id": args["order_id"], "status": "processing"}
    messages.append({
        "role": "tool",
        "tool_call_id": call.id,
        "content": json.dumps(tool_result),
    })

final = client.chat.completions.create(
    model="kimi-k3.1-pro", messages=messages, tools=tools
)
print(final.choices[0].message.content)

The official tool-calling guide also requires each tool result to be returned with its corresponding tool_call_id, and the complete assistant message to be retained in subsequent turns. The application is responsible for authorization, argument validation, timeouts, idempotency, and auditing.

Vision input: Use an array of objects

The official documentation specifies that a vision message’s content is an array of objects, not a serialized string. The example sends an image as a Base64 Data URL. You can also use an ms:// file reference through the supported file workflow. Do not assume that an ordinary public image URL can be read.Official vision-input documentation

import base64
from pathlib import Path

image_data = base64.b64encode(Path("diagram.png").read_bytes()).decode()
response = client.chat.completions.create(
    model="kimi-k3.1-pro",
    messages=[{
        "role": "user",
        "content": [
            {"type": "image_url", "image_url": {
                "url": f"data:image/png;base64,{image_data}"
            }},
            {"type": "text", "text": "Describe the system components and connections shown in the diagram."},
        ],
    }],
)
print(response.choices[0].message.content)

Before integration, check the supported image formats, size limits, and file API restrictions. Confirm your organization’s data-handling rules before sending sensitive images to an external model.

Interpreting official benchmarks and third-party experience

Moonshot’s documentation reports a score of 65.7% for K3.1 Pro on Terminal-Bench 4.0 and lists comparisons with GPT-6 Astra and Claude Opus 5.5. These are vendor-published benchmark figures. Interpret them in light of the task set, test configuration, and publication date; they do not predict a win rate across all coding tasks.Official model overview and benchmarks

Third-party author Liu Xiaopai shared experiences including an interactive 3D camera project, along with personal comparisons of models. This is a third-party account, not a Guishu Intelligence test or a standardized, reproducible head-to-head evaluation. To assess a model, use your own codebase, design constraints, and failure cases, and record prompts, tools, retries, latency, and cost.

Integration checklist

  1. Confirm whether you are calling the official API directly or using a compatible service, then use the matching model ID, Base URL, and key.
  2. Start with a lower reasoning effort and compare quality, latency, and billing on representative tasks.
  3. In multi-turn and Agent workflows, preserve the complete assistant message and associate tool results with the correct call.
  4. Build vision messages as an array of objects; use a supported encoding or file workflow for local images.
  5. Set permission boundaries, argument validation, timeouts, and failure handling for tool execution.
  6. Before deployment, check the current model catalog, available regions, and prices rather than reusing an old configuration.

Frequently asked questions

What is the API model ID for Kimi K3.1 Pro?

The official documentation gives the ID as kimi-k3.1-pro. The high-speed variant is kimi-k3.1-pro-highspeed; treat it as a separate model configuration.

What is the default reasoning effort?

The official documentation lists low, high, and max, with max as the default. Thinking mode itself is always enabled.

Can I pass an image URL directly?

No. The official documentation explicitly says public image URLs are not supported. Use a vision object array with a Base64 Data URL, or an ms:// reference through the file workflow.

Why should an Agent return the complete assistant message?

It may contain structured fields such as tool calls. Keeping only the text loses information needed for subsequent interactions. Tool results must also be returned with the corresponding tool_call_id.

Does Guishu Intelligence offer Kimi K3.1 Pro?

Check the current model pricing page for available models, routing, and prices. Official API capabilities do not mean that the model—or its high-speed variant—is available on our platform.

Further reading


Official documentation checked: 2026-10-24. Model capabilities, API parameters, and access conditions may change; consult the Moonshot Kimi API documentation.