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.
grok-4.6 (preview), which provides a 200,000 token context window, multimodal input (text and image), tool calling, and advanced reasoning for coding, agentic workflows, and knowledge-work scenarios.
In this article, you learn how to:
- Deploy Grok 4.6 (preview) in Microsoft Foundry.
- Authenticate by using Microsoft Entra ID or an API key.
- Generate output with the Chat Completions and Responses APIs.
- Configure reasoning effort with the Chat Completions API (
low,medium,high, orxhigh; defaulthigh). - Call tools with function calling.
- 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 with appropriate permissions to create and manage resources.
- A Microsoft Foundry project in a region supported for Grok 4.6 (preview) deployment. For more information, see Supported deployment types and regions.
- The Cognitive Services Contributor role on the Foundry resource, to 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.
Grok models available in Foundry
Foundry Models sold by Azure include the following SpaceXAI Grok models.
1 Registration is required for access to
grok-code-fast-1 and grok-4.
This article focuses on grok-4.6. For full capability details on all Grok models, see SpaceXAI models sold by Azure.
Deploy Grok 4.6
To deploy Grok 4.6 (preview), follow the instructions in Deploy Microsoft Foundry Models in the Foundry portal, and select thegrok-4.6 model to deploy.
Alternatively, 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.
--sku-name GlobalStandard to deploy in any supported region. Grok 4.6 (preview) currently supports only Global Standard deployment.
To deploy a Grok model that is available for Data Zone Standard (US) deployment, use --sku-name DataZoneStandard to keep processing within the United States data zone.
Reference: az cognitiveservices account deployment create
For more on the CLI deployment workflow, see Add and configure models to Foundry Models.
Generate output with the Chat Completions API
Use the Chat Completions API to send messages to Grok 4.6 (preview). Themodel value is your deployment name, not the underlying model name.
Set the following environment variables. The endpoint takes the form https://<resource-name>.services.ai.azure.com.
- Python
- JavaScript
- REST
If you didn’t install the Use Microsoft Entra ID to authenticate and generate a chat completion:To use an API key instead, pass it directly as
openai and azure-identity packages in the Prerequisites section, install them now by using your package manager, like pip:api_key:Generate a response with the Responses API
Grok 4.6 (preview) also supports the Responses API, which offers a simplified interface for stateful, multi-turn interactions and built-in tool orchestration.- Python
- JavaScript
- REST
Use function calling and tools
Grok 4.6 (preview) supports function calling, using both the Chat completions API and the Responses API. Use function calling when your application needs the model to select a tool, provide structured arguments, or coordinate multiple steps.Chat Completions API
Responses API
For the Responses API, the payload differs from the Chat Completions API: pass the conversation in theinput array by using typed content parts, and define each tool with the function fields at the top level of the tool object.
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-running tasks, where time-to-first-token matters more than total latency.
Chat Completions API
- Python
- JavaScript
- REST
Responses API
- Python
- JavaScript
- REST
When to use Grok 4.6
Use Grok 4.6 (Preview) for complex enterprise workloads that require reasoning, tool use, and multi-step execution. Grok 4.6 is optimized for coding, agentic workflows, technical problem solving, and knowledge-work applications that benefit from sustained reasoning across extended tasks. Common use cases include:- Agentic applications: Use tool calling and reasoning to plan tasks, select tools, coordinate multi-step workflows, and generate structured outputs.
- Software engineering: Support code generation, code understanding, debugging, repository-level analysis, test generation, and complex software engineering workflows.
- Knowledge work and research: Analyze information, synthesize findings, generate reports, summarize large volumes of content, and support research-intensive tasks.
- Engineering and technical workflows: Assist with technical problem solving, engineering analysis, procedural design, and other structured reasoning tasks.
- Enterprise automation: Power enterprise assistants and workflow automation that transform information into actionable business deliverables, such as reports, presentations, spreadsheets, and recommendations.
API endpoints
After you deploy Grok 4.6 (preview), call one of the following endpoints on your Foundry resource:- Chat Completions:
https://<resource-name>.services.ai.azure.com/openai/v1/chat/completions - Responses:
https://<resource-name>.services.ai.azure.com/openai/v1/responses
Request parameters
For more information about the Responses API, see Use the Azure OpenAI Responses API. For more information about Chat Completions API, see Work with chat completion models.
Response format
The response format depends on which API you call. Grok 4.6 (preview) returns an OpenAI-compatible object for both the Chat Completions API and the Responses API.Chat Completions API
A successful Chat Completions response includes the assistant message in the response choices.
The following example shows a Chat Completions response that contains a tool call.
Responses API
A successful Responses API call returns aresponse object. Instead of a choices array, the model output is an ordered output array of typed items, such as message, function_call, and reasoning items.
The following example shows a Responses API object for a text response.
output array contains a function_call item instead of a message item.
Token limits and context window
Grok 4.6 (preview) has a context window of 200,000 tokens. Output is capped at 128,000 tokens, or the remaining context budget after input, whichever is smaller. Input and generated output both count against the context window:- Input tokens: The messages (Chat Completions) or input (Responses) in your request count toward the input token budget.
- Output tokens:
max_completion_tokens(Chat Completions) ormax_output_tokens(Responses) bounds the generated response, up to the 128,000-token output cap, and includes reasoning tokens. - Total: Input and output tokens must fit within the 200,000-token context window. If a request exceeds the context window, it fails.
Supported deployment types and regions
Grok 4.6 supports Global Standard deployment type in all regions. For supported deployment regions, see Region availability for Foundry Models sold by Azure.API quotas and limits
Grok 4.6 (preview) in Foundry 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.
You can request more quota if needed. For more information, see Request increases to the default limits.
Troubleshoot
Use the following table to identify common errors and resolutions.Responsible AI considerations
Before you use Grok 4.6 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.