Skip to content

Conversation

@christian-bromann
Copy link
Member

Adds a new computerUse tool for the OpenAI provider, enabling the computer-use-preview model to control computer interfaces through mouse clicks, keyboard input, scrolling, and more.

Usage

import { ChatOpenAI, tools } from "@langchain/openai";

const computer = tools.computerUse({
  displayWidth: 1024,
  displayHeight: 768,
  environment: "browser",
  execute: async (action) => {
    if (action.type === "click") {
      await page.mouse.click(action.x, action.y);
    }
    return captureScreenshot();
  },
});

const model = new ChatOpenAI({ model: "computer-use-preview" });
const response = await model.bindTools([computer]).invoke("Check the news");

@changeset-bot
Copy link

changeset-bot bot commented Dec 5, 2025

🦋 Changeset detected

Latest commit: 5bc2c23

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@langchain/openai Minor
@langchain/classic Patch
@langchain/community Patch
@langchain/deepseek Patch
@langchain/xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

const res2 = await model.invoke(messages);
expect(
res2.response_metadata?.usage.prompt_tokens_details.cached_tokens
(res2.response_metadata?.usage as any).prompt_tokens_details.cached_tokens
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how come these are needed?

Copy link
Member Author

@christian-bromann christian-bromann Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this code is touching openai code, it runs the integration test which have been failing for me in CI

@christian-bromann christian-bromann force-pushed the cb/openai-image-generation branch 2 times, most recently from 83d519c to 62eff6b Compare December 8, 2025 23:41
@christian-bromann christian-bromann force-pushed the cb/openai-computer-use branch 2 times, most recently from ffc80be to ee42538 Compare December 8, 2025 23:48
@christian-bromann christian-bromann merged commit 5bc2c23 into cb/openai-image-generation Dec 9, 2025
27 of 28 checks passed
@christian-bromann christian-bromann deleted the cb/openai-computer-use branch December 9, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants