X

Kimi K2.7 Code is Now Available in Microsoft Foundry

Kimi-K2.7-Code-is-Now-Available-in-Microsoft-Foundry

Demo code located at https://github.com/taswar/KimiFoundryDemo

There are a lot of AI model announcements these days. But every now and then one lands that feels immediately practical for real engineering work.

Kimi K2.7 Code from Moonshot AI showing up in Microsoft Foundry feels like one of those releases.

Microsoft and Moonshot AI have made Kimi K2.7 Code available in the Foundry model catalog starting July 1, 2026. It is designed for the kind of software engineering that does not happen in a single prompt — multi-file refactors, feature work spanning multiple services, debugging sessions that need to hold context across many steps.

That is a different problem space from “generate a todo app in one shot.” And honestly, that is where most development teams are today.

What Is Kimi K2.7 Code?

Kimi K2.7 Code is a coding-focused model from Moonshot AI. It builds on the K2.6 series with three focused improvements:

  • Long-horizon task execution — carries work across multiple files, tools, and steps
  • Stronger end-to-end task completion — designed to finish tasks, not just generate fragments
  • ~30% fewer thinking tokens vs K2.6 — faster responses, lower cost, more work per context window

The 256K context window is the other number worth noting. Large codebases, long refactoring sessions, multiple files in context at once — that is the use case this model is optimized for.

Benchmark Numbers — The Honest Read

Here is how K2.7 Code stacks up against K2.6 and two frontier models:

Kimi K27 Benchmark

A few things worth flagging:

The Kimi Code Bench numbers are Moonshot AI’s own benchmark — take those as directional. MCP Mark Verified is human-verified and more credible for independent comparison. On that benchmark, K2.7 Code at 81.1 actually beats Claude Opus 4.8 at 76.4. That is the benchmark most relevant to agentic coding workflows with tool use.

On pure coding tasks (Program Bench, MLS Bench Lite), it sits between GPT-5.5 and Claude Opus 4.8. That is a reasonable position for a model priced at 0.95input/4.00 output per million tokens.

Pricing

At $0.95 input, this sits below GPT-4o-class pricing. For long-running coding tasks that consume a lot of output tokens, $4.00/M output is the number to watch. Cached input at $0.19 helps when you are repeatedly loading the same large codebase context.

  Input / 1M tokens Output / 1M tokens Cached Input
Kimi K2.7 Code $0.95 $4.00 $0.19

Top Use Cases

If you are evaluating this model, here is where it fits:

  • Software engineering agents — multi-step planning, tool use, execution across a full development workflow
  • Repository-scale code understanding — analyze, modernize, or refactor large codebases while keeping context across many files
  • Complex feature implementation — changes that span multiple services, components, and repositories
  • Debugging and root cause analysis — deeper code understanding over multi-step investigation workflows

That is a pretty specific profile. This is not a general-purpose chatbot. It is a model built for developer tooling and autonomous coding agents.


Enough Theory. Let’s Actually Call It from C#

Here is a working .NET console app that calls Kimi K2.7 Code through Azure AI Foundry. I am using the Azure AI Inference SDK and DefaultAzureCredential — no API key hardcoded.

Prerequisites

dotnet new console -n KimiFoundryDemo
cd KimiFoundryDemo
dotnet add package Azure.AI.Inference --prerelease
dotnet add package Azure.Identity

Set your environment variables:

# On Windows (PowerShell)
$env:AZURE_AI_CHAT_ENDPOINT="https://YOUR-RESOURCE.services.ai.azure.com/models"
az login

Program.cs

using Azure.Identity;
using Azure;
using Azure.AI.Inference;
using Azure.Core;

var endpoint = Environment.GetEnvironmentVariable("AZURE_AI_CHAT_ENDPOINT")
    ?? throw new InvalidOperationException("Set AZURE_AI_CHAT_ENDPOINT environment variable.");

var model = Environment.GetEnvironmentVariable("AZURE_AI_MODEL") ?? "Kimi-K2.7-Code";

// DefaultAzureCredential handles Entra ID auth — no API key in code.
// Sign in first with: az login
var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions
{
    ExcludeManagedIdentityCredential = true
});

// Foundry (Cognitive Services) endpoints require a token whose audience is
// https://cognitiveservices.azure.com. Force that scope regardless of the
// scope the Azure.AI.Inference SDK requests by default.
var scopedCredential = new ScopeOverrideCredential(
    credential, "https://cognitiveservices.azure.com/.default");

var client = new ChatCompletionsClient(new Uri(endpoint), scopedCredential);

var options = new ChatCompletionsOptions
{
    Model = model,
    Temperature = 0.2f,
    MaxTokens = 2000
};

options.Messages.Add(new ChatRequestSystemMessage(
    """
    You are a senior .NET architect.
    Your job is to review code and identify issues clearly and concisely.
    Be direct. Prioritize correctness over style.
    Return findings as a numbered list with severity: critical, warning, or info.
    """));

options.Messages.Add(new ChatRequestUserMessage(
    """
    Review the following C# method and identify any issues:
 
    public async Task GetUserAsync(int userId)
    {
        var user = await _dbContext.Users
            .Where(u => u.Id == userId)
            .FirstOrDefault();
 
        return user;
    }
    """));

Console.WriteLine($"Calling model: {model}");
Console.WriteLine("---");

Response response = client.Complete(options);
System.Console.WriteLine(response.Value.Content);


// Wraps a TokenCredential and forces a fixed audience/scope, ignoring the
// scope the client pipeline asks for.
sealed class ScopeOverrideCredential : TokenCredential
{
    private readonly TokenCredential _inner;
    private readonly string[] _scopes;

    public ScopeOverrideCredential(TokenCredential inner, string scope)
    {
        _inner = inner;
        _scopes = new[] { scope };
    }

    public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
        => _inner.GetToken(new TokenRequestContext(_scopes), cancellationToken);

    public override ValueTask GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
        => _inner.GetTokenAsync(new TokenRequestContext(_scopes), cancellationToken);
}

Expected Output

I am running az login so that I am not using API_KEY

Something like:

Calling model: kimi-k2-7-code
---
1. **Critical — `Task` return type does not match returned value**  
   The method returns `user`, but the signature returns non-generic `Task`. Change it to `Task` (or `Task` if nullability is disabled).

2. **Critical — Synchronous `FirstOrDefault` used in an async method**  
   `.FirstOrDefault()` executes the query synchronously and is not awaitable. Use `.FirstOrDefaultAsync()` (and pass a `CancellationToken`).

3. **Warning — Missing `CancellationToken`**  
   Async methods should accept `CancellationToken cancellationToken = default` and forward it to `FirstOrDefaultAsync(cancellationToken)`.

4. **Info — Consider `FindAsync` for primary-key lookups**  
   Since the query is by primary key, `_dbContext.Users.FindAsync(userId, cancellationToken)` is more idiomatic and can be faster due to EF change-tracker short-circuiting.

That is the kind of output you want from a code review tool — specific, actionable, severity-tagged.

Why Run It in Foundry vs Directly?

If you are already in Azure, Foundry gives you a few things you do not get with a direct Moonshot API key:

  • Enterprise security and compliance — governance, data protection, responsible AI tooling built in
  • Side-by-side evaluation — compare Kimi K2.7 Code against GPT-5.5, Claude Opus 4.8, or any other Foundry model using the same evaluation dataset
  • GitHub Copilot and VS Code integration — native compatibility with the developer tools your team already uses
  • No separate infrastructure — model is already deployed, monitored, and scaled for you

That last point matters more than it sounds. The jump from “I tried this in a notebook” to “this is running in our CI pipeline” is usually infrastructure, not capability. Foundry removes that friction.


Final Thoughts

Kimi K2.7 Code in Microsoft Foundry is interesting for developers because it is not just a benchmark improvement. It is a model positioned for the kind of work that is genuinely hard to automate well: long-running, multi-step, multi-file engineering tasks.

The MCP Mark Verified score beating Claude Opus 4.8 is the number I would keep an eye on as agentic coding workflows mature. If your team is building AI-assisted developer tooling or coding agents, this is one worth evaluating.

If you are already on Azure AI Foundry, the model is in the catalog now. Start with the C# code above, swap in your own endpoint, and run it against a real method from your codebase. That will tell you more than any benchmark.


Resources

Categories: AI
Taswar Bhatti:
Related Post