# `LangChain.Images.OpenAIImage`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.11/lib/images/open_ai_image.ex#L1)

Represents the [OpenAI Images API
endpoint](https://platform.openai.com/docs/api-reference/images) 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.

# `t`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.11/lib/images/open_ai_image.ex#L86)

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

# `call`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.11/lib/images/open_ai_image.ex#L213)

```elixir
@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.

# `for_api`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.11/lib/images/open_ai_image.ex#L192)

```elixir
@spec for_api(t()) :: %{required(atom()) =&gt; any()}
```

Return the params formatted for an API request.

# `new`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.11/lib/images/open_ai_image.ex#L125)

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

Setup a OpenAIImage client configuration.

# `new!`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.11/lib/images/open_ai_image.ex#L138)

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
