Image Generation
Generate and save an image from a text description.
Generate and save to a file
python
import os, base64
from openai import OpenAI
client = OpenAI(api_key=os.environ["QEVRON_API_KEY"], base_url="https://app.qevron.ai/v1")
resp = client.images.generate(
model="spook-generate",
prompt="A neon-lit city street at night, cinematic, high detail",
n=1,
size="1024x1024",
response_format="b64_json",
)
img_b64 = resp.data[0].b64_json
with open("image.png", "wb") as f:
f.write(base64.b64decode(img_b64))
print("image.png saved")With curl
bash
curl https://app.qevron.ai/v1/images/generations \
-H "Authorization: Bearer $QEVRON_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "spook-generate",
"prompt": "A neon-lit city street at night, cinematic",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json"
}'Background removal (image editing)
To remove the background of an existing image, use the image edits endpoint with the spook-background model:
bash
curl https://app.qevron.ai/v1/images/edits \
-H "Authorization: Bearer $QEVRON_API_KEY" \
-F "model=spook-background" \
-F "image=@product.jpg" \
-F "n=1" \
-F "response_format=b64_json"The result is a transparent PNG with the background removed. This model requires no prompt.
Prompt-writing tips
- Be clear and descriptive: subject + style + lighting + composition (e.g. "watercolor", "cinematic", "wide angle").
response_format:b64_json(embedded data) orurl(link).size:1024x1024,1792x1024, etc., if the model supports it.
Related: Images API.