Docs / Image Generation
Image Generation
Generate images from text prompts through the OpenAI-compatible POST /v1/images/generations endpoint. The request returns image URLs directly; no polling required.
#Models
| Model ID | Family | Notes |
|---|---|---|
| grok-imagine-image | Grok Imagine | Fast image generation |
| grok-imagine-image-quality | Grok Imagine | Higher quality tier |
#API usage
cURL
terminalbash
curl https://relaydance.com/v1/images/generations \
-H "Authorization: Bearer $RELAYDANCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image",
"prompt": "A serene Japanese garden with cherry blossoms, watercolor style",
"n": 1
}'Python
image.pypython
import requests, os
response = requests.post(
"https://relaydance.com/v1/images/generations",
headers={
"Authorization": f"Bearer {os.environ['RELAYDANCE_API_KEY']}",
"Content-Type": "application/json",
},
json={
"model": "grok-imagine-image",
"prompt": "A serene Japanese garden with cherry blossoms, watercolor style",
"n": 1,
},
)
data = response.json()
print(data["data"][0]["url"])OpenAI SDK
image.tstypescript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.RELAYDANCE_API_KEY,
baseURL: "https://relaydance.com/v1",
});
const res = await client.images.generate({
model: "grok-imagine-image",
prompt: "A futuristic city at dusk, cinematic lighting",
n: 1,
});
console.log(res.data[0].url);#Response
response.jsonjson
{
"data": [
{ "url": "https://..." }
]
}#Request parameters
| Parameter | Type | Description |
|---|---|---|
model | string | Image model ID |
prompt | string | Text description of the image to generate |
n | integer | Number of images to generate. Default: 1 |
size | string | Optional output size, model-dependent (e.g. "1024x1024") |
#Tips for better results
- Be specific: describe style, composition, lighting and mood in your prompt
- Name a style: keywords like "photorealistic", "watercolor", "anime" steer the output strongly
- Iterate: small prompt changes can shift results a lot; generate, adjust, repeat
Generated images make good reference inputs for video: pass the URL in
metadata.content[] of a video task. See Image-to-Video.