Skip to content
Azamol AI — Intelligent Assistance Solutions

Kimi K3.1 Pro API Setup: A Step-by-Step Guide with the OpenAI SDK

Author:
Kimi K3.1 Pro API Kurulumu: OpenAI SDK ile Adım Adım Rehber

Setting up the Kimi K3.1 Pro API takes four steps: create an API key in the Kimi API Platform console, store it in the MOONSHOT_API_KEY environment variable, install the OpenAI Python SDK with python3 -m pip install --upgrade 'openai>=1.0', and point the client's base_url at https://api.moonshot.ai/v1 with kimi-k3.1-pro as the model. Released by Moonshot AI on October 23, 2026, K3.1 Pro is an open-weight model with a 1M-token context. The most important setting after setup is reasoning_effort: it defaults to max, so every request runs at the highest thinking level.

What is Kimi K3.1 Pro, and what is it for?

Kimi K3.1 Pro is the first model in Moonshot AI's K3.1 series. The company's tech blog presents it as a post-trained version of Kimi K3 and its most capable 3T-class open-weight model to date. According to the model card, K3.1 Pro has 2.8 trillion total parameters, of which 104 billion are active per token, and a context window of 1,048,576 tokens. It takes text and images, and the official guide also supports video input through file uploads. A kimi-k3.1-pro-highspeed variant offers the same capabilities at 2-3 times the speed.

Kimi K3.1 Pro is pitched at coding, finance and 3D design. By Moonshot's own measurement, it scores 65.7% on Terminal-Bench 4.0, against 66.4% given for Claude Opus 5.5. In independent testing, Vals AI puts the model 9th of 34 on the Vals Index with 62.52 and lists its release date as October 23, 2026. Besides the Kimi API, the model is served by 17 providers on OpenRouter.

What are the requirements for setting up the Kimi K3.1 Pro API?

You need five things to use Kimi K3.1 Pro through the API:

  • A Kimi API Platform account and API key: According to the general quickstart, you create the key on the API Keys page after signing in. Keep it out of your code; our Northflank breach article explains why.
  • At least $1 of credit: According to the K3.1 Pro guide, the model stays locked until the account has a top-up of at least $1. Rate limits also depend on your cumulative top-up.
  • Python 3.9 or later: If you use Node.js, you need version 18 or later.
  • OpenAI SDK 1.0.0 or later: The Kimi API follows the OpenAI format, so there is no separate Kimi library to install.
  • A terminal: The export line below is for a macOS or Linux shell. On Windows, set the environment variable the way your own shell does it.

How do you set up the Kimi K3.1 Pro API step by step?

Setting up Kimi K3.1 Pro follows Moonshot's official Python example; the code blocks below are taken unchanged from the official documentation.

Step 1 — Store the key in an environment variable. The examples read the key from MOONSHOT_API_KEY. Replace the quoted value with your own key:

bash
export MOONSHOT_API_KEY="YOUR_KIMI_API_KEY"

Step 2 — Install the OpenAI SDK. This command upgrades the SDK to version 1.0 or later:

bash
python3 -m pip install --upgrade 'openai>=1.0'

Step 3 — Point the client at the Kimi endpoint. The only Kimi-specific setting is the base_url line:

python
import os

from openai import OpenAI

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

Step 4 — Send the first request. Add this below the client in the same Python file and run the file with Python; the model's reply is printed in the terminal:

python
completion = client.chat.completions.create(
    model="kimi-k3.1-pro",
    messages=[{"role": "user", "content": "Introduce Kimi K3.1 Pro in one sentence."}],
)

print(completion.choices[0].message.content)

Step 5 — Choose the thinking level. Thinking is always on in Kimi K3.1 Pro and cannot be turned off; the reasoning_effort field sets how much. The official example sets the highest level explicitly:

python
completion = client.chat.completions.create(
    model="kimi-k3.1-pro",
    reasoning_effort="max",
    messages=[{"role": "user", "content": "Prove that the square root of 2 is irrational."}],
)

print(completion.choices[0].message.content)

The field accepts low, high and max. If you leave it out, max is used. For short tasks such as answering customer questions, compare low and high on your own examples.

How do you verify that the Kimi K3.1 Pro setup works?

The quickest way to verify the Kimi K3.1 Pro setup independently of Python is the curl request from the official guide. It uses the same MOONSHOT_API_KEY variable:

bash
curl https://api.moonshot.ai/v1/chat/completions \
  --header "Authorization: Bearer $MOONSHOT_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "kimi-k3.1-pro",
    "messages": [{"role": "user", "content": "Introduce Kimi K3.1 Pro in one sentence."}]
  }'

The response comes back in OpenAI format, with the text in choices[0].message.content. The Python example reads the reply from completion.choices[0].message.content as well. Kimi models do not produce the exact same answer every time, so check for a meaningful reply rather than an identical sentence. If curl works but Python does not, the problem is most likely the SDK version or the base_url line.

Which common errors and fixes should you know for Kimi K3.1 Pro?

Most errors with Kimi K3.1 Pro come from habits formed on OpenAI models. Based on the limits in the official guide, the main cases are:

SymptomCauseFix
The model shows as locked in your accountNo credit has been added yetTop up at least $1
Your temperature or top_p setting changes nothingThese values are fixed on K3.1 Pro (temperature=1.0, top_p=0.95)Remove them from the request and steer behavior with instructions
Multi-turn chat or tool calls do not give the expected resultOnly content from the previous reply is sent backAppend the full assistant message, including reasoning_content and tool_calls, to messages
A request with an image failsPublic image URLs are not supportedSend the image as base64 or as ms://<file-id>
JSON output cannot be parsedThe code reads the reasoning_content fieldParse json_schema output from message.content only
Replies are slow and cost more than expectedThe default reasoning_effort is maxTry low or high for short tasks; for speed, look at kimi-k3.1-pro-highspeed

One more note: the guide says the official web search tool is being updated and is not recommended for production workflows in the near term. If your assistant needs current information, run the search with your own tool.

Which way should you use Kimi K3.1 Pro?

There are three ways to reach Kimi K3.1 Pro, and each has different data and license consequences. We compiled the table below from the official documentation and the license text:

RouteSetup workWho processes the dataLicense angle
Kimi APIKey, OpenAI SDK, base_urlMoonshot AI; Zero Data Retention is availableUse through Moonshot's official products is exempt
Third-party provider (e.g. providers on OpenRouter)The provider's key and endpointThe provider you chooseThe exemption is written for certified inference partners only; ask the provider
Your own serversMulti-GPU server with vLLM, SGLang or TokenSpeedYour infrastructureInternal use is exempt; if you offer the model to others as a service, check the revenue threshold

How much does an AI assistant cost per month on Kimi K3.1 Pro?

In the example below, an AI assistant handling 10,000 customer conversations a month costs $230 in Kimi K3.1 Pro model usage. For pricing, we used the figures Vals AI lists: $2 per million input tokens and $10 per million output tokens. We could not access the table on Kimi's pricing page, so check the current price in the console before you budget. We assume 4,000 input tokens and 1,500 output tokens including thinking per conversation; these are our example figures, not numbers published by Moonshot.

  1. Input: 10,000 × 4,000 = 40 million tokens; 40 × $2 = $80.
  2. Output: 10,000 × 1,500 = 15 million tokens; 15 × $10 = $150.
  3. Monthly total: $80 + $150 = $230.
  4. If conversations are processed in bulk rather than live, the Batch API bills 60% of the standard price according to the pricing page: $230 × 0.6 = $138.

We kept the output share high because thinking at the default max level can run long. Repeated system prompts are cached automatically and cached input is billed at a lower rate, so your real bill may differ. The math covers model usage only; WhatsApp or phone channel fees, integration and maintenance are not included.

What should you check before taking Kimi K3.1 Pro live?

Before taking Kimi K3.1 Pro live, settle four points:

  • Language quality: The model card does not list supported languages. The system prompt in the official example describes the model as especially good at conversations in Chinese and English. If your customers write in other languages, measure quality with your own customer questions and state the response language explicitly in the system prompt.
  • GDPR: If you process personal data of people in the EU, Article 28 GDPR requires processing by a processor to be governed by a binding contract and to follow the controller's documented instructions. Zero Data Retention on the Kimi API does not replace that contract. Get the processing terms and region in writing. This is not legal advice.
  • License thresholds: Under the license, companies that offer the model to others as a service via API and whose revenue exceeded $20 million over the last 12 months need a separate agreement with Moonshot. Products above 100 million monthly active users or $20 million in monthly revenue must display the "Kimi K3.1-Pro" name in their interface. Most small and mid-sized businesses stay well below these thresholds.
  • Security work: Moonshot says it removed cyber-related training data from the open-weight release. If you are choosing a model for security analysis, factor in that limitation.

Which Kimi K3.1 Pro version does this guide use?

The steps in this guide are written for the model ID kimi-k3.1-pro and the https://api.moonshot.ai/v1 endpoint. According to the official guide, max_completion_tokens defaults to 131072 and can be raised to 1048576. Because the SDK is installed with the openai>=1.0 condition, you get the current OpenAI release on that day; pin the version you use in production in your own dependency file. For the faster model, changing the model ID to kimi-k3.1-pro-highspeed is enough.

What does this setup mean for your business?

For businesses that work with long documents and want to test another model with only small changes to existing OpenAI code, setting up Kimi K3.1 Pro is a low-cost way to experiment. Take a mid-sized engineering firm that reads long tender specifications before every bid. With a 1M-token context, it can pass an entire specification to the model in one request and ask compliance questions. If its code already uses the OpenAI SDK, switching means changing the key, the base_url and the model line. The real work is measuring answer quality in each language you serve and settling the data processing terms with your provider.

Who it suits, and who it does not:

  • A good fit: Businesses that work with long contracts, specifications or financial documents, run coding agents, already have an integration built on the OpenAI SDK, and have access to at least one developer.
  • Not a good fit: Businesses without developer resources get results faster from a ready-made AI assistant service than from building on the API. Businesses that need instant answers on the phone will feel the delay of long thinking at the default max level. Businesses that cannot send customer data to an outside provider and have no multi-GPU servers should also look elsewhere.

Three steps you can take this week:

  1. Send 50 real customer questions, with personal data removed, to K3.1 Pro at low and max; record accuracy and response time.
  2. Get in writing which provider and which country processes your data, and the Zero Data Retention terms.
  3. Plug your monthly conversation volume into the math above and compare the result with your current model's bill.

If you need a cheaper classification layer, see our Claude Haiku 5.5 API setup guide; to add an assistant to your website, see our AI assistant installation guide. For multi-step flows that read a long document and then open a CRM record or draft a quote, see our AI agent service; to receive customer messages on WhatsApp, our WhatsApp automation service. You can try ready-made scenarios on our demos page.

Sources

Last checked: November 8, 2026.

Next step

To adapt Kimi K3.1 Pro or another model to your own workflow, visit our AI assistant service page, request a short discovery call through our contact form, or call +90 850 840 08 23 and talk live with Azra, our voice assistant.

Frequently asked questions

Is the Kimi K3.1 Pro API paid?

Yes. The model unlocks once your account has a top-up of at least $1. Vals AI lists token pricing at $2 per million input tokens and $10 per million output tokens; check the current price in the console. Requests processed in bulk through the Batch API are billed at 60% of the standard price.

Which languages does Kimi K3.1 Pro support?

Moonshot's model card does not list supported languages, and the official example describes the model as especially good in Chinese and English. Test answer quality in each language you serve with real customer questions before going live, and state the response language explicitly in the system prompt.

Can we run Kimi K3.1 Pro on our own servers?

The weights are on Hugging Face, and the model card gives the vllm serve "moonshotai/Kimi-K3.1-Pro" command for vLLM. With 2.8 trillion total parameters, though, the model needs a multi-GPU server. Internal use is free under the license; if you plan to offer the model to others as a service, check the license's revenue threshold.

Can we move our existing OpenAI code to Kimi K3.1 Pro?

Yes. The Kimi API follows the OpenAI format, so changing the key, the base_url and the model ID is enough. In addition, remove the fixed parameters (temperature, top_p) from requests and send the assistant message back with its reasoning_content in multi-turn conversations.