View Source LangChain.Images.OpenAIImage (LangChain v0.3.0-rc.0)

Represents the OpenAI Images API endpoint for working with DALL-E-2 and DALL-E-3.

Parses and validates inputs for making a request from the OpenAI Image API.

Converts responses into more specialized LangChain data structures and provide functions for saving generated images.

Summary

Functions

Calls the OpenAI API passing the OpenAIImage struct with configuration.

Return the params formatted for an API request.

Setup a OpenAIImage client configuration.

Setup a OpenAIImage client configuration and return it or raise an error if invalid.

Types

@type t() :: %LangChain.Images.OpenAIImage{
  api_key: term(),
  endpoint: term(),
  model: term(),
  n: term(),
  prompt: term(),
  quality: term(),
  receive_timeout: term(),
  response_format: term(),
  size: term(),
  style: term(),
  user: term()
}

Functions

@spec call(t()) :: {:ok, [LangChain.Images.GeneratedImage.t()]} | {:error, String.t()}

Calls the OpenAI API passing the OpenAIImage struct with configuration.

When successful, it returns {:ok, generated_images} where that is a list of LangChain.Images.GeneratedImage structs.

@spec for_api(t()) :: %{required(atom()) => any()}

Return the params formatted for an API request.

@spec new(attrs :: map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Setup a OpenAIImage client configuration.

@spec new!(attrs :: map()) :: t() | no_return()

Setup a OpenAIImage client configuration and return it or raise an error if invalid.