Skip to content

Image Generation

Updated View as Markdown

Truememory provides an OpenAI-compatible image generation endpoint that routes to multiple providers. Any client that works with OpenAI’s /v1/images/generations works with Truememory by changing the base URL.

All requests require a Bearer token from Truememory Auth.

Endpoint

POST /v1/images/generations

Supported Models

Model Provider Format
openai/gpt-image-1.5 OpenAI url or b64_json
openai/dall-e-3 OpenAI url or b64_json
google/gemini-3.1-flash-image Google Gemini (“Nano Banana 2”, Vertex AI) b64_json only
google/gemini-3.1-flash-lite-image Google Gemini (“Nano Banana 2 Lite”, Vertex AI) b64_json only
google/gemini-2.5-flash-image Google Gemini (“Nano Banana”, Vertex AI) b64_json only
google/gemini-3-pro-image Google Gemini (“Nano Banana Pro”, Vertex AI) b64_json only

Use the provider/model format (e.g. openai/gpt-image-1.5). You can also omit the provider prefix for OpenAI models (e.g. dall-e-3).

The Gemini image models (“Nano Banana” and “Nano Banana Pro”) generate a single image per request (n must be 1).

Parameters

Send as JSON:

Parameter Type Default Description
model string required Image model to use (e.g. openai/gpt-image-1.5, google/gemini-3.1-flash-image)
prompt string required Text description of the desired image
n integer 1 Number of images to generate. OpenAI: 1–10. Google: 1 only — Gemini image models return a single image.
size string null Image size: 1024x1024, 1792x1024, 1024x1792. For Google models, this maps to aspect ratios (1:1, 16:9, 9:16).
quality string null Image quality (OpenAI only): auto, low, medium, high, hd
response_format string b64_json url or b64_json. Google models always return b64_json regardless of this setting.
style string null Image style (dall-e-3 only): natural, vivid

Examples

OpenAI (gpt-image-1.5)

curl -X POST https://your-tie-host/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "model": "openai/gpt-image-1.5",
    "prompt": "A serene mountain landscape at sunset with a reflective lake",
    "n": 1,
    "size": "1024x1024",
    "quality": "auto"
  }'

Google Gemini (“Nano Banana”)

curl -X POST https://your-tie-host/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "model": "google/gemini-3.1-flash-image",
    "prompt": "A serene mountain landscape at sunset with a reflective lake",
    "size": "1024x1024"
  }'

Use google/gemini-3-pro-image for the higher-quality “Nano Banana Pro” model.

DALL-E 3

curl -X POST https://your-tie-host/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "model": "openai/dall-e-3",
    "prompt": "A serene mountain landscape at sunset with a reflective lake",
    "style": "natural"
  }'

Response

The response follows OpenAI’s image generation format:

{
  "created": 1711900000,
  "data": [
    {
      "b64_json": "iVBORw0KGgo...",
      "url": null,
      "revised_prompt": "A tranquil mountain landscape during golden hour..."
    }
  ]
}
Field Type Description
created integer Unix timestamp of when the response was generated
data array List of generated images
data[].b64_json string or null Base64-encoded image data (when response_format is b64_json)
data[].url string or null Temporary URL to the generated image (when response_format is url, OpenAI models only)
data[].revised_prompt string or null The prompt that was actually used (OpenAI models may revise your prompt for safety/quality)

Provider Differences

Feature OpenAI Google Gemini (Nano Banana)
Max images per request 10 1
response_format: "url" Temporary URL returned Not supported — always returns b64_json
style parameter Supported (dall-e-3 only) Ignored
quality parameter Supported Ignored
revised_prompt Returned when prompt is modified Not returned
Size handling Passed as-is (e.g. 1024x1024) Mapped to aspect ratio (e.g. 1:1)

SDK Integration

Since the endpoint is OpenAI-compatible, you can use the standard OpenAI SDK:

Python

from openai import OpenAI

client = OpenAI(
    base_url="https://your-tie-host/v1",
    api_key="$TOKEN",
)

response = client.images.generate(
    model="openai/gpt-image-1.5",
    prompt="A serene mountain landscape at sunset",
    n=1,
    size="1024x1024",
)

print(response.data[0].b64_json[:50])  # base64 image data

TypeScript / Node.js

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://your-tie-host/v1",
  apiKey: "$TOKEN",
});

const response = await client.images.generate({
  model: "openai/gpt-image-1.5",
  prompt: "A serene mountain landscape at sunset",
  n: 1,
  size: "1024x1024",
});

console.log(response.data[0].b64_json?.slice(0, 50));

Error Handling

Status Code When
400 VALIDATION_ERROR Unsupported model, n exceeds provider limit, invalid parameters
401 AUTH_TOKEN_MISSING No Bearer token provided
502 SERVICE_UPSTREAM_ERROR The upstream provider (OpenAI or Google) returned an error
503 SERVICE_UNAVAILABLE Required provider credentials not configured (e.g. OPENAI_API_KEY or GCP_PROJECT_ID)
Navigation

Type to search…

↑↓ navigate↵ selectEsc close