computer-use-preview model that powers Computer use.
Prerequisites
- A deployed Azure OpenAI model.
- An authentication method:
- API key (for example,
AZURE_OPENAI_API_KEY), or - Microsoft Entra ID (recommended).
- API key (for example,
- Install the client library for your language:
- Python:
pip install openai azure-identity - .NET:
dotnet add package OpenAIanddotnet add package Azure.Identity - JavaScript/TypeScript:
npm install openai @azure/identity - Java: Add
com.openai:openai-javaandcom.azure:azure-identityto your project.
- Python:
- For REST examples, set
AZURE_OPENAI_API_KEY(API key flow) orAZURE_OPENAI_AUTH_TOKEN(Microsoft Entra ID flow).
Supported regions
Before running the examples in this article, confirm that your resource region supports the Responses API. The v1 API is required to access the latest features. For details, see the API version lifecycle. For Foundry Agent Service regional support, see the regional availability table. The Responses API is currently available in the following regions:- australiaeast
- brazilsouth
- canadacentral
- canadaeast
- centralus
- eastus
- eastus2
- francecentral
- germanywestcentral
- italynorth
- japaneast
- japanwest
- koreacentral
- northcentralus
- norwayeast
- polandcentral
- southafricanorth
- southcentralus
- southeastasia
- southindia
- spaincentral
- swedencentral
- switzerlandnorth
- switzerlandwest
- uaenorth
- uksouth
- ukwest
- westcentralus
- westeurope
- westus
- westus2
- westus3
Supported models
The Responses API supports the following models:gpt-5.6-sol(Version:2026-07-09)gpt-5.6-terra(Version:2026-07-09)gpt-5.6-luna(Version:2026-07-09)gpt-chat-latest(Versions:2026-06-24,2026-05-28,2026-05-05)gpt-5.5(Version:2026-04-24)gpt-5.4-nano(Version:2026-03-17)gpt-5.4-mini(Version:2026-03-17)gpt-5.4-pro(Version:2026-03-05)gpt-5.4(Version:2026-03-05)gpt-5.3-chat(Version:2026-03-03)gpt-5.3-codex(Version:2026-02-24)gpt-5.2-codex(Version:2026-01-14)gpt-5.2(Version:2025-12-11)gpt-5.2-chat(Version:2025-12-11)gpt-5.2-chat(Version:2026-02-10)gpt-5.1-codex-max(Version:2025-12-04)gpt-5.1(Version:2025-11-13)gpt-5.1-chat(Version:2025-11-13)gpt-5.1-codex(Version:2025-11-13)gpt-5.1-codex-mini(Version:2025-11-13)gpt-5-pro(Version:2025-10-06)gpt-5-codex(Version:2025-09-11)gpt-5(Version:2025-08-07)gpt-5-mini(Version:2025-08-07)gpt-5-nano(Version:2025-08-07)gpt-5-chat(Version:2025-08-07)gpt-5-chat(Version:2025-10-03)gpt-5-codex(Version:2025-09-15)gpt-4o(Versions:2024-11-20,2024-08-06,2024-05-13)gpt-4o-mini(Version:2024-07-18)computer-use-previewgpt-4.1(Version:2025-04-14)gpt-4.1-nano(Version:2025-04-14)gpt-4.1-mini(Version:2025-04-14)gpt-image-1(Version:2025-04-15)gpt-image-1-mini(Version:2025-10-06)gpt-image-1.5(Version:2025-12-16)o1(Version:2024-12-17)o3-mini(Version:2025-01-31)o3(Version:2025-04-16)o4-mini(Version:2025-04-16)
Not currently supported:
- Image generation using multi-turn editing and streaming.
- Images can’t be uploaded as a file and then referenced as input.
- PDF as an input file is now supported, but setting file upload purpose to
user_datais not currently supported. - Performance issues when background mode is used with streaming. Microsoft is working to resolve this issue.
Generate a text response
Generate a simple text response using the Responses API. ReplaceYOUR-RESOURCE-NAME and MODEL_NAME with your deployment values.
- Python
- C#
- JavaScript
- Java
- REST
Example response
Retrieve a response
Retrieve a response by its ID from a previous Responses API call.- Python
- C#
- JavaScript
- Java
- REST
Example response
Delete a response
By default, response data is retained for 30 days. Delete a stored response by ID.- Python
- C#
- JavaScript
- Java
- REST
Chaining responses together
Chain turns by passing the previous response ID toprevious_response_id.
Chaining responses manually
Alternatively, you can manually carry forward output items in the next request.Compact a Response
Compaction reduces the input context while preserving essential state for later turns.- Python
- C#
- JavaScript
- Java
- REST
Compact using items returned
You can compact all items returned from previous requests like reasoning, message, function call, etc.Compact using previous response ID
You can also compact using a previous response ID.Server-side compaction
You can also use server-side compaction directly in Responses (POST /responses or client.responses.create) by setting context_management with a compact_threshold.
- When the output token count crosses the configured threshold, the Responses API automatically runs compaction.
- In this mode, you do not need to call
/responses/compactseparately. - The response includes an encrypted compaction item.
- Server-side compaction will work when you set store=false on your Responses create requests.
previous_response_id, pass only the new user message on each turn. In both patterns, the compaction item carries the context needed for the next window.
Flow
- Call
responsesas usual. Addcontext_managementwithcompact_thresholdto enable server-side compaction. - If the output crosses the threshold, the service triggers compaction, emits a compaction item in the output stream, and prunes the context before continuing inference.
- Continue the conversation using one of these patterns:
- Stateless input-array chaining: append output items, including compaction items, to the next input array.
previous_response_idchaining: pass only the new user message on each turn and carry the latest response ID forward.
Example
Streaming
Stream the response as it’s generated by settingstream=true. The service emits incremental events you can consume to render output token-by-token.
Sample error event:
Function calling
The Responses API supports function calling.Handle guardrails and content filtering
Guardrails (content filters) are applied at the deployment level and run automatically on every Responses API call, so they protect both the input you send and the output the model generates. You configure guardrails separately. For more information, see Configure guardrails and controls. This section shows how to detect and handle guardrail results when you call the Responses API. The Responses API surfaces guardrail results differently from chat completions. Instead of theprompt_filter_results and content_filter_results fields that chat completions return, the response object includes a top-level content_filters array. Each entry describes one filter result.
The
content_filters array is a Microsoft Foundry extension that isn’t part of the base OpenAI response schema, so the SDKs don’t expose a typed property for it. Read it as a raw or extra field, as shown in the following examples.Detect blocked input
When guardrails block your input, the API returns an HTTP 400 error with the codecontent_filter. Catch this error to handle blocked prompts gracefully.
- Python
- C#
- JavaScript
- Java
- REST
Read guardrail annotations
When a request succeeds, read thecontent_filters array from the response to inspect the guardrail results for the input and output.
- Python
- C#
- JavaScript
- Java
- REST
Code Interpreter
The Code Interpreter tool enables models to write and execute Python code in a secure, sandboxed environment. It supports a range of advanced tasks, including:- Processing files with varied data formats and structures
- Generating files that include data and visualizations (for example, graphs)
- Iteratively writing and running code to solve problems—models can debug and retry code until successful
- Enhancing visual reasoning in supported models (for example, o3, o4-mini) by enabling image transformations such as cropping, zooming, and rotation
- This tool is especially useful for scenarios involving data analysis, mathematical computation, and code generation.
Containers
Code Interpreter has additional charges beyond the token based fees for Azure OpenAI usage. If your Responses API calls Code Interpreter simultaneously in two different threads, two code interpreter sessions are created. Each session is active by default for 1 hour with an idle timeout of 20 minutes.
"container": { "type": "auto", "file_ids": ["file-1", "file-2"] } in the tool configuration when creating a new Response object. This automatically creates a new container or reuses an active one from a previous code_interpreter_call in the model’s context. The code_interpreter_call in the output of the API will contain the container_id that was generated. This container expires if it is not used for 20 minutes.
The following file limits apply:
- A request can include up to 50 file IDs.
- A container can hold up to 1,000 files in total, including input files and files generated by Code Interpreter.
File inputs and outputs
When running Code Interpreter, the model can create its own files. For example, if you ask it to construct a plot, or create a CSV, it creates these images directly on your container. It will cite these files in the annotations of its next message. Any files in the model input get automatically uploaded to the container. You do not have to explicitly upload it to the container.Supported Files
List input items
Retrieve the input items that were sent to a response. This is useful for inspecting the full conversation context, including any items added by the model (for example, function calls or compaction items).- Python
- C#
- JavaScript
- Java
- REST
Example response
Image input
Vision-enabled models can interpret images alongside text. They can recognize objects, shapes, colors, and textures, and read text contained within an image, subject to the limitations listed later in this article. You can provide an image as input to a request in any of the following ways:- A fully qualified URL to an image file
- A Base64-encoded data URI
- A file ID created with the Files API
Image URL
Reference an image hosted at a public URL. The model fetches the image and includes it as part of the input content.Base64-encoded image
Send an image inline by encoding its bytes as a base64 data URI. Use this pattern when the image isn’t hosted at a public URL or when you want to avoid an extra network fetch.File ID
Upload an image with the Files API by usingpurpose="vision", then reference the returned file ID in your request. This approach is useful when you want to reuse the same image across multiple requests without resending its bytes.
Image input requirements
The following table lists the supported file types for image inputs.
In a single request, you can include up to 50 images. Each individual image file must be under 50 MB, and the combined size of all images in the request must also be under 50 MB.
Images must meet these additional requirements:
- The image must be relevant to the prompt; the model isn’t designed for unrelated visual content.
- Images shouldn’t contain harmful or sensitive content that violates content policies.
- Image files can’t be corrupted or unreadable. If the model can’t process an image, the request fails.
Choose an image detail level
Use thedetail property on an input_image content part to control how the model processes the image. Lower detail uses fewer tokens and is faster, while higher detail uses more tokens but lets the model capture finer features.
Image input limitations
Vision-enabled models have the following limitations:- Medical images: The model isn’t suitable for interpreting specialized medical images such as CT scans and shouldn’t be used for medical advice.
- Non-English text: The model might not perform optimally when handling images that contain text in non-Latin alphabets, such as Japanese or Korean.
- Small text: Enlarge text within an image to improve readability, but avoid cropping out important details.
- Rotation: The model might misinterpret rotated or upside-down text and images.
- Visual elements: The model might struggle with graphs or text where colors or styles—such as solid, dashed, or dotted lines—vary.
- Spatial reasoning: The model has difficulty with tasks that require precise spatial localization, such as identifying chess positions.
- Accuracy: The model might generate incorrect descriptions or captions in some cases.
- Image shape: The model has difficulty with panoramic and fisheye images.
- Metadata and resizing: The model doesn’t process original file names or metadata, and images are resized before analysis, which affects their original dimensions.
- Counting: The model might give approximate counts for objects in images.
- CAPTCHAs: For safety reasons, a system is in place to block the submission of CAPTCHAs.
File input
Models with vision capabilities support PDF input. PDF files can be provided either as Base64-encoded data or as file IDs. To help models interpret PDF content, both the extracted text and an image of each page are included in the model’s context. This is useful when key information is conveyed through diagrams or non-textual content.- All extracted text and images are put into the model’s context. Make sure you understand the pricing and token usage implications of using PDFs as input.
- In a single API request, you can include more than one file, but each file must be under 50 MB. The combined limit across all files in the request is 50 MB.
- Only models that support both text and image inputs can accept PDF files as input.
- A
purposeofuser_datais currently not supported. As a temporary workaround you will need to set purpose toassistants.
Convert PDF to Base64 and analyze
Send a PDF inline by encoding its bytes as a base64 data URI. The model receives both the extracted text and a rendered image of each page.Upload PDF and analyze
Upload the PDF file withpurpose="assistants". A purpose of user_data isn’t currently supported.
Using remote MCP servers
You can extend the capabilities of your model by connecting it to tools hosted on remote Model Context Protocol (MCP) servers. These servers are maintained by developers and organizations and expose tools that can be accessed by MCP-compatible clients, such as the Responses API. Model Context Protocol (MCP) is an open standard that defines how applications provide tools and contextual data to large language models (LLMs). It enables consistent, scalable integration of external tools into model workflows. The following example shows how to use a remote MCP server to query information about an Azure REST API repository. The model retrieves and reasons over repository content in real time.Approvals
By default, the Responses API requires explicit approval before any data is shared with a remote MCP server. This approval step helps ensure transparency and gives you control over what information is sent externally. We recommend reviewing all data being shared with remote MCP servers and optionally logging it for auditing purposes. When an approval is required, the model returns amcp_approval_request item in the response output. This object contains the details of the pending request and allows you to inspect or modify the data before proceeding.
Authentication
- The MCP client within the Responses API requires TLS 1.2 or greater.
- Mutual TLS (mTLS) is currently not supported.
- Azure service tags are currently not supported for MCP client traffic.
Authorization header.
Background tasks
Background mode lets you run long-running tasks asynchronously with reasoning models such aso3 and o1-pro. It’s useful for complex tasks that can take several minutes to complete (for example, Codex- or Deep Research-style agents). When a request is sent with "background": true, the task is processed asynchronously, and you poll for its status.
Start a background task
Setbackground=true on the request to queue the task. The service returns immediately with a response ID and a queued status — use that ID to poll, stream, or cancel the task.
Poll for completion
Continue polling while the status isqueued or in_progress. Once the response reaches a terminal state, it’s available for retrieval.
Cancel a background task
Cancel an in-progress background task with thecancel endpoint. Canceling is idempotent—subsequent calls return the final response object.
background and stream to true. This pattern lets you resume streaming if the connection drops. Track your position with the sequence_number from each event.
Limitations
- Background mode requires
store=true. Stateless requests are not supported. - You can only resume streaming if the original request included
stream=true. - To cancel a synchronous response, terminate the connection directly.
Resume streaming from a specific point
If a streaming connection drops, you can resume from a known event by passingstream=true along with starting_after=<sequence_number> on a GET to the response. The service replays events emitted after that sequence number.
Encrypted reasoning items
When you use the Responses API in stateless mode (store=false), you must still preserve reasoning context across conversation turns. To do this, include encrypted reasoning items in your requests.
To retain reasoning items across turns, add reasoning.encrypted_content to the include parameter. The response then contains an encrypted version of the reasoning trace, which you can pass to future requests.
- Streaming: Display partial image outputs during generation to improve perceived latency.
- Flexible inputs: Accept image file IDs as inputs in addition to raw image bytes.
The image generation tool in the Responses API is supported by
gpt-image-1-series models, and you can call it from a set of compatible chat and reasoning models. For the current list of supported orchestration models, see the Supported models section later in this article.The image generation tool doesn’t currently support streaming mode. To stream partial images, call the image generation API directly outside of the Responses API.Reasoning models
For examples of how to use reasoning models with the responses API see the reasoning models guide.Computer use
Computer use with Playwright has moved to the dedicated computer use model guide.Troubleshooting
- 401/403: If you use Microsoft Entra ID, verify your token is scoped for
https://ai.azure.com/.default. If you use an API key, confirm you’re using the correct key for the resource. - 404: Confirm
modelmatches your deployment name.