---
title: "Make a picture with AI from a description (Build Credits); only where AI pictures are configured"
method: POST
path: "/builder/sessions/{sessionId}/assets/generate"
tags: ["Builder"]
---

# Make a picture with AI from a description (Build Credits); only where AI pictures are configured

`POST /builder/sessions/{sessionId}/assets/generate`

## Request

- Base URL: `https://hostingsurge.com/api/v1`
- URL: `https://hostingsurge.com/api/v1/builder/sessions/{sessionId}/assets/generate`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `__Host-hs_session`

## Path parameters

- `sessionId` string, uuid, required

## Request body

- object
  - `prompt` string, required
  - `alt` string
  - `shape` 'square' | 'landscape' | 'portrait'

## Response `201`

Stored

- object
  - `uploadId` string, uuid, required
  - `src` string, required: The picture's address on the site, e.g. /assets/team-3f2a9c1d.webp
  - `width` integer, required
  - `height` integer, required
  - `alt` string, nullable, required
  - `source` 'upload' | 'openverse' | 'ai', required
  - `license` object, nullable, required
  - `variants` object[], required
    - `src` string, required
    - `width` integer, required
  - `createdAt` string, required: ISO-8601 timestamp

## Other responses

- `400`: Invalid request (code invalid_request; details.reason: invalid, unmappable, not_found, secret_detected, unsupported, too_large, unreadable)
- `401`: Missing or invalid session/token (code unauthorized)
- `402`: No Build Credits left (code limit_reached)
- `403`: Authenticated but not permitted (code forbidden)
- `404`: Not found or not visible to the caller (code not_found)
- `409`: Refused for now (code conflict; details.reason: turn_running while the AI changes the site, stale when the files changed since the editor loaded them (details.version: the current one), previewing_version, archived, in_use)
- `429`: Too many changes at once (code rate_limited); see Retry-After
- `501`: Not available on this server (code not_configured)

---

[API](https://skmtc.dev/hostingsurge/apis/hostingsurge-platform-api.md) · [All operations](https://skmtc.dev/hostingsurge/apis/hostingsurge-platform-api/llms.txt) · [OpenAPI document](https://skmtc.dev/hostingsurge/apis/hostingsurge-platform-api/revisions/4d08337cdff1?raw)
