@decartai/langchain package provides a LangChain Tool that gives any LLM agent the ability to generate and edit images using Decart.
Prerequisites
- A Decart API key
- Node.js 18+
- An LLM provider (Anthropic, OpenAI, etc.) for agent usage
Installation
Install the package along with the required@langchain/core peer dependency:
Setup
Set your Decart API key as an environment variable:Quick start
Text-to-image
Generate an image from a text prompt:Image editing
Edit an existing image by providing animageUrl:
Using with LLM agents
Bind the tool to an LLM to let it generate images on its own:Parameters
Text description for image generation, or an edit instruction for image-to-image.
Output resolution.
Output orientation. Only applies to text-to-image generation.
Seed value for reproducible results.
Source image URL for image-to-image editing. When provided, the tool uses
lucy-pro-i2i instead of lucy-pro-t2i.Automatically enhance the prompt for better results.
Model selection
The tool selects the model automatically based on your input:| Input | Model | Mode |
|---|---|---|
prompt only | lucy-pro-t2i | Text-to-image generation |
prompt + imageUrl | lucy-pro-i2i | Image-to-image editing |
Constructor options
Decart API key. Defaults to the
DECART_API_KEY environment variable.Custom API base URL.
Next steps
Models overview
Explore all available Decart models.
JavaScript SDK
Use Decart’s native SDK for full API access.
GitHub
View source code and contribute.