Documentation
Quickstart
Create an INFRO API key, install the SDK, and make your first text, image, video, or audio request — in about five minutes, with no provider accounts.
You need two things to start: a key and a model id. Everything else — routing, retries, failover, metering — happens behind the endpoint.
1. Create a key
Sign up in the console and create an API key. Keys are free; you pay only for what you generate. Add credits with a card, and set a per-key spend limit if you want a hard ceiling — see Rate & spend limits.
# keep the key in your environment, never in code
export INFRO_API_KEY="sk_infro_..."2. Install the SDK
pip install infroAny OpenAI-compatible client also works for text: point its base URL at https://api.infro.io/v1 and swap the key. See SDKs & frameworks for LangChain, the Vercel AI SDK, and others.
3. Make your first request
Model ids follow vendor/model-name. Browse the catalog for ids, per-unit prices, and capabilities. Switching models is a one-string change.
import os
from infro import Infro
client = Infro(api_key=os.environ["INFRO_API_KEY"])
image = client.images.generate(
model="bfl/flux-2-pro",
prompt="a lighthouse in fog, 35mm",
)
print(image.data[0].url)
print(f"cost: ${image.usage.cost:.4f}")4. Try another modality
The same client covers text, video, and audio. Video runs as an async job because renders take minutes — submit, then receive a signed webhook when it lands.
# Text — OpenAI-compatible
chat = client.chat.completions.create(
model="anthropic/claude-sonnet-5",
messages=[{"role": "user", "content": "Write an alt text for a foggy lighthouse."}],
)
# Video — async, delivered by webhook
job = client.videos.create(
model="kuaishou/kling-2.5",
prompt="slow push-in on a lighthouse in fog",
duration_seconds=6,
webhook={"url": "https://api.example.com/hooks/infro"},
)
print(job.id, job.status)5. Optional: control routing and cost
By default INFRO routes to the cheapest healthy route. Pin a policy, restrict regions, or set model fallbacks per request. These fields sit at the top level of the body and are ignored by other OpenAI-compatible backends, so your code stays portable.
image = client.images.generate(
model="bfl/flux-2-pro",
prompt="a lighthouse in fog, 35mm",
routing={"policy": "fastest", "regions": ["us", "eu"]},
fallbacks=["bytedance/seedream-4"],
)Every response carries usage.cost, the exact amount charged. Log it next to your own request ids and you have per-feature cost attribution without any extra instrumentation.
Next steps
- Authentication — key format, headers, rotation, and spend limits.
- Image generation · Video generation · Audio & speech.
- Errors — every status code and which to retry.
- Failover & fallbacks — what happens when a route goes down.