Skip to main content

Class: OpenAIImageProvider

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:104

Implements​

Constructors​

Constructor​

new OpenAIImageProvider(): OpenAIImageProvider

Returns​

OpenAIImageProvider

Properties​

defaultModelId?​

optional defaultModelId: string

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:107

Implementation of​

IImageProvider.defaultModelId


isInitialized​

isInitialized: boolean = false

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:106

Implementation of​

IImageProvider.isInitialized


providerId​

readonly providerId: "openai" = 'openai'

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:105

Implementation of​

IImageProvider.providerId

Methods​

editImage()​

editImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:239

Edits an image using the OpenAI /v1/images/edits endpoint.

Supports both img2img (prompt-guided transformation) and inpainting (mask-guided regional editing). The endpoint expects multipart form data with the source image and an optional mask.

Parameters​

request​

ImageEditRequest

Edit request with source image buffer and prompt.

Returns​

Promise<ImageGenerationResult>

Generation result containing the edited image(s).

Throws​

When the provider is not initialised.

Throws​

When the API returns an HTTP error status.

See​

https://platform.openai.com/docs/api-reference/images/createEdit

Implementation of​

IImageProvider.editImage


generateImage()​

generateImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:138

Parameters​

request​

ImageGenerationRequest

Returns​

Promise<ImageGenerationResult>

Implementation of​

IImageProvider.generateImage


initialize()​

initialize(config): Promise<void>

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:112

Parameters​

config​

Record<string, unknown>

Returns​

Promise<void>

Implementation of​

IImageProvider.initialize


listAvailableModels()​

listAvailableModels(): Promise<ImageModelInfo[]>

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:429

Returns​

Promise<ImageModelInfo[]>

Implementation of​

IImageProvider.listAvailableModels


styleTransferModel()​

styleTransferModel(modelId): string

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:283

The model a style transfer runs on for modelId, or a refusal. An empty id takes the configured default when it is one of OPENAI_STYLE_TRANSFER_MODELS, else Sunburst. A named model must be one of them, unless the provider's base URL is not OpenAI's: a custom endpoint may serve any name.

Parameters​

modelId​

string

The model the call names, or an empty string.

Returns​

string

Throws​

For a model the style transfer does not run.

Implementation of​

IImageProvider.styleTransferModel


transferStyle()​

transferStyle(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:311

Restyles an image after a style reference through /v1/images/edits, which takes "up to 16 images" for the GPT Image models (openai-node, src/resources/images.ts): the source and the reference go as two image[] parts, the source first, with an instruction that names them.

The endpoint has no strength, seed or negative prompt: strength picks the instruction (see styleTransfer.ts), and the others are not sent. Before the request, the images are checked to be PNG, WebP or JPEG files under 50 MB each, and the prompt as sent to be at most 32,000 characters.

Parameters​

request​

ImageStyleTransferRequest

The source, the reference and the prompt.

Returns​

Promise<ImageGenerationResult>

Generation result with the restyled image(s).

Throws​

When the provider is not initialised, the model, an image or the prompt is refused, the API returns an HTTP error status, or the answer holds no image.

Implementation of​

IImageProvider.transferStyle


variateImage()​

variateImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/OpenAIImageProvider.ts:418

Makes variations of an image through the /v1/images/edits endpoint, with a GPT image model and a prompt that asks for a variation. OpenAI retired /v1/images/variations and the DALL·E models it served: "Use the image edits endpoint with a GPT Image model and a prompt to create a variation of an image" (openai-node, src/resources/images.ts).

The edits endpoint has no strength parameter, so variance picks the prompt: below 0.5 asks for a close variation, otherwise a looser one.

Parameters​

request​

ImageVariateRequest

Variation request with the source image buffer.

Returns​

Promise<ImageGenerationResult>

Generation result containing the variation image(s).

Throws​

When the provider is not initialised.

Throws​

When the API returns an HTTP error status.

See​

https://github.com/openai/openai-node/blob/master/src/resources/images.ts

Implementation of​

IImageProvider.variateImage