# `LangChain.Images.ModelsLabImage`
[🔗](https://github.com/brainlid/langchain/blob/v0.9.3/lib/images/modelslab_image.ex#L1)

Represents the [ModelsLab Images API](https://docs.modelslab.com/image-generation/overview)
for text-to-image generation using Flux, SDXL, Stable Diffusion, and 10,000+
community fine-tuned models.

## Configuration

Set your API key in your application config:

    config :langchain, :modelslab_key, "your-api-key"

Or pass it directly when creating the struct:

    {:ok, ml_image} = ModelsLabImage.new(%{
      api_key: "your-api-key",
      prompt: "A cozy cabin in the woods at dusk"
    })

## Usage

    {:ok, ml_image} = LangChain.Images.ModelsLabImage.new(%{
      prompt: "A sunset over mountains in watercolor style",
      model: "flux",
      width: 1024,
      height: 1024
    })

    {:ok, images} = LangChain.Images.ModelsLabImage.call(ml_image)
    LangChain.Images.save_images({:ok, images}, "/tmp", "my_image_")

## Available models

- `"flux"` — High-quality photorealistic Flux model (default)
- `"flux-dev"` — Flux development variant
- `"sdxl"` — Stable Diffusion XL
- `"realistic-vision-v6"` — Photorealistic portraits
- `"dreamshaper-8"` — Artistic and creative styles
- `"anything-v5"` — Anime and illustration style
- Any community model ID from [modelslab.com/models](https://modelslab.com/models)

## API docs

- [ModelsLab text-to-image API](https://docs.modelslab.com/image-generation/overview)
- [Get API key](https://modelslab.com/dashboard/api-keys)

# `t`
[🔗](https://github.com/brainlid/langchain/blob/v0.9.3/lib/images/modelslab_image.ex#L99)

```elixir
@type t() :: %LangChain.Images.ModelsLabImage{
  api_key: term(),
  endpoint: term(),
  guidance_scale: term(),
  height: term(),
  model: term(),
  negative_prompt: term(),
  num_inference_steps: term(),
  prompt: term(),
  receive_timeout: term(),
  retry_count: term(),
  samples: term(),
  seed: term(),
  width: term()
}
```

# `call`
[🔗](https://github.com/brainlid/langchain/blob/v0.9.3/lib/images/modelslab_image.ex#L195)

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

Call the ModelsLab API and return generated images.

Returns `{:ok, [GeneratedImage.t()]}` on success or `{:error, reason}` on
failure.

# `for_api`
[🔗](https://github.com/brainlid/langchain/blob/v0.9.3/lib/images/modelslab_image.ex#L169)

```elixir
@spec for_api(t()) :: map()
```

Return the params formatted for a ModelsLab API request.

# `new`
[🔗](https://github.com/brainlid/langchain/blob/v0.9.3/lib/images/modelslab_image.ex#L127)

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

Build a new `ModelsLabImage` configuration.

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

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

Build a new `ModelsLabImage` configuration and return it or raise on error.

---

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