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.
- 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:- An Azure subscription with a valid payment method. If you don’t have an Azure subscription, create a paid Azure account.
- Access to Microsoft Foundry.
- A Microsoft Foundry project in a supported deployment region. MAI-Thinking-1 is available for global standard deployment.
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 requirecurlto be installed and available onPATH.
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 theMAI-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.
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.-
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
modelvalue in chat completions requests - Key: API key for use with API key authentication. Alternatively, you can use a Microsoft Entra ID token for authentication.
- Endpoint: Foundry resource endpoint of the form
-
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). Themodel value is your deployment name, not the underlying model name.
Set these environment variables:
https://<resource-name>.services.ai.azure.com.
- Python
- JavaScript
- REST
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, setreasoning_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
Setstream 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
deltawith the incremental fields for that step. Text arrives in thedelta.contentfield across successive chunks. - Intermediate chunks set
usageto null andfinish_reasonto null. - The final chunk sets
finish_reasonand includes the populatedusageobject, includingusage.prompt_tokens_details.cached_tokens. - When you set
reasoning_displaytoencrypted, the encrypted reasoning state is delivered on the final chunk asdelta.reasoning.encrypted_content. Otherwise,reasoningis null on every chunk. - The stream terminates with a
data: [DONE]sentinel.
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. Withstream: 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: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_tokensbounds 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.
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.