I was comparing AI APIs last week and stumbled across something that made me do a double-take: $0.003 per image for Flux Schnell. That's 5× cheaper than the official Black Forest Labs pricing.
The API is called NexaAPI, and it gives you a single OpenAI-compatible key to access 50+ models — Flux, Veo 3, Kling, Sora, Stable Diffusion, Whisper, TTS, and more.
Here's the complete tutorial.
Setup
pip install nexaapi
# or
npm install nexaapi
Get your API key from RapidAPI (free tier available).
Your First Image in 3 Lines
from nexaapi import NexaAPI
client = NexaAPI(api_key="YOUR_API_KEY")
print(client.images.generate(model="flux-schnell", prompt="a red panda coding").image_url)
import NexaAPI from 'nexaapi';
const client = new NexaAPI({ apiKey: 'YOUR_API_KEY' });
const { imageUrl } = await client.images.generate({ model: 'flux-schnell', prompt: 'a red panda coding' });
console.log(imageUrl);
That's it. $0.003. One API key.
Full Image Generation
from nexaapi import NexaAPI
import os
client = NexaAPI(api_key=os.environ.get("NEXAAPI_KEY"))
# Flux Schnell — fastest & cheapest
response = client.images.generate(
model="flux-schnell",
prompt="A red panda sitting at a computer, coding, digital art style",
negative_prompt="blurry, low quality",
width=1024,
height=1024
)
print(f"Image URL: {response.image_url}")
print(f"Cost: $0.003")
Video Generation
# Kling v1 video
response = client.videos.generate(
model="kling-v1",
prompt="A drone flying over a mountain landscape at golden hour",
duration=5
)
print(f"Video URL: {response.video_url}")
# Veo 3 — Google's model with audio
response_veo = client.videos.generate(
model="veo-3",
prompt="A chef preparing pasta, cinematic quality",
duration=8
)
print(f"Veo 3: {response_veo.video_url}")
TTS — 50+ Voices
response = client.audio.tts(
text="Hello! This is NexaAPI text to speech.",
voice="en-US-Neural2-F",
format="mp3"
)
print(f"Audio URL: {response.audio_url}")
Batch Generation
import asyncio
from nexaapi import AsyncNexaAPI
async def generate_batch(prompts):
client = AsyncNexaAPI(api_key=os.environ.get("NEXAAPI_KEY"))
tasks = [client.images.generate(model="flux-schnell", prompt=p) for p in prompts]
results = await asyncio.gather(*tasks)
return [r.image_url for r in results]
prompts = ["a cat", "a dog", "a bird", "a fish", "a dragon"]
urls = asyncio.run(generate_batch(prompts))
print(f"Generated {len(urls)} images for ${len(urls) * 0.003:.3f}")
# Output: Generated 5 images for $0.015
Drop-in OpenAI Replacement
Already using OpenAI SDK? Change one line:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_NEXAAPI_KEY",
base_url="https://api.nexa-api.com/v1" # ← only change
)
# Everything else stays the same!
Pricing Comparison
| Model | NexaAPI | Official | Savings |
|---|---|---|---|
| Flux Schnell | $0.003 | $0.015 | 5× cheaper |
| Flux Pro 1.1 | $0.02 | $0.055 | 2.75× cheaper |
| Stable Diffusion 3.5 | $0.005 | $0.02 | 4× cheaper |
| Veo 3 | $0.50/video | $2.00/video | 4× cheaper |
Top comments (0)