Image Generation API Docs
One POST, and the finished image comes back in the response as PNG, JPEG, WebP or PDF. No webhooks, no polling. Set your key and a design ID, then run any snippet.
Every snippet here is the code our test harness runs against the live render service.
import os
import requests
API_KEY = os.environ["IMEJIS_API_KEY"]
DESIGN_ID = os.environ["IMEJIS_DESIGN_ID"]
BASE = os.environ.get("IMEJIS_RENDER_URL", "https://render.imejis.io")
HEADERS = {"dma-api-key": API_KEY, "Content-Type": "application/json"}
# Render one image. The response body IS the image — no polling, no webhook.
response = requests.post(
f"{BASE}/v1/{DESIGN_ID}",
headers=HEADERS,
json={
"headline.text": "Hello from Python",
"subtitle.text": "Rendered in one request",
},
)
response.raise_for_status()
with open("output.jpg", "wb") as f:
f.write(response.content)
print("single:", response.status_code, len(response.content), "bytes")const API_KEY = process.env.IMEJIS_API_KEY
const DESIGN_ID = process.env.IMEJIS_DESIGN_ID
const BASE = process.env.IMEJIS_RENDER_URL ?? "https://render.imejis.io"
const HEADERS = { "dma-api-key": API_KEY, "Content-Type": "application/json" }
// The size to render on a multi-size design; absent/"master" is the base.
const variation = process.env.IMEJIS_VARIATION_ID ?? "story"
// Render one image. The response body IS the image — no polling, no webhook.
const res = await fetch(`${BASE}/v1/${DESIGN_ID}`, {
method: "POST",
headers: HEADERS,
body: JSON.stringify({
"headline.text": "Hello from Node.js",
"subtitle.text": "Rendered in one request",
}),
})
if (!res.ok) throw new Error(`render failed: ${res.status}`)
const image = Buffer.from(await res.arrayBuffer())
console.log("single:", res.status, image.length, "bytes"): "${IMEJIS_API_KEY:?set IMEJIS_API_KEY}"
: "${IMEJIS_DESIGN_ID:?set IMEJIS_DESIGN_ID}"
BASE="${IMEJIS_RENDER_URL:-https://render.imejis.io}"
# Render one image. The response body IS the image, so -o writes the file.
curl -sS -o output.jpg -w 'single: %{http_code} %{size_download} bytes\n' \
-X POST "$BASE/v1/$IMEJIS_DESIGN_ID" \
-H "dma-api-key: $IMEJIS_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"headline.text":"Hello from cURL","subtitle.text":"Rendered in one request"}'package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
)
// A stored render (delivery=hosted or delivery=signed).
type stored struct {
URL string `json:"url"`
ExpiresAt string `json:"expiresAt"`
Format string `json:"format"`
File struct {
Size int `json:"size"`
} `json:"file"`
}
// One /bulk response: results in the order the items were sent.
type bulkResponse struct {
Results []struct {
Index int `json:"index"`
Format string `json:"format"`
URL string `json:"url"`
Error string `json:"error"`
} `json:"results"`
Summary map[string]int `json:"summary"`
}
func envOr(key, fallback string) string {
if v := os.Getenv(key); v != "" {
return v
}
return fallback
}
func apiKey() string { return os.Getenv("IMEJIS_API_KEY") }
func designID() string { return os.Getenv("IMEJIS_DESIGN_ID") }
func baseURL() string { return envOr("IMEJIS_RENDER_URL", "https://render.imejis.io") }
// The size to render on a multi-size design; "master"/absent is the base size.
func variationID() string { return envOr("IMEJIS_VARIATION_ID", "story") }
// render POSTs `body` to `path` with the render key and returns the response.
func render(path string, params url.Values, body any) *http.Response {
payload, err := json.Marshal(body)
if err != nil {
panic(err)
}
endpoint := baseURL() + path
if len(params) > 0 {
endpoint += "?" + params.Encode()
}
req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("dma-api-key", apiKey())
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
return res
}
// readAll drains a response body (the rendered image, or a JSON envelope).
func readAll(res *http.Response) []byte {
defer res.Body.Close()
out, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
return out
}
// save writes the rendered bytes to disk.
func save(name string, data []byte) {
if err := os.WriteFile(name, data, 0o644); err != nil {
panic(err)
}
}
// decode parses a JSON response envelope into `target`.
func decode(data []byte, target any) {
if err := json.Unmarshal(data, target); err != nil {
panic(err)
}
}
func main() {
// Render one image. The response body IS the image — no polling, no webhook.
res := render("/v1/"+designID(), nil, map[string]string{
"headline.text": "Hello from Go",
"subtitle.text": "Rendered in one request",
})
image := readAll(res)
save("output.jpg", image)
fmt.Println("single:", res.StatusCode, len(image), "bytes")
}<?php
$apiKey = getenv("IMEJIS_API_KEY");
$designId = getenv("IMEJIS_DESIGN_ID");
$base = getenv("IMEJIS_RENDER_URL") ?: "https://render.imejis.io";
/** POST $body to $path with the render key; returns [body, status, contentType]. */
function render(string $path, array $params = [], array $body = []): array
{
global $apiKey, $base;
$url = $base . $path . ($params ? "?" . http_build_query($params) : "");
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["dma-api-key: $apiKey", "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode($body),
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);
return [$response, $status, $type];
}
// Render one image. The response body IS the image — no polling, no webhook.
[$image, $status] = render("/v1/$designId", [], [
"headline.text" => "Hello from PHP",
"subtitle.text" => "Rendered in one request",
]);
file_put_contents("output.jpg", $image);
echo "single: $status " . strlen($image) . " bytes\n";const API_KEY = Deno.env.get("IMEJIS_API_KEY")
const DESIGN_ID = Deno.env.get("IMEJIS_DESIGN_ID")
const BASE = Deno.env.get("IMEJIS_RENDER_URL") ?? "https://render.imejis.io"
const HEADERS = { "dma-api-key": API_KEY, "Content-Type": "application/json" }
// The size to render on a multi-size design; absent/"master" is the base.
const variation = Deno.env.get("IMEJIS_VARIATION_ID") ?? "story"
// Render one image. The response body IS the image — no polling, no webhook.
const res = await fetch(`${BASE}/v1/${DESIGN_ID}`, {
method: "POST",
headers: HEADERS,
body: JSON.stringify({
"headline.text": "Hello from Node.js",
"subtitle.text": "Rendered in one request",
}),
})
if (!res.ok) throw new Error(`render failed: ${res.status}`)
const image = new Uint8Array(await res.arrayBuffer())
await Deno.writeFile("output.jpg", image)
console.log("single:", res.status, image.length, "bytes")const API_KEY = Bun.env.IMEJIS_API_KEY
const DESIGN_ID = Bun.env.IMEJIS_DESIGN_ID
const BASE = Bun.env.IMEJIS_RENDER_URL ?? "https://render.imejis.io"
const HEADERS = { "dma-api-key": API_KEY, "Content-Type": "application/json" }
// The size to render on a multi-size design; absent/"master" is the base.
const variation = Bun.env.IMEJIS_VARIATION_ID ?? "story"
// Render one image. The response body IS the image — no polling, no webhook.
const res = await fetch(`${BASE}/v1/${DESIGN_ID}`, {
method: "POST",
headers: HEADERS,
body: JSON.stringify({
"headline.text": "Hello from Node.js",
"subtitle.text": "Rendered in one request",
}),
})
if (!res.ok) throw new Error(`render failed: ${res.status}`)
const image = await res.arrayBuffer()
await Bun.write("output.jpg", image)
console.log("single:", res.status, image.byteLength, "bytes")import java.io.FileOutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
static final String API_KEY = System.getenv("IMEJIS_API_KEY");
static final String DESIGN_ID = System.getenv("IMEJIS_DESIGN_ID");
static final String BASE = envOr("IMEJIS_RENDER_URL", "https://render.imejis.io");
static final HttpClient CLIENT = HttpClient.newHttpClient();
static String envOr(String key, String fallback) {
String value = System.getenv(key);
return (value == null || value.isEmpty()) ? fallback : value;
}
/** The size to render on a multi-size design; absent/"master" is the base. */
static String variation() {
return envOr("IMEJIS_VARIATION_ID", "story");
}
/** POST a JSON body to `path` with the render key; returns the raw response. */
static HttpResponse<byte[]> render(String path, String query, String json)
throws Exception {
String url = BASE + path + (query.isEmpty() ? "" : "?" + query);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("dma-api-key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
return CLIENT.send(request, HttpResponse.BodyHandlers.ofByteArray());
}
static String encode(String value) {
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
/** Build a query string from alternating key/value pairs. */
static String query(String... pairs) {
StringBuilder out = new StringBuilder();
for (int i = 0; i < pairs.length; i += 2) {
if (i > 0) out.append('&');
out.append(encode(pairs[i])).append('=').append(encode(pairs[i + 1]));
}
return out.toString();
}
/**
* Pull one string field out of a JSON response. Any JSON library (Jackson,
* Gson) does this better — this keeps the samples dependency-free so they
* compile with nothing but the JDK.
*/
static String field(String json, String name) {
Matcher m = Pattern.compile("\"" + name + "\"\\s*:\\s*\"([^\"]*)\"").matcher(json);
return m.find() ? m.group(1) : "";
}
public static void main(String[] args) throws Exception {
// Render one image. The response body IS the image — no polling, no webhook.
HttpResponse<byte[]> res = render("/v1/" + DESIGN_ID, "",
"{\"headline.text\":\"Hello from Java\",\"subtitle.text\":\"Rendered in one request\"}");
try (FileOutputStream out = new FileOutputStream("output.jpg")) {
out.write(res.body());
}
System.out.println("single: " + res.statusCode() + " " + res.body().length + " bytes");
}
}using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Web;
var apiKey = Environment.GetEnvironmentVariable("IMEJIS_API_KEY")!;
var designId = Environment.GetEnvironmentVariable("IMEJIS_DESIGN_ID")!;
var baseUrl = Environment.GetEnvironmentVariable("IMEJIS_RENDER_URL")
?? "https://render.imejis.io";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("dma-api-key", apiKey);
// POST a JSON body to `path` with the render key.
async Task<HttpResponseMessage> Render(string path, string query, object body)
{
var url = baseUrl + path + (query.Length == 0 ? "" : "?" + query);
var content = new StringContent(
JsonSerializer.Serialize(body), Encoding.UTF8, "application/json");
return await client.PostAsync(url, content);
}
// Build a query string from alternating key/value pairs.
string Query(params string[] pairs)
{
var parts = new List<string>();
for (var i = 0; i < pairs.Length; i += 2)
{
parts.Add($"{HttpUtility.UrlEncode(pairs[i])}={HttpUtility.UrlEncode(pairs[i + 1])}");
}
return string.Join("&", parts);
}
// The size to render on a multi-size design; absent/"master" is the base.
var variation = Environment.GetEnvironmentVariable("IMEJIS_VARIATION_ID") ?? "story";
// Render one image. The response body IS the image — no polling, no webhook.
var res = await Render($"/v1/{designId}", "", new Dictionary<string, string>
{
["headline.text"] = "Hello from C#",
["subtitle.text"] = "Rendered in one request",
});
var image = await res.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("output.jpg", image);
Console.WriteLine($"single: {(int)res.StatusCode} {image.Length} bytes");use serde_json::{json, Value};
use std::env;
use std::fs;
use std::io::Read;
fn env_or(key: &str, fallback: &str) -> String {
match env::var(key) {
Ok(value) if !value.is_empty() => value,
_ => fallback.to_string(),
}
}
/// POST a JSON body to `path` with the render key; returns (status, bytes, content-type).
fn render(path: &str, query: &str, body: Value) -> (u16, Vec<u8>, String) {
let base = env_or("IMEJIS_RENDER_URL", "https://render.imejis.io");
let api_key = env::var("IMEJIS_API_KEY").expect("IMEJIS_API_KEY");
let url = if query.is_empty() {
format!("{base}{path}")
} else {
format!("{base}{path}?{query}")
};
let response = ureq::post(&url)
.set("dma-api-key", &api_key)
.set("Content-Type", "application/json")
.send_string(&body.to_string())
.expect("render request failed");
let status = response.status();
let content_type = response.content_type().to_string();
let mut bytes = Vec::new();
response
.into_reader()
.read_to_end(&mut bytes)
.expect("read body");
(status, bytes, content_type)
}
/// The size to render on a multi-size design; absent/"master" is the base.
fn variation() -> String {
env_or("IMEJIS_VARIATION_ID", "story")
}
/// Percent-encode a query value (spaces, #, unicode all have to be escaped).
fn encode(value: &str) -> String {
value
.bytes()
.map(|b| match b {
b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => {
(b as char).to_string()
}
_ => format!("%{b:02X}"),
})
.collect()
}
fn main() {
let design_id = env::var("IMEJIS_DESIGN_ID").expect("IMEJIS_DESIGN_ID");
// Render one image. The response body IS the image — no polling, no webhook.
let (status, image, _) = render(
&format!("/v1/{design_id}"),
"",
json!({
"headline.text": "Hello from Rust",
"subtitle.text": "Rendered in one request",
}),
);
fs::write("output.jpg", &image).expect("write output.jpg");
println!("single: {status} {} bytes", image.len());
}require "json"
require "net/http"
require "uri"
API_KEY = ENV.fetch("IMEJIS_API_KEY")
DESIGN_ID = ENV.fetch("IMEJIS_DESIGN_ID")
BASE = ENV.fetch("IMEJIS_RENDER_URL", "https://render.imejis.io")
def render(path, params: {}, body: nil)
uri = URI("#{BASE}#{path}")
uri.query = URI.encode_www_form(params) unless params.empty?
request = Net::HTTP::Post.new(uri)
request["dma-api-key"] = API_KEY
request["Content-Type"] = "application/json"
request.body = JSON.dump(body || {})
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
http.request(request)
end
end
# The size to render on a multi-size design; absent/"master" is the base.
VARIATION = ENV.fetch("IMEJIS_VARIATION_ID", "story")
# Render one image. The response body IS the image — no polling, no webhook.
response = render("/v1/#{DESIGN_ID}", body: {
"headline.text" => "Hello from Ruby",
"subtitle.text" => "Rendered in one request"
})
File.binwrite("output.jpg", response.body)
puts "single: #{response.code} #{response.body.bytesize} bytes"A guide for your stack.
Copy-paste guides for each language, framework and no-code tool.
ASP.NET Core API guide
Astro API guide
Bun API guide
C# API guide
cURL API guideDeno API guide
Django API guide
Express API guide
FastAPI API guide
Fastify API guide
Flask API guide
Go API guide
Hono API guide
Java API guide
Laravel API guide
Make API guiden8n API guide
NestJS API guide
Next.js API guide
Node.js API guideNuxt API guide
Phoenix API guide
PHP API guide
Python API guide
Remix API guide
Ruby API guide
Ruby on Rails API guide
Rust API guide
Spring Boot API guide
SvelteKit API guide
Symfony API guide
WordPress API guide
Zapier API guide
Also useful
Know what you can put in a design.
Text, images, charts, QR codes, tables and more, each with its properties and sample JSON.
Browse the component libraryLet an AI agent drive it.
Connect Claude, ChatGPT, Gemini, Cursor or Google Antigravity over MCP. Your agent designs the template and gets the finished image back in one call.
Explore the MCP serverLearn about image generation APIs.
API questions.
Stuck? Visit the help center or write to us.
What is an image generation API?
An image generation API renders finished images from a design template and your data over HTTP. You design a template once, then send your values — text, numbers, images — to a single endpoint and get the image back, with no design tool and no manual export.
How do I generate an image with the API?
Send a POST request to the render endpoint with your API key in the dma-api-key header and a JSON body mapping template fields to your data. imejis returns the finished PNG, JPEG, WebP or PDF directly in the response — not a URL to poll.
Which programming languages can I use?
Any language that can make an HTTP request. imejis has copy-paste guides for cURL, Node.js, Python, Go, Ruby, PHP, Java, C# and more.
What does the image generation API cost?
The free plan includes 100 renders a month with no credit card. Paid plans add more renders, premium templates (every paid plan) and the MCP server (every plan). See the pricing page for each plan's limits.
Can the API return a PDF?
Yes, as one of the output formats: add format=pdf and the render comes back as a PDF at the design's canvas size. It is a single page. A multi-page document is one render per page plus your own assembly step, so if a bound document is the product itself, a document engine is the better fit.
Can an AI agent use the API?
Yes. imejis also runs a remote MCP server, so Claude, ChatGPT, Gemini, Cursor or Google Antigravity can design a template and render an image directly over the Model Context Protocol.
Your first render is one request away.
100 renders a month free with imejis, no card needed