Skip to content

Latest commit

 

History

History
298 lines (242 loc) · 8.01 KB

File metadata and controls

298 lines (242 loc) · 8.01 KB
external help file PSOpenAI-help.xml
Module Name PSOpenAI
online version https://github.com/mkht/PSOpenAI/blob/main/Docs/Request-ImageGeneration.md
schema 2.0.0

Request-ImageGeneration

SYNOPSIS

Creates an image given a prompt.

SYNTAX

Request-ImageGeneration
    [-Prompt] <String>
    [-Model <String>]
    [-NumberOfImages <UInt16>]
    [-Size <String>]
    [-Quality <String>]
    [-Style <String>]
    [-Background <String>]
    [-Moderation <String>]
    [-OutputCompression <UInt16>]
    [-OutputFormat <String>]
    [-ResponseFormat <String>]
    [-OutputRawResponse]
    [-User <String>]
    [-TimeoutSec <Int32>]
    [-MaxRetryCount <Int32>]
    [-ApiBase <Uri>]
    [-ApiKey <Object>]
    [-Organization <String>]
    [<CommonParameters>]
Request-ImageGeneration
    [-Prompt] <String>
    -OutFile <String>
    [-Model <String>]
    [-NumberOfImages <UInt16>]
    [-Size <String>]
    [-Quality <String>]
    [-Style <String>]
    [-Background <String>]
    [-Moderation <String>]
    [-OutputCompression <UInt16>]
    [-OutputFormat <String>]
    [-User <String>]
    [-TimeoutSec <Int32>]
    [-MaxRetryCount <Int32>]
    [-ApiBase <Uri>]
    [-ApiKey <Object>]
    [-Organization <String>]
    [<CommonParameters>]

DESCRIPTION

Creates an image given a prompt.
https://developers.openai.com/api/reference/resources/images/methods/generate

EXAMPLES

Example 1: Creates and save an image from prompt.

Request-ImageGeneration -Model 'gpt-image-1' -Prompt 'A cute baby lion' -OutFile C:\babylion.png

lion

Example 2: Creates multiple images at once, and retrieve results by URL.

Request-ImageGeneration -Model 'dall-e-3' -Prompt 'Delicious ramen with gyoza' -Model -ResponseFormat 'url' -NumberOfImages 3
https://oaidalleapiprodscus.blob.core.windows.net/private/org-BXLtGIt0xglP9if8FVhkD...
https://oaidalleapiprodscus.blob.core.windows.net/private/org-BXLtGIt0xglP9if8FVhkD...
https://oaidalleapiprodscus.blob.core.windows.net/private/org-BXLtGIt0xglP9if8FVhkD...

PARAMETERS

-Prompt

(Required) A text description of the desired image(s). The maximum length is 32000 characters for the GPT image models, 1000 characters for dall-e-2 and 4000 characters for dall-e-3.

Type: String
Required: True
Position: 1
Accept pipeline input: True (ByValue)

-Model

The model to use for image generation. One of dall-e-2, dall-e-3, or a GPT image model. Defaults to dall-e-2 unless a parameter specific to the GPT image models is used.

Type: String
Required: False
Position: Named
Default value: dall-e-2

-NumberOfImages

The number of images to generate. Must be between 1 and 10. For dall-e-3, only 1 is supported.

Type: UInt16
Aliases: n
Required: False
Position: Named
Default value: 1

-Size

The size of the generated images. Must be one of 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), or auto (default value) for the GPT image models, one of 256x256, 512x512, or 1024x1024 for dall-e-2, and one of 1024x1024, 1792x1024, or 1024x1792 for dall-e-3.

Type: String
Required: False
Position: Named
Default value: auto

-Quality

The quality of the image that will be generated.

  • auto (default value) will automatically select the best quality for the given model.
  • high, medium and low are supported for the GPT image models.
  • hd and standard are supported for dall-e-3.
  • standard is the only option for dall-e-2.
Type: String
Required: False
Position: Named
Default value: auto

-Style

The style of the generated images. Must be one of vivid or natural. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for dall-e-3.

Type: String
Required: False
Position: Named
Default value: vivid

-Background

Allows to set transparency for the background of the generated image(s). This parameter is only supported for the GPT image models. Must be one of transparent, opaque or auto (default value). When auto is used, the model will automatically determine the best background for the image.

Type: String
Required: False
Position: Named

-Moderation

Control the content-moderation level for images generated by the GPT image models. Must be either low for less restrictive filtering or auto (default value).

Type: String
Required: False
Position: Named

-OutputCompression

The compression level (0-100%) for the generated images. This parameter is only supported for the GPT image models with the webp or jpeg output formats, and defaults to 100.

Type: UInt16
Aliases: output_compression
Required: False
Position: Named

-OutputFormat

The format in which the generated images are returned. This parameter is only supported for the GPT image models. Must be one of png, jpeg, or webp.

Type: String
Aliases: output_format
Required: False
Position: Named

-ResponseFormat

The format in which the generated images are returned. Must be one of url, base64 or byte. This parameter is only supported for dall-e-2, as the GPT image models always return images in base64 format.

Type: String
Parameter Sets: Format
Aliases: response_format
Required: False
Position: Named
Default value: url

-OutputRawResponse

If specifies this switch, an output of this function to be a raw response value from the API. (Normally JSON formatted string.)

Type: SwitchParameter
Parameter Sets: Format
Required: False
Position: Named

-OutFile

Specify the file path where the generated images will be saved. This cannot be specified with the ResponseFormat parameter.

Type: String
Parameter Sets: OutFile
Required: True
Position: Named

-User

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.

Type: String
Required: False
Position: Named

-TimeoutSec

Specifies how long the request can be pending before it times out. The default value is 0 (infinite).

Type: Int32
Required: False
Position: Named
Default value: 0

-MaxRetryCount

Number between 0 and 100.
Specifies the maximum number of retries if the request fails.
The default value is 0 (No retry).
Note : Retries will only be performed if the request fails with a 429 (Rate limit reached) or 5xx (Server side errors) error. Other errors (e.g., authentication failure) will not be performed.

Type: Int32
Required: False
Position: Named
Default value: 0

-ApiBase

Specifies an API endpoint URL such like: https://your-api-endpoint.test/v1
If not specified, it will use https://api.openai.com/v1

Type: System.Uri
Required: False
Position: Named
Default value: https://api.openai.com/v1

-ApiKey

Specifies API key for authentication.
The type of data should [string] or [securestring].
If not specified, it will try to use $global:OPENAI_API_KEY or $env:OPENAI_API_KEY

Type: Object
Required: False
Position: Named

-Organization

Specifies Organization ID which used for an API request.
If not specified, it will try to use $global:OPENAI_ORGANIZATION or $env:OPENAI_ORGANIZATION

Type: string
Aliases: OrgId
Required: False
Position: Named

INPUTS

OUTPUTS

NOTES

RELATED LINKS

https://developers.openai.com/api/docs/guides/image-generation/

https://developers.openai.com/api/reference/resources/images/methods/generate