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
- Yarn
- pnpm
npm install @langchain/openai
yarn add @langchain/openai
pnpm add @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:
- DallEAPIWrapper from
@langchain/openai
Related
- Tool conceptual guide
- Tool how-to guides