View Source OpenaiEx.Image (openai_ex v0.2.1)

This module provides an implementation of the OpenAI images API. The API reference can be found at https://platform.openai.com/docs/api-reference/images.

api-fields

API Fields

The following fields can be used as parameters when creating a new image:

  • :prompt
  • :n
  • :size
  • :response_format
  • :user

Link to this section Summary

Functions

Calls the image generation endpoint.

Calls the image edit endpoint.

Calls the image variation endpoint.

Creates a new image request with the given arguments.

Link to this section Functions

Calls the image generation endpoint.

arguments

Arguments

  • openai: The OpenAI configuration to use.
  • image: The image request to send.

returns

Returns

A map containing the response from the OpenAI API.

See the OpenAI API Create Image reference for more information.

Link to this function

create_edit(openai, image_edit)

View Source

Calls the image edit endpoint.

arguments

Arguments

  • openai: The OpenAI configuration to use.
  • image_edit: The image edit request to send.

returns

Returns

A map containing the response from the OpenAI API.

See the OpenAI API Create Image Edit reference for more information.

Link to this function

create_variation(openai, image_variation)

View Source

Calls the image variation endpoint.

arguments

Arguments

  • openai: The OpenAI configuration to use.
  • image_variation: The image variation request to send.

returns

Returns

A map containing the response from the OpenAI API.

See the OpenAI API Create Image Variation reference for more information.

Creates a new image request with the given arguments.

arguments

Arguments

  • args: A list of key-value pairs, or a map, representing the fields of the image request.

returns

Returns

A map containing the fields of the image request.

The :prompt field is required.

Example usage:

iex> _request = OpenaiEx.Image.new(prompt: "This is a test")
%{prompt: "This is a test"}

iex> _request = OpenaiEx.Image.new(%{prompt: "This is a test"})
%{prompt: "This is a test"}