Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Computer Tool Param

From Leeroopedia
Knowledge Sources
Domains API_Types, Python
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete type for parameterizing a computer use tool provided by the openai-python SDK.

Description

ComputerToolParam is a TypedDict that defines the parameter structure for configuring a virtual computer control tool in the Responses API. It requires display_height and display_width (both integers specifying the screen dimensions), an environment field restricted to one of "windows", "mac", "linux", "ubuntu", or "browser", and a type field fixed to "computer_use_preview". All fields are marked as Required.

Usage

Import this type when constructing a tool list for a response request that includes computer use capabilities. Pass it as a tool parameter to enable the model to interact with a virtual computer display.

Code Reference

Source Location

Signature

class ComputerToolParam(TypedDict, total=False):
    """A tool that controls a virtual computer."""
    display_height: Required[int]
    display_width: Required[int]
    environment: Required[Literal["windows", "mac", "linux", "ubuntu", "browser"]]
    type: Required[Literal["computer_use_preview"]]

Import

from openai.types.responses import ComputerToolParam

I/O Contract

Fields

Name Type Required Description
display_height int Yes The height of the computer display in pixels.
display_width int Yes The width of the computer display in pixels.
environment Literal["windows", "mac", "linux", "ubuntu", "browser"] Yes The type of computer environment to control.
type Literal["computer_use_preview"] Yes The type of the computer use tool. Always "computer_use_preview".

Usage Examples

from openai.types.responses import ComputerToolParam

tool: ComputerToolParam = {
    "type": "computer_use_preview",
    "display_width": 1920,
    "display_height": 1080,
    "environment": "linux",
}

response = client.responses.create(
    model="gpt-4o",
    tools=[tool],
    input="Take a screenshot of the desktop",
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment