DallEAPIWrapper#

class langchain_community.utilities.dalle_image_generator.DallEAPIWrapper[source]#

Bases: BaseModel

Wrapper for OpenAI’s DALL-E Image Generator.

https://platform.openai.com/docs/guides/images/generations?context=node

Usage instructions:

  1. pip install openai

  2. save your OPENAI_API_KEY in an environment variable

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param default_headers: Mapping[str, str] | None = None#
param default_query: Mapping[str, object] | None = None#
param http_client: Any | None = None#

Optional httpx.Client.

param max_retries: int = 2#

Maximum number of retries to make when generating.

param model_kwargs: Dict[str, Any] [Optional]#
param model_name: str = 'dall-e-2' (alias 'model')#
param n: int = 1#

Number of images to generate

param openai_api_base: str | None = None (alias 'base_url')#

Base URL path for API requests, leave blank if not using a proxy or service emulator.

param openai_api_key: str | None = None (alias 'api_key')#

Automatically inferred from env var OPENAI_API_KEY if not provided.

param openai_organization: str | None = None (alias 'organization')#

Automatically inferred from env var OPENAI_ORG_ID if not provided.

param openai_proxy: str | None = None#
param quality: str | None = 'standard'#

Quality of the image that will be generated

param request_timeout: float | Tuple[float, float] | Any | None = None (alias 'timeout')#
param separator: str = '\n'#

Separator to use when multiple URLs are returned.

param size: str = '1024x1024'#

Size of image to generate

run(query: str) β†’ str[source]#

Run query through OpenAI and parse result.

Parameters:

query (str) –

Return type:

str

Examples using DallEAPIWrapper