anonrouterdocs

Image and speech generation

Generate images over the ticketed relay and synthesize speech through the router.

Beyond text, AnonRouter can generate images and synthesize speech from media models in the catalog. Both features are gated by the deployment operator, so confirm availability before you build on them.

The raw examples use separate control and content origins. The API key goes only to the control origin; prompts, text, images, and audio go only to the confidential API origin.

export ANONROUTER_API_KEY="ar_..."
export ANONROUTER_API_URL="https://api.anonrouter.ai/v1"
export ANONROUTER_CONTROL_URL="https://control.anonrouter.ai/v1"

Check availability first

GET /v1/capabilities reports whether image generation is enabled (image_generation.enabled). Image and speech models also appear in GET /v1/models with model_type of image or tts.

Image generation

Image generation uses the same private ticket flow as chat, so the prompt and the generated image travel over the relay and never reach the control plane. Issue a ticket with operation: "image", then post the prompt with the ticket. The ticket binds the model, size, and response format, and the request must match.

# 1. Issue an image ticket.
TICKET=$(curl -s "$ANONROUTER_CONTROL_URL/inference/tickets" \
  -H "Authorization: Bearer $ANONROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "alibaba/z-image-turbo",
    "operation": "image",
    "size": "1024x1024",
    "response_format": "b64_json"
  }' | jq -r .ticket)

# 2. Generate the image.
curl "$ANONROUTER_API_URL/images/generations" \
  -H "Content-Type: application/json" \
  -H "x-anonrouter-ticket: $TICKET" \
  -d '{
    "model": "alibaba/z-image-turbo",
    "prompt": "A watercolor fox in a misty forest",
    "size": "1024x1024",
    "response_format": "b64_json"
  }'

The response returns base64 image data:

{
  "created": 1782097200,
  "model": "alibaba/z-image-turbo",
  "data": [
    { "b64_json": "iVBORw0KGgo...", "mime_type": "image/png" }
  ]
}
  • size is WIDTHxHEIGHT, each dimension between 128 and 2048, default 1024x1024.
  • response_format is always b64_json. No hosted URL is returned.
  • Image models are billed at a flat price per image.

Speech

Speech uses the same two-step privacy split. The ticket request carries the model, voice, output format, and UTF-16 input length—but not the text. The text then goes to the confidential API with only the one-use ticket.

SPEECH_TICKET=$(curl -s "$ANONROUTER_CONTROL_URL/inference/tickets" \
  -H "Authorization: Bearer $ANONROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "speech",
    "model": "venice/kokoro-text-to-speech",
    "input_chars": 22,
    "voice": "af_sky",
    "response_format": "mp3"
  }' | jq -r .ticket)

curl "$ANONROUTER_API_URL/audio/speech" \
  -H "x-anonrouter-ticket: $SPEECH_TICKET" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "venice/kokoro-text-to-speech",
    "input": "Hello from AnonRouter.",
    "voice": "af_sky",
    "response_format": "mp3"
  }' \
  --output speech.mp3
  • input is the text to synthesize, up to 20,000 characters.
  • input_chars in the ticket is the exact UTF-16 code-unit length. The official SDK handles this correctly for emoji and other astral characters.
  • voice is an optional, provider-specific string.
  • response_format is mp3. The response body is raw audio with the matching content-type.
  • Speech is billed at a flat price per million input characters.

No video endpoint

Video generation is not part of the API. Only text, image, embedding, and speech models are callable.

On this page