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.
OpenAI-compatible · MAI Code 2 · MAI Code 2 Flash
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.
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
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.
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 →Use this base URL with any OpenAI-compatible client, and the model mai-code-2 or mai-code-2-flash.
https://maicode2.com/v1INTEGRATION
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."}]
}'API Provider: OpenAI Compatible
Base URL: https://maicode2.com/v1
API Key: sk_maicode2_your_key
Model ID: mai-code-2Open the extension settings in VS Code and choose the OpenAI Compatible provider.
PLAYGROUND
Try MAI Code 2 here before you write any code. The playground sends the same request as the API and uses the same balance.
USE CASES
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.
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.
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.
Call the API from a GitHub Actions or GitLab job to review each pull request diff, write release notes or explain failing tests.
Build code assistants, SQL helpers or documentation bots on MAI Code 2 with a server-side key and per-token billing.
LangChain, LlamaIndex, the Vercel AI SDK and other OpenAI-compatible clients connect with a base URL and key.
MODELS AND PRICES
mai-code-2The full model, for hard refactors, multi-file changes and agent loops.$3.00$0.15$15.00mai-code-2-flashThe fast, low-cost tier, for autocomplete, quick edits and high-volume calls.$0.30$0.03$1.50Price 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 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.
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.
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.
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.
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.
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.
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.
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.