Skip to content
Tavio
All articles
  • AI image generation API
  • generate images via API
  • Tavio
  • flux
  • OpenAI-compatible API

How to Generate Images via API with Tavio (Step-by-Step)

6 min read

Generating images via API means creating pictures from a text description with a programmatic request, no manual clicking in a UI. With Tavio you do this with a single HTTP call to an OpenAI-compatible endpoint, and the exact same API key works not only for images but also for video, speech, and text. This guide walks the whole path: from getting a key to handling the response and choosing the right model for the job.

What Tavio is and why one API covers everything

Tavio is a unified API and web dashboard to generate images, video, speech (TTS), and text (chat/LLM). The core idea is simple: one API key for every modality, exposed through an OpenAI-compatible REST API, so your existing OpenAI SDKs and tools work unchanged — you just point them at a new base_url.

Under the hood Tavio runs on edge infrastructure (low latency, global) and performs automatic failover between providers: if one model or provider is down, the request is routed to a backup. You don’t have to write multi-provider retry logic yourself — it’s built in.

The API base URL is https://api.tavio.tech/v1. It uses familiar OpenAI paths, including /images/generations for pictures.

Step 1. Get an API key from the Telegram bot

Sign-up and key issuance happen through the Telegram bot. Open https://t.me/taviotech_bot and start it — the bot creates your account and issues an API key. This is the only sign-up method today; email and password are not supported yet.

Copy the key and keep it secret. In the examples below, substitute it for YOUR_TAVIO_API_KEY. Storing it in an environment variable rather than hardcoding it is the safer habit.

Step 2. Your first request with curl

The fastest way to confirm everything works is to hit the images/generations endpoint directly with curl. You specify the model, a text prompt, how many images you want (n), and the size (size).

curl https://api.tavio.tech/v1/images/generations \
  -H "Authorization: Bearer YOUR_TAVIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flux-1.1-pro",
    "prompt": "a cozy Scandinavian living room at golden hour, soft natural light, editorial photography",
    "n": 1,
    "size": "1024x1024"
  }'

The response comes back in the OpenAI-compatible format — a data array holding the generated images:

{
  "created": 1750598400,
  "data": [
    {
      "url": "https://cdn.tavio.tech/images/abc123.png"
    }
  ]
}

Grab the url from the first element of data — it’s a link to the finished image in the CDN. From there you can download it, show it to a user, or save it to your own storage.

Step 3. The same call in Python with the OpenAI SDK

Because the API is OpenAI-compatible, you don’t need a separate client. Take the official OpenAI SDK and just set base_url and your Tavio key. Everything else stays standard.

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_TAVIO_API_KEY",
    base_url="https://api.tavio.tech/v1",
)

response = client.images.generate(
    model="flux-1.1-pro",
    prompt="a red vintage bicycle leaning on a stone wall, morning fog, cinematic",
    n=1,
    size="1024x1024",
)

image_url = response.data[0].url
print(image_url)

The same client also serves the other modalities — client.chat.completions.create(...) for text and client.audio.speech.create(...) for speech. One client, one key, different methods.

How to choose a model: quality vs. cost

Tavio offers several image models, and picking one is a balance of quality, speed, and price. The model identifiers match those listed on the pricing page.

  • flux-1.1-pro — the flagship for photorealistic, detailed images. Reach for it when quality matters most: product visuals, covers, hero images.
  • flux-dev — a lighter member of the FLUX family. A good compromise for iterating and rough passes while you dial in a prompt.
  • gpt-image-2 — strong at complex scenes, text inside the image, and compositions driven by description.
  • sdxl — a reliable workhorse. A sensible choice for high volume and bulk generation, where cost per image matters more than maximum detail.

A practical strategy: refine your prompt on a cheaper model (flux-dev or sdxl), then generate the final version on flux-1.1-pro. That way you don’t overpay for dozens of draft runs.

Prompting basics for images

A good image prompt describes not just the subject but the style, light, and composition too. A few principles that work:

  • Subject plus context. Not just “a cat,” but “a ginger cat sitting on a windowsill by a rain-streaked window.”
  • Light and time. Words like golden hour, soft natural light, and studio lighting noticeably change the result.
  • Style and medium. editorial photography, oil painting, 3D render, and cinematic set the overall aesthetic.
  • Angle and framing. close-up, wide shot, and top-down view control the composition.

English prompts tend to give more predictable results across most models, but you can describe the scene in any language.

What it costs: credits and awareness

Tavio runs on a subscription: your plan grants a daily credit quota (refreshed every day, with the remainder burning at midnight UTC), and any generation draws from it. Paid plans start at $10/mo.

Each image draws credits depending on the model, the size, and how many images you request. Up-to-date per-model prices in credits live on the pricing page: tavio.tech/en/pricing. A practical tip for stretching your daily quota: generate n: 1 while you refine the prompt and only increase the count for the final run, and switch on heavier models like flux-1.1-pro once the prompt is dialed in.

FAQ

Do I have to rewrite my code if I already use the OpenAI SDK?

No. Tavio’s API is OpenAI-compatible, so you just change base_url to https://api.tavio.tech/v1 and plug in your Tavio key. The images.generate, chat.completions.create, and audio.speech.create methods stay the same.

What happens if a model’s provider goes down?

Tavio performs automatic failover: if the primary model or provider is unavailable, the request is routed to a backup. You don’t need to implement multi-provider retry logic yourself.

How do I find the exact price of a specific model?

Per-image prices are listed in credits on the pricing page, tavio.tech/en/pricing. Those credits are drawn from your plan’s daily quota, so what matters per model is its credit cost rather than a separate charge for each image.

Can I use the same key for video and speech?

Yes. The same API key works for images, video, speech (TTS), and text. Only the method and model change — for example, kling-v2 or veo-fast for video, and elevenlabs-tts or openai-tts for speech.

Get started now

Getting a key and firing off your first request takes a couple of minutes. Sign up through the Telegram bot at https://t.me/taviotech_bot, copy your API key, and drop it into the examples above. Full endpoint and parameter details are in the docs: https://api.tavio.tech/docs. And if you prefer no-code, you can generate images in the web dashboard too: https://app.tavio.tech.