Images (beta)

Overview

The images endpoint family provides text-to-image generation capabilities via MultiRoute. This functionality is currently beta and may change without notice as we refine the contract and underlying routing behavior.

Use this endpoint to:

Status

Beta / experimental
The images API is considered experimental. Fields, response formats, and supported models may evolve. Avoid hard-coding against this contract for long-lived production systems without version pinning and monitoring.

Endpoint

Full URL:

https://api.multiroute.ai/v1/images/generations

Authentication is required via the Authorization: Bearer <your-api-key> header.

Request body

The request body is JSON with at least a model and a prompt, plus optional generation parameters:

Example request body

{
  "model": "multiroute-image-latest",
  "prompt": "A minimalist illustration of a mountain range at sunrise in a flat vector style",
  "n": 1,
  "size": "1024x1024",
  "response_format": "url"
}

Response body

The endpoint returns a JSON object describing generated images:

Example response (response_format: "url")

{
  "created": 1710000001,
  "data": [
    {
      "url": "https://cdn.multiroute.ai/images/img-abc123.png",
      "revised_prompt": "A minimalist vector illustration of mountains at sunrise."
    }
  ]
}

Examples

cURL

curl https://api.multiroute.ai/v1/images/generations \
  -H "Authorization: Bearer $MULTIROUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "multiroute-image-latest",
    "prompt": "An isometric illustration of a microservice architecture diagram",
    "n": 1,
    "size": "1024x1024",
    "response_format": "url"
  }'

TypeScript / Node (fetch)

const apiKey = process.env.MULTIROUTE_API_KEY!;

async function generateImage() {
  const response = await fetch("https://api.multiroute.ai/v1/images/generations", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${apiKey}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "multiroute-image-latest",
      prompt: "A multi-colored logo representing API routing and orchestration",
      n: 1,
      size: "512x512",
      response_format: "url",
    }),
  });

  if (!response.ok) {
    const errorBody = await response.text();
    throw new Error(`Request failed: ${response.status} ${errorBody}`);
  }

  const data = await response.json();
  console.log("Image URL:", data.data[0]?.url);
}

generateImage().catch(console.error);

Python (requests)

import os
import requests

API_KEY = os.environ.get("MULTIROUTE_API_KEY")

def generate_image():
  url = "https://api.multiroute.ai/v1/images/generations"
  headers = {
      "Authorization": f"Bearer {API_KEY}",
      "Content-Type": "application/json",
  }
  json_body = {
      "model": "multiroute-image-latest",
      "prompt": "A clean dashboard UI screenshot for monitoring API routing performance",
      "n": 1,
      "size": "1024x1024",
      "response_format": "url",
  }

  resp = requests.post(url, headers=headers, json=json_body, timeout=60)
  resp.raise_for_status()
  data = resp.json()
  print("Image URL:", data["data"][0]["url"])

if __name__ == "__main__":
  generate_image()

Best practices