AiImage.h header
#include <ew/app/AiImage.h>
Namespace ew::app
AiImageRequest struct
struct ew::app::AiImageRequest
A request to an image-generation model: the text prompt, the model name, and an optional size ("1024x1024", etc.). Provider-agnostic – any endpoint speaking the OpenAI-compatible images/generations shape consumes it. The model comes from settings, never hard-coded.
Members
QString ew::app::AiImageRequest::prompt
The text prompt describing the image to generate.
QString ew::app::AiImageRequest::model
The image model to request (e.g. "dall-e-3", "gpt-image-1", a local model id).
QString ew::app::AiImageRequest::size
The requested size (e.g. "1024x1024"); empty leaves it to the provider's default.
AiImageResult struct
struct ew::app::AiImageResult
A generated image, or an error. On success exactly one of imageData (decoded bytes, when the provider returns base64) or url (when it returns a link to fetch) is set; ok distinguishes success from failure.
Members
bool ew::app::AiImageResult::ok = false
True when the model returned an image; false when the request errored.
QByteArray ew::app::AiImageResult::imageData
The decoded image bytes, when the provider returned base64 JSON (empty otherwise).
QString ew::app::AiImageResult::url
The image URL, when the provider returned a link instead of inline data (empty otherwise).
QString ew::app::AiImageResult::error
A human-readable error message (when not ok).
Functions
QString ew::app::buildImageRequestJson(const AiImageRequest &request)
Serializes request to an OpenAI-compatible images/generations request body (JSON), asking for one image as base64 so the result is self-contained. Pure and unit-testable – no network or key.
AiImageResult ew::app::parseImageResponseJson(const QString &json)
Parses an OpenAI-compatible images/generations response body json into an AiImageResult: on success the first image's decoded base64 data (preferred) or its URL; on an API error the error message; and a clear error when the body is malformed or empty. Pure and unit-testable.