import type { FetchImpl, Model, Usage } from "@oh-my-pi/pi-catalog/types"; import type { ApiKey } from "../auth-retry.js"; import * as AIError from "../error/index.js"; import type { ImageContent } from "../types.js"; import type { GeneratedImage, ImageInput } from "./types.js"; export declare class ImageApiError extends AIError.ProviderHttpError { readonly name = "ImageApiError"; } export declare function emptyUsage(input?: number, output?: number, cost?: number): Usage; export declare function usageFromWire(value: unknown): Usage; export declare function imageBaseUrl(model: Model): string; export declare function modelHeaders(model: Model, signal?: AbortSignal): Promise>; export declare function errorMessage(rawText: string): string; export declare function parseImageApiResponse(model: Model, response: Response): Promise; /** Request URL, or a builder for routes that depend on the bearer (xAI's `XAI_BASE_URL` rule). */ type ImageRequestUrl = string | ((bearer: string) => string); export declare function postJson(options: { model: Model; url: ImageRequestUrl; body: unknown; apiKey: ApiKey; fetch: FetchImpl; signal?: AbortSignal; }): Promise; export declare function postMultipart(options: { model: Model; url: ImageRequestUrl; body: FormData; apiKey: ApiKey; fetch: FetchImpl; signal?: AbortSignal; }): Promise; export declare function decodeImageResponse(value: unknown, fetch: FetchImpl, signal?: AbortSignal): Promise<{ images: GeneratedImage[]; usage: Usage; }>; /** * Mime type of a base64 image, read from its header only. 64 base64 chars * decode to 48 bytes, past every magic number `parseImageMetadata` checks, so * multi-MB payloads are never fully decoded just to be labelled. */ export declare function sniffBase64ImageMimeType(base64: string): string | undefined; /** * Validate provider-bound image input without changing it. Accepts non-empty standard base64 * with canonical trailing bits and optional padding, and case-insensitive image MIME syntax * (RFC 6838 restricted names). Does not sniff the MIME type, decode image pixels, or enforce * provider-specific format support; data-URL transports additionally go through `toDataUrl`. * * @throws {AIError.ValidationError} If the base64 data or image MIME type is invalid. */ export declare function validateImageInput(image: ImageInput): void; /** * Encode validated image input as a base64 data URL. * * @throws {AIError.ValidationError} If the input is invalid or its MIME type cannot survive a data URL. */ export declare function toDataUrl(image: ImageInput): string; /** * Whether a MIME type survives a data URL intact: a raw `#` starts a URL fragment and * data-URL consumers leave a `%23` escape undecoded, so no data-URL transport preserves it. */ export declare function isDataUrlMimeType(mimeType: string): boolean; /** Whether a value is an embedded image with valid base64 data, MIME type, and detail. */ export declare function isEmbeddedImageContent(image: unknown): image is ImageContent; /** Convert one validated embedded image to a lowercase-MIME inline data URL. */ export declare function embeddedImageDataUrl(image: unknown): string; export declare function resolveOpenAIImageSize(aspectRatio?: string, imageSize?: string): string | undefined; export {};