Docs menu

Generate images legacy

POST /v1/organisations/{organisation_id}/workspaces/{workspace_id}/apps/{app_id}/instances/{instance_id}/images Deprecated

Makes images from a description, optionally based on images in the space, with Google's or OpenAI's image model, and saves them to the space's "Generated images" folder, scanned like any upload.

Only the instance's own app token asks (the AI agents space's images app offers it to agents as a tool), and only a write app. The organisation's AI settings pick the model: a provider it allows, served in the EU while it keeps processing there; provider names one. The call runs on the installation's provider accounts and is billed in credits by the tokens the provider reports (source image_generation), within the plan's limits. The prompt is never logged.

Authentication

Send an API key, or an access token from your organisation’s identity provider, in the Authorization header. How API keys work

Scope the API key needs: files:write

Security schemes in the OpenAPI document: session_cookie (cookie __Host-ivy_session)bearer (bearer)api_key (bearer)

Parameters

  • organisation_id path string required
  • workspace_id path string required
  • app_id path string required
  • instance_id path string required

Request body

application/json ImageGenerationRequest required

  • count integer (int32) | null

    How many images, 1-4; one when absent.

    minimum 0

  • prompt string required

    What to draw: the subject, style, composition and any text the image shows; 1-4,000 characters.

  • provider AgentProvider | null
  • reference_images string[]

    Up to 4 file ids of PNG, JPEG or WebP images in the space to base the images on: a photo to edit or a style to follow.

  • size ImageShape | null

Responses

  • 200 application/json GeneratedImages

    The new image files, in the space's "Generated images" folder

  • 401 application/json ErrorBody

    unauthenticated

  • 402 application/json ErrorBody

    usage_limit_reached, billing_restricted, service_identity_limit_reached

  • 403 application/json ErrorBody

    insufficient_scope: only an app instance asks, with its own app token; forbidden: only a write app makes images, and only for a person who may add files to the space. no_image_provider: the organisation's AI settings allow no provider whose images this installation offers (in the EU while it keeps processing there). access_revoked: the app's principal lost access, or the space was archived, before the request ran

  • 404 application/json ErrorBody

    Not the token's organisation or space, or a reference image that isn't in it

  • 409 application/json ErrorBody

    file_scanning: a reference image has no version that passed the malware scan yet

  • 413 application/json ErrorBody

    storage_limit_reached: the organisation's storage has no room for the images (4 MB each), checked before the provider is called

  • 422 application/json ErrorBody

    validation_failed with the field and reason; image_refused: the provider's safety system declined the prompt, with its reason; unsupported_type, too_large: a reference image that isn't a PNG, JPEG or WebP of at most 20 MB

  • 429 application/json ErrorBody

    rate_limited: the instance's requests per minute

  • 500 application/json ErrorBody

    internal

  • 502 application/json ErrorBody

    image_failed: the provider failed

  • 503 application/json ErrorBody

    images_unavailable: this installation makes no images, the provider is busy, or it didn't answer in time; or unavailable: the database is briefly unavailable; retry after Retry-After seconds

Error codes

Errors come back as an ErrorBody whose code is one of these.

  • 401 unauthenticated
  • 402 usage_limit_reachedbilling_restrictedservice_identity_limit_reached
  • 403 insufficient_scopeforbidden
  • 404 not_found generic code for this status
  • 409 file_scanning
  • 413 storage_limit_reached
  • 422 validation_failedimage_refusedunsupported_typetoo_large
  • 429 rate_limited
  • 500 internal
  • 502 image_failed
  • 503 images_unavailableunavailable

Examples

curl
curl -X POST "$IVY_API_URL/v1/organisations/$ORGANISATION_ID/workspaces/$WORKSPACE_ID/apps/$APP_ID/instances/$INSTANCE_ID/images" \
  -H "Authorization: Bearer $IVY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"string"}'
JavaScript SDK
import { client, generateImagesLegacy } from "@spacivapp/ivy-sdk";

client.setConfig({
  baseUrl: process.env.IVY_API_URL,
  headers: { Authorization: `Bearer ${process.env.IVY_API_KEY}` },
});

const { data, error, response } = await generateImagesLegacy({
  path: { organisation_id: organisationId, workspace_id: workspaceId, app_id: appId, instance_id: instanceId },
  body: {
    prompt: "string"
  },
});
Example request body
{
  "count": 0,
  "prompt": "string",
  "provider": "anthropic",
  "reference_images": [
    "string"
  ],
  "size": "square"
}
Example response (200)
{
  "images": [
    {
      "file_id": "file_123",
      "name": "Ada Lovelace",
      "path": "string"
    }
  ],
  "model": "string"
}