Skip to main content
Generate images from text prompts, edit existing images with natural language, or transform images with style transfer. All generated images are automatically saved to your Space.

Quick Start

import requests

response = requests.post(
    "https://api.zarkai.xyz/v1/chat",
    headers={
        "x-api-key": "your_api_key",
        "Content-Type": "application/json",
    },
    json={
        "messages": [
            {"role": "user", "content": "Create an image of a futuristic cityscape at night with neon lights"}
        ],
        "workspace_id": "wks-xxxxx",
        "tools": ["image_gen"],
        "tool_choice": "auto",
    },
)

data = response.json()
print(data["response"])
Generated images are returned as file references and saved directly to your Space.

Image Editing

Edit an existing image by referencing a file already in your Space:
{
  "messages": [
    {"role": "user", "content": "Add falling snow to this image"}
  ],
  "workspace_id": "wks-xxxxx",
  "tools": ["image_gen"],
  "file_ids": ["file-abc123"],
  "tool_choice": "auto"
}
The model understands the image content and applies your requested changes while preserving the rest of the scene.

Style Transfer

Transform existing images by describing the desired aesthetic:
{
  "messages": [
    {"role": "user", "content": "Render this image as an oil painting in the style of impressionism"}
  ],
  "workspace_id": "wks-xxxxx",
  "tools": ["image_gen"],
  "file_ids": ["file-abc123"],
  "tool_choice": "auto"
}
Supported styles include oil painting, watercolor, pencil sketch, pop art, anime, pixel art, and any style you can describe.

Streaming

Python
import requests
import json

response = requests.post(
    "https://api.zarkai.xyz/v1/chat",
    headers={"x-api-key": "your_api_key", "Content-Type": "application/json"},
    json={
        "messages": [{"role": "user", "content": "Create an image of a mountain landscape at sunrise"}],
        "workspace_id": "wks-xxxxx",
        "tools": ["image_gen"],
        "stream": True,
    },
    stream=True,
)

for line in response.iter_lines():
    if line:
        event = json.loads(line.decode("utf-8").removeprefix("data: "))
        if event["type"] == "media_item":
            print(f"Image generated: {event['file_id']}")
        elif event["type"] == "ai_chunk":
            print(event["content"], end="", flush=True)
        elif event["type"] == "ai_complete":
            print(f"\n\nDone.")

Streaming Events

EventDescription
media_itemGenerated image file reference with file_id and metadata
ai_chunkIncremental text describing what was generated
ai_completeFinal response with image reference

What Image Generator Is Not

Image Generator is a creation tool. It generates new visual content from descriptions.

Examples

Create an image of a futuristic cityscape at night with neon lights
Generate a minimalist logo for a coffee shop called "Brew"
Draw a technical diagram showing a load balancer architecture
Render this photo as a pencil sketch
Create an icon set for a mobile app — home, search, profile, settings
Apply a watercolor style to my uploaded photo
Edit this image to add rain