Skip to main content

Dall-E Tool

The Dall-E tool allows your agent to create images using OpenAI's Dall-E image generation tool.

Setup

You will need an OpenAI API Key which you can get from the OpenAI web site and then set the OPENAI_API_KEY environment variable to the key you just created.

To use the Dall-E Tool you need to install the LangChain OpenAI integration package:

npm install @langchain/openai
/* eslint-disable no-process-env */
import { DallEAPIWrapper } from "@langchain/openai";

const tool = new DallEAPIWrapper({
n: 1, // Default
model: "dall-e-3", // Default
apiKey: process.env.OPENAI_API_KEY, // Default
});

const imageURL = await tool.invoke("a painting of a cat");

console.log(imageURL);

API Reference:


Was this page helpful?


You can also leave detailed feedback on GitHub.