import { t as OpenAIImageModel } from "./models-D-Wcs-FO.mjs"; import { t as OpenAiRegion } from "./region-DNmR5OQo.mjs"; import { Context, Effect, Layer, Redacted, Schema, Stream } from "effect"; import { ImageBase64Source, ImageBytesSource } from "@effect-uai/core/Image"; import { CommonImageEditRequest, CommonImageGenerateRequest, CommonStreamImageRequest, ImageGenerator, ImageResponse, ImageStreamEvent, ImageStreaming } from "@effect-uai/core/ImageGenerator"; import { HttpClient } from "effect/http"; import * as AiError from "@effect-uai/core/AiError"; import * as SSE from "@effect-uai/core/SSE"; declare namespace OpenAIImageGenerator_d_exports { export { Config, OpenAIImageEditRequest, OpenAIImageGenerateRequest, OpenAIImageGenerator, OpenAIImageGeneratorService, OpenAIImageRef, OpenAIStreamImageEditRequest, OpenAIStreamImageRequest, WireBody, decodeImagesResponse, editForm, generateBody, imageHttpError, imageStreamError, layer, make, sizeOf, streamBody, streamEditForm, streamEventOf, toResponse }; } /** Wire knobs shared by `/images/generations` and `/images/edits`. */ type OpenAIImageKnobs = { /** * Exact `"WxH"` or `"auto"`. Takes precedence over `aspectRatio` and * `resolution`, which are then warn-dropped. */ readonly size?: string; readonly quality?: "low" | "medium" | "high" | "auto"; /** `"transparent"` requires a png or webp `outputFormat`. */ readonly background?: "transparent" | "opaque" | "auto"; readonly outputFormat?: "png" | "jpeg" | "webp"; /** 0..100, jpeg and webp only. */ readonly outputCompression?: number; readonly moderation?: "low" | "auto"; }; type OpenAIImageGenerateRequest = Omit & { readonly model: OpenAIImageModel; } & OpenAIImageKnobs; /** * Reference images for an edit. Narrowed off `ImageSource`: the endpoint's * multipart body uploads bytes, so a `url` variant has no wire * representation here and is a compile-time error rather than a 400. * Fetch it yourself and pass the bytes. */ type OpenAIImageRef = ImageBase64Source | ImageBytesSource; type OpenAIImageEditRequest = Omit & { readonly model: OpenAIImageModel; readonly images: ReadonlyArray; } & OpenAIImageKnobs & { /** PNG with an alpha channel, same dimensions as `images[0]`, which it applies to. */ readonly mask?: OpenAIImageRef; }; type OpenAIStreamImageRequest = Omit & { readonly model: OpenAIImageModel; } & OpenAIImageKnobs; type OpenAIStreamImageEditRequest = OpenAIImageEditRequest & { readonly partialImages: 1 | 2 | 3; }; type OpenAIImageGeneratorService = { readonly generate: (request: OpenAIImageGenerateRequest) => Effect.Effect; readonly edit: (request: OpenAIImageEditRequest) => Effect.Effect; readonly streamGeneration: (request: OpenAIStreamImageRequest) => Stream.Stream; readonly streamEdit: (request: OpenAIStreamImageEditRequest) => Stream.Stream; }; declare const OpenAIImageGenerator_base: Context.ServiceClass; /** * Provider-typed service tag. Yield this for exact pixel sizes, quality * tiers, transparency, and masks; yield the generic `ImageGenerator` tag * for provider-portable code. Both are registered by `layer`. */ declare class OpenAIImageGenerator extends OpenAIImageGenerator_base {} type Config = { readonly apiKey: Redacted.Redacted; readonly baseUrl?: string; readonly region?: OpenAiRegion; }; /** * Derive `"WxH"` from the portable ratio and tier. `undefined` means * "send no size" and let the endpoint pick. */ declare const sizeOf: (request: Pick) => Effect.Effect; type WireBody = { readonly prompt: string; readonly model: string; readonly n?: number; readonly size?: string; readonly quality?: string; readonly background?: string; readonly output_format?: string; readonly output_compression?: number; readonly moderation?: string; readonly stream?: boolean; readonly partial_images?: number; }; declare const generateBody: (request: OpenAIImageGenerateRequest) => Effect.Effect; /** * Multipart edit body. The endpoint also documents a JSON variant taking * `images[]` as URL or data-URL references, but it is not universally * served: Azure-backed routes validate against this schema and reject the * JSON one with "Missing required parameter: 'image'". Multipart works * everywhere, so it is the only variant sent. * * References upload as repeated `image[]` parts, so they must be inline * bytes; a URL source fails `InvalidRequest`. */ declare const editForm: (request: OpenAIImageEditRequest) => Effect.Effect; /** The edit form plus the two streaming fields, which multipart sends as strings. */ declare const streamEditForm: (request: OpenAIStreamImageEditRequest) => Effect.Effect; declare const streamBody: (request: OpenAIStreamImageRequest) => Effect.Effect; declare const WireImagesResponse: Schema.Struct<{ readonly created: Schema.optional; readonly data: Schema.$Array; readonly url: Schema.optional; readonly revised_prompt: Schema.optional; }>>; readonly output_format: Schema.optional; readonly usage: Schema.optional; readonly output_tokens: Schema.optional; readonly total_tokens: Schema.optional; }>>; }>; type WireImagesResponse = typeof WireImagesResponse.Type; declare const decodeImagesResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{ readonly created?: number | undefined; readonly data: readonly { readonly b64_json?: string | undefined; readonly url?: string | undefined; readonly revised_prompt?: string | undefined; }[]; readonly output_format?: string | undefined; readonly usage?: { readonly input_tokens?: number | undefined; readonly output_tokens?: number | undefined; readonly total_tokens?: number | undefined; } | undefined; }, Schema.SchemaError, never>; declare const toResponse: (wire: WireImagesResponse, requested: OpenAIImageKnobs["outputFormat"]) => Effect.Effect; /** Never fails: the returned error is the value. */ declare const imageHttpError: (status: number, body: string) => Effect.Effect; /** * An error frame mid-stream. The HTTP status was 200, so the status * mapping has nothing to say and a non-moderation failure is one the * model hit while generating. */ declare const imageStreamError: (body: string) => Effect.Effect; /** * Decode one SSE frame. Frames this capability has no representation for * decode to `undefined` and are dropped, so a new event type on the wire * does not break the stream. */ declare const streamEventOf: (event: SSE.Event, requested: OpenAIImageKnobs["outputFormat"]) => Effect.Effect; declare const make: (cfg: Config) => Effect.Effect; /** * Layer registering the provider-typed tag, the generic `ImageGenerator`, * and the `ImageStreaming` marker. A `CommonImageGenerateRequest` is * structurally an `OpenAIImageGenerateRequest` with no vendor knobs set, * so the generic registration forwards directly. * * `baseUrl` retargets the same wire protocol at an OpenAI-compatible * gateway. Whether such a gateway honours partial images is not this * Layer's promise; the marker is registered for the models it routes to. */ declare const layer: (cfg: Config) => Layer.Layer; //#endregion export { Config, OpenAIImageEditRequest, OpenAIImageGenerateRequest, OpenAIImageGenerator, OpenAIImageGeneratorService, OpenAIImageRef, OpenAIStreamImageEditRequest, OpenAIStreamImageRequest, WireBody, decodeImagesResponse, editForm, generateBody, imageHttpError, imageStreamError, layer, make, sizeOf, streamBody, streamEditForm, streamEventOf, OpenAIImageGenerator_d_exports as t, toResponse }; //# sourceMappingURL=OpenAIImageGenerator.d.mts.map