Skip to Content
Create Bulk Images

Create Images from Templates (Bulk)

Send a POST request to this endpoint to create multiple images at once using multiple templates.

You will need to authenticate to use this API. See authentication.

This endpoint consumes 1 credit per image generated in the batch. For example, requesting 10 image variations will consume 10 credits. They are spent when the batch starts, and an image that fails costs nothing: its credit is refunded.

Request

POST https://api.ojo.so/v1/image/bulk

Request Body

ParameterTypeDescription
templatesarrayArray of template objects to generate images from
defaultOptionsobject(Optional) Default options to apply to all templates unless overridden
strictboolean(Optional) When true, answers 422 with every image’s warnings before any image is rendered or charged

A field the API does not know, at the top level, in defaultOptions or in a template object, is ignored and listed in the response’s top-level warnings, such as templates[0]: unknown field `modifcations` was ignored. With strict, it answers 422 instead.

Template Object

ParameterTypeDescription
templateIdstringThe ID of the template to use
modificationsarrayArray of objects containing variables to modify in the template for each image
modifyobject or arrayInstead of modifications: the variables for one image, or an array as modifications. Send one of the two
viewportHeightnumber(Optional) Height of the viewport in pixels (overrides defaultOptions)
viewportWidthnumber(Optional) Width of the viewport in pixels (overrides defaultOptions)
transparentBackgroundboolean(Optional) When true, generates images with transparent backgrounds (overrides defaultOptions)

DefaultOptions Object

ParameterTypeDescription
viewportHeightnumber(Optional) Default height of the viewport in pixels (default: 800)
viewportWidthnumber(Optional) Default width of the viewport in pixels (default: 1280)
transparentBackgroundboolean(Optional) Default transparent background setting (default: false)
curl --request POST \ --url https://api.ojo.so/v1/image/bulk \ --header 'Authorization: Bearer <your API key>' \ --header 'Content-Type: application/json' \ --data '{ "defaultOptions": { "viewportWidth": 1200, "viewportHeight": 630, "transparentBackground": false }, "templates": [ { "templateId": "product-card-template", "modifications": [ { "title": "Premium Headphones", "price": "$199.99", "color": "#FF5733" }, { "title": "Wireless Earbuds", "price": "$89.99", "color": "#33FF57" } ] }, { "templateId": "social-post-template", "viewportHeight": 1080, "viewportWidth": 1080, "modifications": [ { "heading": "Summer Sale", "tagline": "Up to 50% off", "bgColor": "#3357FF" } ] } ] }'

Response

Your images are generated. An image that failed to generate is listed in errors with its reason, and the others are returned. errors is left out when every image was generated.

{ "images": [ { "id": "image-id-1", "templateId": "product-card-template", "imageUrl": "https://example.com/path/to/image1.png", "createdAt": "2023-08-29T12:34:56Z" }, { "id": "image-id-3", "templateId": "social-post-template", "imageUrl": "https://example.com/path/to/image3.png", "createdAt": "2023-08-29T12:34:58Z" } ], "errors": [ { "templateId": "product-card-template", "modify": { "title": "Wireless Earbuds", "price": "$89.99", "color": "#33FF57" }, "error": "Failed to generate image", "logs": ["Error detail information"] } ], "totalRequested": 3, "successCount": 2, "failureCount": 1 }

Limitations

  • Maximum Batch Size: You can generate up to 50 images in a single batch request across all templates combined.
  • Rendered HTML: at most 5 MB per image and 25 MB for the whole request. A larger request gets a 422 before anything renders.
  • Partial results: an image that fails or is not done within 90 seconds is listed in errors with its reason. The other images are returned. Only they cost credits, and each failed image costs nothing.
  • Credit Consumption: Each image generated in the batch consumes 1 credit.
  • Rate Limiting: Bulk requests are subject to the same rate limits as individual requests. See rate limits for details.