Quickstart
Generate your first image in 5 minutes.
1. Get an API key
Sign up at reapi.ai, then go to Dashboard → API Keys → Create new key. Copy it now — you won't see it again.
rk_live_xxxxxxxxxxxxxxxxxxxxxxx2. Submit a generation task
curl https://reapi.ai/api/v1/images/generations \
-H "Authorization: Bearer rk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "a cute red panda eating bamboo, photorealistic",
"size": "1:1"
}'Response (immediately):
{
"id": "task_018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e",
"model": "gpt-image-2",
"status": "processing",
"created_at": 1735000000
}3. Poll until done
curl https://reapi.ai/api/v1/tasks/task_018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e \
-H "Authorization: Bearer rk_live_xxx"Repeat every 1–2 seconds until status is completed:
{
"id": "task_018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e",
"model": "gpt-image-2",
"status": "completed",
"created_at": 1735000000,
"output": {
"image_urls": [
"https://cdn.reapi.ai/media/tasks/018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e/0.png"
]
},
"error": null
}That's it. Your image is at output.image_urls[0].
Full example (Node.js)
const KEY = process.env.REAPI_KEY;
async function generate(prompt) {
const submit = await fetch('https://reapi.ai/api/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': `Bearer ${KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'gpt-image-2',
prompt,
}),
}).then(r => r.json());
const taskId = submit.id;
while (true) {
await new Promise(r => setTimeout(r, 1500));
const task = await fetch(`https://reapi.ai/api/v1/tasks/${taskId}`, {
headers: { 'Authorization': `Bearer ${KEY}` },
}).then(r => r.json());
if (task.status === 'completed') return task.output.image_urls;
if (task.status === 'failed') throw new Error(task.error?.message ?? 'failed');
}
}
console.log(await generate('a cute red panda'));Python
import os, time, requests
KEY = os.environ['REAPI_KEY']
HEAD = {'Authorization': f'Bearer {KEY}'}
submit = requests.post(
'https://reapi.ai/api/v1/images/generations',
headers=HEAD,
json={
'model': 'gpt-image-2',
'prompt': 'a cute red panda',
},
).json()
task_id = submit['id']
while True:
time.sleep(1.5)
task = requests.get(f'https://reapi.ai/api/v1/tasks/{task_id}', headers=HEAD).json()
if task['status'] == 'completed':
print(task['output']['image_urls'])
break
if task['status'] == 'failed':
raise RuntimeError(task['error'])Next steps
- API overview — full conventions
- Tasks —
GET /api/v1/tasks/{id}polling reference - gpt-image-2 model card — capabilities + pricing
- Errors — error code reference
reAPI Docs