MCode

OpenAI-compatible · MAI Code 2 · MAI Code 2 Flash

MAI Code 2 API

Call Microsoft’s MAI Code 2 and MAI Code 2 Flash coding models through one OpenAI-compatible endpoint. Create a key, pay $5 once, and connect your code, Cline, Continue, Aider or OpenCode in a few minutes.

  • 2models: MAI Code 2 and MAI Code 2 Flash
  • $5one-time top-up to start
  • /v1OpenAI-compatible API
cURL
curl https://maicode2.com/v1/chat/completions \
  -H "Authorization: Bearer $MAICODE2_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mai-code-2",
    "messages": [{"role": "user", "content": "Write a Python function that checks if a string is a palindrome."}]
  }'

GET STARTED

Three steps to your first MAI Code 2 API call

  1. 1

    Create an API key

    Sign in with Google or email and create a key. Keep it on your server or in your editor settings; you can revoke it at any time.

  2. 2

    Add $5 of balance, once

    A single small payment activates the key. Each request is billed by the tokens it uses: $5 covers about 180 MAI Code 2 requests of 4K input and 1K output tokens, or about 1,800 with MAI Code 2 Flash.

    One-time payment, no subscription. Your balance never expires and works with both models.

    Need more? $20 and $50 top-ups →
  3. 3

    Connect your code or editor

    Use this base URL with any OpenAI-compatible client, and the model mai-code-2 or mai-code-2-flash.

    Base URL
    https://maicode2.com/v1
    Open the integration guide →

INTEGRATION

Copy a working request

cURL
curl https://maicode2.com/v1/chat/completions \
  -H "Authorization: Bearer $MAICODE2_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mai-code-2",
    "messages": [{"role": "user", "content": "Write a Python function that checks if a string is a palindrome."}]
  }'
Cline / Roo Code / Kilo Code
API Provider:  OpenAI Compatible
Base URL:      https://maicode2.com/v1
API Key:       sk_maicode2_your_key
Model ID:      mai-code-2

Open the extension settings in VS Code and choose the OpenAI Compatible provider.

PLAYGROUND

Try MAI Code 2 online

System prompt

Try MAI Code 2 here before you write any code. The playground sends the same request as the API and uses the same balance.

Billed per token from your balance · Ctrl+Enter to send

USE CASES

Common ways to connect MAI Code 2

Swap the base URL in your code

Already using the OpenAI SDK? Change base_url to the MAI Code 2 API endpoint and the model name. Streaming, tool calls and JSON output keep working.

Coding agents in VS Code

Cline, Roo Code, Kilo Code and Continue accept any OpenAI-compatible provider. Use MAI Code 2 for agent runs and MAI Code 2 Flash for autocomplete.

Terminal agents

Aider and OpenCode run against the same endpoint. Pair MAI Code 2 as the main model with MAI Code 2 Flash as the cheap helper model.

Code review in CI

Call the API from a GitHub Actions or GitLab job to review each pull request diff, write release notes or explain failing tests.

Your own product

Build code assistants, SQL helpers or documentation bots on MAI Code 2 with a server-side key and per-token billing.

Frameworks

LangChain, LlamaIndex, the Vercel AI SDK and other OpenAI-compatible clients connect with a base URL and key.

MODELS AND PRICES

MAI Code 2 and MAI Code 2 Flash

ModelInputCached inputOutput
MAI Code 2mai-code-2The full model, for hard refactors, multi-file changes and agent loops.$3.00$0.15$15.00
MAI Code 2 Flashmai-code-2-flashThe fast, low-cost tier, for autocomplete, quick edits and high-volume calls.$0.30$0.03$1.50

Price per 1M tokens, billed from your USD balance. Minimum $0.001 per request. Failed requests are free.

Model facts were checked on 2026-11-18 against public launch coverage; see the guides for sources.

FAQ

MAI Code 2 API questions

What is MAI Code 2?

MAI Code 2 is a coding model from Microsoft AI (MAI), announced on November 17, 2026 together with a faster, cheaper tier called MAI Code 2 Flash. Both are built for writing, editing and reviewing code and for agent loops in tools such as GitHub Copilot.

How do I get a MAI Code 2 API key?

Sign in, create a key on this page, and add a one-time balance from $5. Then set the base URL to https://maicode2.com/v1 in any OpenAI-compatible client and use the model mai-code-2 or mai-code-2-flash.

Is the MAI Code 2 API OpenAI-compatible?

Yes. The endpoint follows the OpenAI Chat Completions format, including streaming and tool calls, so the official OpenAI SDKs for Python and Node.js, Cline, Continue, Aider, OpenCode and most coding agents work after you change the base URL and key.

What is the difference between MAI Code 2 and MAI Code 2 Flash?

MAI Code 2 is the full model for harder tasks such as multi-file changes and long agent runs. MAI Code 2 Flash is the fast tier for quick edits, autocomplete-style calls and high volume, at one tenth of the price per token here.

How much does the MAI Code 2 API cost?

MAI Code 2 costs $3 per million input tokens and $15 per million output tokens; MAI Code 2 Flash costs $0.30 and $1.50. Cached input is billed at a lower rate. There is no subscription: you pay once to add balance, from $5, and it never expires.

Is this an official Microsoft service?

No. MAI Code 2 API (maicode2.com) is an independent service that forwards your requests to the MAI Code 2 models through a hosted model provider. It is not affiliated with or endorsed by Microsoft or GitHub. MAI is a Microsoft trademark, used here only to name the models.

Can I try MAI Code 2 before writing code?

Yes. The playground on this page sends the same request as the API, from your browser, and shows the tokens and cost of every reply. It uses the same balance as your API keys.

Do you store my prompts and code?

API requests are not stored: we keep only metering data such as the model, token counts, cost and time. Playground messages stay in your browser. Prompts are sent to the model provider to generate the reply.

MAI Code 2 API is an independent service and is not affiliated with or endorsed by Microsoft or GitHub. MAI, MAI Code 2 and MAI Code 2 Flash are names of Microsoft models, used here only to describe them. Model output can be wrong; review generated code before you run it.