Skip to main content
Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
MAI-Thinking-1 (preview) is a reasoning model from Microsoft for workloads that depend on multi-step reasoning, such as math, coding, and enterprise scenarios. The model uses a chat completions API that’s compatible with OpenAI SDK-style chat completions patterns. To use MAI-Thinking-1, deploy it in Microsoft Foundry, set your Foundry endpoint, authenticate your request, and call the chat completions endpoint with your deployment name. In this article, you learn how to:
  • Deploy MAI-Thinking-1 in Microsoft Foundry
  • Authenticate and call the chat completions API by using Microsoft Entra ID or an API key
  • Call tools with function calling
  • Preserve reasoning state across turns
  • Stream responses
  • Troubleshoot common errors

Prerequisites

Before you begin, you need:
PTU deployment is currently not supported for MAI-Thinking-1.
  • Permission to create and manage model deployments. The Cognitive Services Contributor role lets you deploy models. For more information, see Azure RBAC roles.
  • An authentication method: Microsoft Entra ID (recommended) or an API key.
  • Install the required dependencies to run the examples with Microsoft Entra ID authentication.

    Python

    JavaScript

    REST

    REST examples require curl to be installed and available on PATH.

MAI-Thinking-1 at a glance

Deploy MAI-Thinking-1

To deploy MAI-Thinking-1 (preview), follow the instructions in Deploy Microsoft Foundry Models in the Foundry portal, and select the MAI-Thinking-1 model to deploy. Alternatively, you can deploy the model by using the Azure CLI as shown in the following code: Replace <ACCOUNT_NAME>, <RESOURCE_GROUP>, and <DEPLOYMENT_NAME> with your values.
Reference: az cognitiveservices account deployment create To list all available deployments on your resource:
Reference: az cognitiveservices account deployment list

Retrieve your deployment details and credentials

After deployment, gather the endpoint, deployment name, and API key that you use to authenticate and route your API requests. If you use Microsoft Entra ID for REST requests, also retrieve an access token.
  1. Find the endpoint, deployment name, and key on the Details tab of your deployment in the Foundry portal or in the Keys and Endpoint section of your resource in the Azure portal.
    • Endpoint: Foundry resource endpoint of the form https://<resource-name>.services.ai.azure.com
    • Name: Deployment name - use this as the model value in chat completions requests
    • Key: API key for use with API key authentication. Alternatively, you can use a Microsoft Entra ID token for authentication.
  2. For REST requests that use Microsoft Entra ID, sign in with the Azure CLI, and then retrieve an access token and set it as an environment variable:
    Reference: az account get-access-token

Run a chat completion

Use the chat completions API to send messages to MAI-Thinking-1 (preview). The model value is your deployment name, not the underlying model name. Set these environment variables:
An example endpoint value is https://<resource-name>.services.ai.azure.com.
To use an API key instead, pass it through default headers:

Use function calling and tools

Use MAI-Thinking-1 in agentic workflows that call tools or functions. Only function tools are supported. Use function calling when your application needs the model to select a tool, provide structured arguments, or coordinate multiple steps.

Preserve reasoning state across turns

To receive the encrypted reasoning state, set reasoning_display to encrypted on each request. When set, the response includes reasoning.encrypted_content on the assistant message (non-streaming) or on the final stream chunk (delta.reasoning.encrypted_content). When you don’t set it, reasoning is null and there’s nothing to carry across turns. MAI-Thinking-1 returns encrypted chain-of-thought content with a response. The encrypted value is opaque to your application and doesn’t expose the model’s raw reasoning. Pass it back to the model when a later turn in the same conversation benefits from the reasoning the model already did, such as multi-turn agent loops and tool-calling workflows. To pass back the encrypted reasoning state:
  • Return the value exactly as you received it. Any change invalidates it.
  • Send back the complete assistant message rather than rebuilding it field by field.
  • Don’t inspect, decode, transform, log, or display the value.
  • The value counts toward the context window when you send it back.
Serializing the complete assistant message preserves the encrypted chain-of-thought field exactly as returned. If your SDK version doesn’t expose the field, preserve the equivalent assistant-message object from the raw API response.

Stream responses

Set stream to true to receive the response incrementally instead of waiting for the full completion. Streaming is useful for chat interfaces and long reasoning tasks, where time-to-first-token matters more than total latency. When streaming is enabled, the response is delivered as a series of server-sent events. Each event is a chat.completion.chunk object rather than the single chat.completion object returned by a non-streamed request. The streamed response has the following characteristics:
  • Each chunk carries a delta with the incremental fields for that step. Text arrives in the delta.content field across successive chunks.
  • Intermediate chunks set usage to null and finish_reason to null.
  • The final chunk sets finish_reason and includes the populated usage object, including usage.prompt_tokens_details.cached_tokens.
  • When you set reasoning_display to encrypted, the encrypted reasoning state is delivered on the final chunk as delta.reasoning.encrypted_content. Otherwise, reasoning is null on every chunk.
  • The stream terminates with a data: [DONE] sentinel.
An intermediate chunk has the following shape:
The final chunk carries the reasoning state, finish reason, and token usage. This example shows the response to a request that sets reasoning_display to encrypted. Otherwise, reasoning is null.

Content safety in streamed responses

Content safety applies to streamed responses. A prompt blocked by input safety fails before generation starts and returns HTTP 400. Output safety is evaluated as the response streams, so generation can stop mid-response. With stream: true, the client receives the chunks produced so far, followed by a terminal SSE error event where error.type = SafetyBlockedError, and then data: [DONE]. Handle a truncated response that ends in an error event as an expected case. For non-streaming requests, an output safety block returns HTTP 400.

When to use MAI-Thinking-1

Use MAI-Thinking-1 (preview) for workloads that benefit from deeper reasoning, longer context, or more deliberate planning. It’s best suited for tasks where answer quality depends on multi-step reasoning. Common use cases include:
  • Enterprise deployments: A 256K context window, clean data provenance, function calling, and the ability to follow complex instructions.
  • Coding workflows: Reading code, editing files, running tests, fixing bugs, observing failures, and recovering from intermediate mistakes.
  • Complex reasoning tasks: Quantitative reasoning such as financial modeling, statistical analysis, market sizing, and forecasting.

API endpoints

After you deploy MAI-Thinking-1 (preview), call the chat completions endpoint on your Foundry resource:
To authenticate, you need your resource endpoint and either a Microsoft Entra ID token or an API key. You can find these values in the Keys and Endpoint section of your resource in the Azure portal, or on the deployment details page in the Foundry portal.

Request parameters

The chat completions API accepts the following parameters.

Response format

A successful chat completions response includes the assistant message in the response choices. The following example shows a response that contains a tool call.

Token limits and context window

MAI-Thinking-1 (preview) has a total token budget of 256K per request, which supports long-context prompts and extended conversation history. Output is capped at 64K tokens, or the remaining context budget after input, whichever is smaller. Messages and generated output count against this token budget:
  • Input tokens: The messages in your request count toward the input token budget.
  • Output tokens: max_completion_tokens bounds the generated response, up to the 64K output cap, and includes reasoning tokens.
  • Total: Input and output tokens must fit within the 256K-token context window. If a request exceeds the context window, it fails.

API quotas and limits

MAI-Thinking-1 (preview) has the following rate limits measured in requests per minute (RPM) and tokens per minute (TPM). The tier available to you depends on your subscription and deployment configuration. MAI-Thinking-1 supports global standard deployment. For supported deployment regions, see Region availability for Foundry Models sold by Azure. PTU deployment isn’t currently supported.

Troubleshoot

Use the following table to identify common errors and resolutions.

Write effective prompts for reasoning tasks

For reasoning-heavy tasks, provide the model with the goal, context, constraints, and expected output format. Recommended patterns:
  • State the goal clearly.
  • Include relevant context.
  • Provide constraints, such as audience, format, length, or business rules.
  • Ask for concise final answers when you don’t need a detailed explanation.
The following example shows a well-structured prompt.

Responsible AI considerations

Before you use MAI-Thinking-1 (preview) in an application, evaluate the model for your intended scenario. Follow these recommended practices:
  • Validate model behavior on realistic prompts.
  • Test for task-specific quality, safety, and reliability.
  • Use human review for high-impact workflows.
  • Log and monitor failures according to your application requirements.
  • Apply appropriate content safety and abuse monitoring.
Microsoft Foundry screens requests with input safety and screens responses with output safety. For details about how blocked prompts and responses behave, including streaming requests, see Content safety in streamed responses.