Skip to content

Media AI: overview

The background on a product photo is wrong, and your editor wants to fix it in the admin. On the image’s edit page they choose Doctor image, which asks your image service to improve the photo, remove its background or an object, restore it or enlarge it. The work runs in the background.

The original always stays. A media library upload gains the edit as a new image beside it. In a one-image place, such as a page’s main image or the site logo, the editor finds the edit in the media library and uploads it there.

Media AI doesn’t include an image-editing service or a key for one. Your developer must connect your own service that accepts Media AI’s request and switch the feature on. Until then Doctor image is unavailable and says why. That service receives the image, the task, the editor’s instructions and the admin language.

Each editor can use it only on images they may edit, by default ten times an hour per image. Returned alt text or a caption is saved on the original, not the edit. Existing text stays unless the editor chooses otherwise. Batches start from the command line, never on a schedule or at upload.

When a job finishes, the editor gets a notification, linking to the result when it worked.

Media AI adds a queued Doctor image action to image records. It can improve, remove a background or named object, restore, or upscale an image. A provider may also return localised alt text and a caption. Generated image output is attached as a new media item, while the original file is preserved.

The package ships with no provider configured and makes no AI requests by default. Doctor image shows as unavailable, with the reason on hover, and media-ai:doctor-batch refuses to queue anything, until a provider is available. Media AI includes a first-party HTTP image editing provider. To turn it on, install AI Orchestrator and set:

  • CAPELL_MEDIA_AI_IMAGE_DOCTOR=ai_orchestrator
  • CAPELL_MEDIA_AI_IMAGE_PROVIDER=http
  • CAPELL_MEDIA_AI_IMAGE_PROVIDER_ENDPOINT, an https:// URL with no credentials in it
  • CAPELL_MEDIA_AI_IMAGE_PROVIDER_ALLOWED_HOSTS, a comma-separated list that must contain the endpoint’s host
  • CAPELL_MEDIA_AI_IMAGE_PROVIDER_KEY, sent as a bearer token

When all of these are valid, Media AI registers the media-ai / doctor-image capability with AI Orchestrator itself. If any is missing or invalid, the capability is not registered and Doctor image stays unavailable. The provider call never follows a redirect, uses a 5-second connect timeout and a 60-second request timeout, refuses source images over 10 MB and responses over 20 MB. All of these limits are configurable. The endpoint must accept a JSON POST with operation, instructions, locale, model and image.mime_type / image.base64, and answer with JSON containing any of alt_text, caption, image_base64 and image_mime_type. Each request carries an Idempotency-Key header that stays the same when the queued job is retried. Media AI retries only when the connection could not be opened, so the request never left Capell; a timeout after sending, any error response, or an unreadable or oversized response is not retried, because the provider may already have charged for it. The editor is told the request did not complete. Whether a given provider honours the idempotency key has not been verified. Capell’s tests exercise this contract against a faked endpoint; no live provider has been called, so confirm the request and response format with your provider and a real key before relying on it. A different provider can be bound to the Capell\MediaAI\Contracts\ImageEditingProvider contract instead. There is no Media AI settings screen; enablement, provider, rate limit, model hints, output limit and batch size come from capell-media-ai configuration.

Keep a queue worker running. Every admin and batch request dispatches an encrypted, unique job; the image is not processed in the browser request. The default job timeout is 120 seconds with two attempts.

Open an image in the Media Library and select Doctor image. The action appears for image media you can update. It is unavailable, with the reason on hover, until a provider is configured. Choose an operation, give precise instructions, and submit it. The default limit is ten submissions per account and media item per hour; the warning tells you when that window becomes available again.

The completion notification means the provider job finished and its accepted output was applied. Review all generated content:

  • Returned alt text and captions are written to the original media translation for the request locale, falling back to an available language when necessary. By default they only fill fields that are empty; existing values are kept. When replacement is selected, existing values are replaced. Every write keeps the previous values on the media record and adds an activity-log entry naming the user who started the request. An operator can put a replaced value back with the media-ai:restore-metadata operator command. The restore is refused when the field was edited after the change, so later edits are never lost. Queued requests created before this change keep existing values.
  • Returned image bytes create a separate item on the same disk. For an ordinary collection it joins the same collection. For a one-image place (a collection with a size limit, such as a page’s main image or a site logo) it goes to the owner’s capell-media-ai-edits collection instead, because the media library would otherwise delete the original to make room. The new item records its source media ID and collection, operation, locale, and generation time. The original image is never replaced or removed.
  • Image output is ignored unless its declared and detected type agree, it is JPEG, PNG, WebP, or GIF, and it is within the configured size limit (10 MB by default). Valid metadata can still be applied when image output is rejected.

media-ai:doctor-batch --actor=<user-id> is an operator command for queued bulk work. It checks the actor’s media permission for each image’s site, refuses before queueing anything when no provider is configured, and by default selects the oldest image records missing alt text in the requested locale and queues at most 50. An explicit --limit is capped at 100. Each actor can queue at most 500 requests in any 24 hours, and all actors together can queue at most 2,000 for images on one site; all three limits are configurable, and a quota of 0 switches batch work off. Set a lower --limit for the first run and inspect results before expanding it. Images that Image Doctor generated are skipped, so a batch never sends its own output back for another request. --all-images also includes images that already have alt text, but their existing alt text and captions are kept unless you also pass --overwrite-metadata. Replacements are recorded and can be restored with media-ai:restore-metadata. A queue worker is still required after the command reports how many jobs it queued.

For example, an operator can queue up to 25 English images missing alt text, using user 42’s current media permissions and asking for accurate alt text plus a concise catalogue caption.

The operational outcomes are queued while background work is pending, reviewable when a separate generated image is ready to inspect, applied when metadata was written, refused when no safe output could be applied, and failed when the provider could not complete the request and the queue retry policy applies.

The first-party HTTP provider receives only the operation, instructions, locale, model hint and the image bytes with their MIME type. Media IDs, names, owning records, file names and URLs are not sent. A custom AI Orchestrator module registered for doctor-image instead receives the media ID, type, size and a URL from which it can read the image. Public media uses its normal URL. Private media uses a temporary URL valid for five minutes; if the disk cannot issue one, no permanent URL is substituted. Raw storage disk names, paths, file names and media names are never sent.

Do not submit confidential imagery unless the configured AI provider’s storage and training terms are acceptable. Financial authorisation belongs to the consuming application and is not performed by Media AI. Media AI does not record what each request costs, so AI Spend Caps cannot count Image Doctor spend; its limits are request counts (per editor per image per hour, and daily batch allowances) and size caps.

Identical jobs for the same account, image, and request parameters are deduplicated for one hour. If the provider cannot be reached, the queued job throws and can run once more before entering the application’s failed-job handling. A provider failure after the request was sent is reported to the editor straight away and is not retried. After retries are exhausted, including a terminal timeout, the initiating editor receives one durable failure notification if they still have access to the unchanged source. It confirms that no result was applied and suggests reviewing the image and instructions before trying again or contacting the site administrator. Transient failures do not send a failure notice. Deleted or inaccessible sources produce no notice disclosing the image. Duplicate terminal callbacks are deduplicated for the same dispatch; a later deliberately submitted request has its own outcome. For already queued payloads without a dispatch identifier, the editor and request digest provide the compatibility fallback. A committed successful application suppresses a later failure notice. Media AI has no separate run-history screen. Operators can inspect the queue and application log to correct provider availability, credentials or image access. If an image was deleted before its job runs, the job exits without creating output.


For how to use Media AI, see the admin guide. For developers: see the README.