APIMart
Back to all models

Kimi K2.7 Code API

Moonshot AIModel ID kimi-k2.7-codeText model

Kimi K2.7 Code will be retired on December 31, 2026, after which API calls will stop working. We recommend migrating to Kimi K3 ahead of time.

View Kimi K3

Use Kimi K2.7 Code to carry a refactor across many files, work through a failing CI run step by step, or wire a tool into an agent over MCP.

Max input
262,144 tokens
Max output
262,144 tokens
Input → output
Text, Image → Text
  • Image input
  • Streaming
  • Cached input pricing
  • OpenAI SDK compatible

Kimi K2.7 Code API use cases

Each use case comes with an illustrative example: source material, a prompt and a hand-written sample answer, not actual model output. Copy the prompt, swap in your own material and try it on Kimi K2.7 Code.

Try Kimi K2.7 Code with your own material

Refactors across many files

Give Kimi K2.7 Code the goal, the file list and tools to read, edit and run tests, and let it work through the change. Review the full diff and run the test suite before merging.

Example: Why did CI fail on this commit?

Material

CI log (excerpt)
warning: unused variable 'tmp' error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. (src/user.ts:18) 3 tests skipped
src/user.ts:18
sendWelcome(user.email);

PromptRead the CI log, find the first real error, and propose the smallest fix.

Sample answer · written by hand to show the reasoning

The warning and the skipped tests don’t fail the build; the type error does. user.email can be undefined, but sendWelcome needs a string. Either skip the call when email is missing (if (user.email) sendWelcome(user.email);) or make email required where users are created. Rerun the type check to confirm.

About the Kimi K2.7 Code API

  • Built on Kimi K2.6 for coding

    Moonshot built Kimi K2.7 Code on Kimi K2.6 for long-horizon coding work. It is the default model in Moonshot’s Kimi Code.

  • Always thinks, with fewer thinking tokens

    It always reasons before answering and keeps reasoning across turns. Moonshot reports about 30% fewer thinking tokens than Kimi K2.6. The context window is 262,144 tokens.

  • Retiring in late December 2026

    Moonshot has closed Kimi K2.7 Code to new users and expects to retire it in late December 2026. Plan the move to Kimi K3 now.

  • Kimi K2.7 Code API key and access

    You don’t need a separate Kimi K2.7 Code API key: one APIMart key works for every model. Requests go through an OpenAI Chat Completions-compatible endpoint with the model ID kimi-k2.7-code; Kimi K2.7 Code API pricing is in the table on this page.

Kimi K2.7 Code official benchmark results

Selected results Moonshot AI published at launch.

  • Kimi Code Bench v2

    62.0

    Moonshot’s in-house coding benchmark. Up from 50.9 for Kimi K2.6; GPT-5.5 scores 69.0 and Claude Opus 4.8 67.4.

  • MCP Mark Verified

    81.1

    Agents completing tasks with tools over MCP. Up from 72.8 for Kimi K2.6; Claude Opus 4.8 scores 76.4 and GPT-5.5 92.9.

  • MCP Atlas

    76.0

    Tool use over MCP. Up from 69.4 for Kimi K2.6; GPT-5.5 scores 79.4 and Claude Opus 4.8 81.3.

  • Program Bench

    53.6

    A programming evaluation. Up from 48.3 for Kimi K2.6; GPT-5.5 scores 69.1 and Claude Opus 4.8 63.8.

  • MLS Bench Lite

    35.1

    A machine-learning engineering evaluation. Up from 26.7 for Kimi K2.6; GPT-5.5 scores 35.5 and Claude Opus 4.8 42.8.

  • Kimi Claw 24/7 Bench

    46.9

    Moonshot’s in-house benchmark for long-running agent work. Up from 42.9 for Kimi K2.6; Claude Opus 4.8 scores 50.4 and GPT-5.5 52.8.

How to call the Kimi K2.7 Code API

To call Kimi K2.7 Code, you only need an APIMart API key and your existing OpenAI SDK, or send plain HTTP requests.

POST /v1/chat/completions
curl https://api.apimart.ai/v1/chat/completions \
  -H "Authorization: Bearer $APIMART_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "kimi-k2.7-code",
  "messages": [
    {
      "role": "user",
      "content": "Describe how to design a clear API in three sentences."
    }
  ],
  "stream": false
}'

Kimi K2.7 Code access details

Model IDkimi-k2.7-code
Base URLhttps://api.apimart.ai/v1
Endpoint/chat/completions

Common parameters

model
Required
messages
Required
stream
Optional
max_tokens
Optional
temperature
Optional
All request parameters, response fields and error codes

Kimi K2.7 Code API request parameters

Kimi K2.7 Code uses the general chat endpoint, POST /v1/chat/completions, with a JSON body. model and messages are required; every other parameter is optional.

ParameterTypeRequiredDescription
modelstringYesModel ID. Use kimi-k2.7-code for this model.
messagesarrayYesConversation messages. Each message has a role (system, user, or assistant) and content. Include earlier messages for multi-turn conversations.
streambooleanNoWhether to stream the output. true returns chunks over SSE, false returns the full response at once. Default: true.
temperaturenumberNoOutput randomness, 0–2. Default: 1.0. Lower values give more deterministic output.
top_pnumberNoNucleus sampling, 0–1. Default: 1.0. Adjust this or temperature, not both.
max_tokensintegerNoMaximum number of tokens to generate for the reply.
frequency_penaltynumberNoFrequency penalty, -2.0 to 2.0. Default: 0. Positive values reduce repeated wording.
presence_penaltynumberNoPresence penalty, -2.0 to 2.0. Default: 0. Positive values encourage new topics.
stopstring | arrayNoUp to 4 stop sequences. Generation stops when any of them appears.
nintegerNoNumber of replies to generate. Default: 1.

Response fields

The response contains the fields below. Token usage is returned in usage, which you can use to check costs.

FieldTypeDescription
idstringUnique identifier for the request.
modelstringThe model that handled the request.
choicesarrayList of replies. Each item contains message (role and content) and finish_reason.
usageobjectToken usage: prompt_tokens, completion_tokens, and total_tokens.

Error codes

Failed requests return an error object with code, message, and type.

StatusTypeMeaning
400invalid_request_errorInvalid request parameters.
401authentication_errorThe API key is invalid or missing.
402payment_requiredInsufficient account balance.
403permission_errorNo permission to access this resource.
429rate_limit_errorToo many requests. Retry later.
500server_errorInternal server error.
502bad_gatewayGateway error. The service is temporarily unavailable.

Kimi K2.7 Code API pricing

The Kimi K2.7 Code API is billed by token usage, and prices depend on your membership tier. Prices below are per million tokens; 1 US dollar = 10 credits.

ItemGoldCurrent pricePlatinumDiamondOfficial priceYou save
Input7.4288Credits~$0.74297.0574Credits~$0.70576.6859Credits~$0.66869.286Credits~$0.928620%
Cached input1.4858Credits~$0.14861.4115Credits~$0.14111.3372Credits~$0.13371.8572Credits~$0.185720%
Output30.8295Credits~$3.08329.288Credits~$2.928827.7466Credits~$2.774738.5369Credits~$3.853720%

Prices are for reference only. View full pricing

Why call Kimi K2.7 Code API through APIMart

  • 20% below official pricing

    Kimi K2.7 Code API pricing is billed by token usage. Gold to Diamond member prices are 20%–28% below Moonshot AI's official prices, and cached input costs just $0.1486 per 1M tokens.

    See membership prices
  • One API key for 500+ models

    Kimi K2.7 Code, the rest of its family and 500+ models from GPT, Claude, Gemini and more share one API key and one account balance. Switching models is just a change to the model parameter.

  • Change two lines of existing code

    If you already use the OpenAI SDK, point base_url at https://api.apimart.ai/v1 and swap in your APIMart API key. Requests and responses keep the same format.

  • Try it online before you code

    Try Kimi K2.7 Code with your own material in the Playground, no code or setup needed, and integrate once you like the results.

    Open Playground

Which Moonshot AI model should you choose?

Base prices per 1M tokens (USD). Your Kimi K2.7 Code API key works for every model in the table; just change the model parameter.

Differences between Moonshot AI models
ComparisonKimi K2.7 Code CurrentKimi K2.6Kimi K3
Best forLong-horizon coding, Agentic tool use, Always thinksCoding agents, Long-horizon tool use, Open weightsLong-horizon coding, Web research, Images and documents
Max input262,144 tokens262,144 tokens1,000,000 tokens
Max output262,144 tokens262,144 tokens104,857 tokens
Input price$0.7429$0.7429$2.4
Output price$3.083$3.083$12

Kimi K2.7 Code FAQ

Is Kimi K2.7 Code being retired?

Yes. Moonshot lists Kimi K2.7 Code as deprecated: it is no longer available to newly registered users and is expected to be retired in late December 2026. Moonshot’s migration advice is to set model to kimi-k3 and remove the thinking parameter from the request. On APIMart the same API key works for Kimi K3, so rerun your coding tasks on it before the cut-off.

Should I use Kimi K2.7 Code or Kimi K2.6?

Use Kimi K2.7 Code for coding agents and long programming tasks: Moonshot built it on K2.6 for this work, and it scores higher on Moonshot’s coding and MCP benchmarks while using about 30% fewer thinking tokens. For writing, analysis and chat, Moonshot recommends Kimi K2.6. Both use the same APIMart API key.

Can I turn off thinking on Kimi K2.7 Code?

No. Moonshot’s documentation says Kimi K2.7 Code only accepts thinking enabled, and passing disabled returns an error; it also keeps reasoning from earlier turns. If you need fast answers without thinking, use Kimi K2.6 with thinking turned off.

Which parameters are fixed on Kimi K2.7 Code?

Moonshot’s documentation fixes temperature at 1.0, top_p at 0.95, n at 1, and presence and frequency penalty at 0. Passing any other value returns an error, so leave these parameters out of the request. tool_choice accepts auto and none; required returns an error.

Kimi K2.7 Code is open-weight, so why use the API?

The weights are on Hugging Face under a Modified MIT License, but it is a 1-trillion-parameter mixture-of-experts model with 32 billion active parameters, so running it yourself takes a multi-GPU server. Through the API you pay per token and need only an API key.

How can I try this model online?

Click Start chatting or Open Playground to visit the existing APIMart Playground. Select Kimi K2.7 Code in the text category to start exploring.

Which model ID does the Kimi K2.7 Code API use?

Set model to kimi-k2.7-code. Copy the exact ID from the page heading or the integration details panel.

Is it compatible with the OpenAI SDK?

You can keep the OpenAI SDK. Set base_url to https://api.apimart.ai/v1, provide your APIMart API key, and use the model ID on this page.

What is the context window of Kimi K2.7 Code?

On APIMart, Kimi K2.7 Code accepts up to 262,144 input tokens per request. Your prompt, earlier messages, and file content all count toward it.

How many tokens can it output at once?

Kimi K2.7 Code can output up to 262,144 tokens in a single reply. Use the max_tokens parameter to set a lower limit.

How much does the Kimi K2.7 Code API cost?

The Kimi K2.7 Code API on APIMart is billed by token, and prices depend on your membership tier. Gold: $0.7429 per million input tokens and $3.083 per million output tokens. Diamond: $0.6686 per million input tokens and $2.7747 per million output tokens. Prices may change; the pricing page has the current rates.

Does it support streaming?

Yes. The general chat endpoint streams over SSE by default. Set stream to false to receive the complete response at once.

How do I get an API key?

Sign in to APIMart and create a key on the API Keys page, then send it in the Authorization: Bearer header. The same key also works for other models on the platform.