Images
Generate and edit images with the OpenAI-compatible /v1/images endpoints. Priced per image, returned as base64, with an optional 30-day encrypted gallery.
Ruvicode serves image models through two OpenAI-compatible endpoints, on the same API key and wallet as chat:
POST /v1/images/generationscreates images from a prompt.POST /v1/images/editschanges an image you send, following a prompt.
Images are created at 1K resolution (about one megapixel, for example 1024x1024 or 1248x832). Image models are priced per image, not per token. You pay only for images that come back: a request for 4 images that returns 3 is charged for 3, and a request that fails or is rejected by the content policy costs nothing.
Models
| Model | Endpoint | Content filter |
|---|---|---|
ruvicode-image | generations | Blurs adult output |
ruvicode-image-uncensored | generations | Adult content not blurred |
ruvicode-image-edit | edits | Blurs adult output |
ruvicode-image-edit-uncensored | edits | Adult content not blurred |
ruvicode-image-premium | generations | Blurs adult output |
ruvicode-image-premium-uncensored | generations | Adult content not blurred |
ruvicode-image-premium-edit | edits | Blurs adult output |
ruvicode-image-premium-edit-uncensored | edits | Adult content not blurred |
The premium models give higher-quality images at a higher price per image.
Some content is blurred on every model, the uncensored ones included. The response then carries "blurred": true.
Current prices per image are on each model page in the models catalog and in GET /v1/models (price_per_image). A model that is temporarily unavailable answers 404.
Generate an image
curl https://api.ruvicode.com/v1/images/generations \
-H "Authorization: Bearer rvcd_..." \
-H "Content-Type: application/json" \
-d '{
"model": "ruvicode-image",
"prompt": "A lighthouse on a cliff at golden hour",
"aspect_ratio": "16:9",
"n": 1,
"store": false
}'With the OpenAI SDK:
import base64
from openai import OpenAI
client = OpenAI(api_key="rvcd_...", base_url="https://api.ruvicode.com/v1")
result = client.images.generate(
model="ruvicode-image",
prompt="A lighthouse on a cliff at golden hour",
size="1536x1024",
n=2,
extra_body={"store": False}, # Ruvicode extension, see the table below
)
for i, image in enumerate(result.data):
with open(f"image-{i}.png", "wb") as f:
f.write(base64.b64decode(image.b64_json))Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model | string | required | An image generation model id |
prompt | string | required | What to draw, up to 10,000 characters |
n | integer | 1 | Images to create, 1 to 4 |
aspect_ratio | string | 1:1 | 1:1, 3:2, 16:9, 21:9, 9:16, 2:3, 3:4, 4:5. Premium models: 1:1, 3:2, 16:9, 9:16, 2:3, 3:4, 4:3 |
size | string | none | OpenAI-style size such as 1536x1024. Mapped to the nearest aspect ratio; aspect_ratio wins when you send both |
output_format | string | png | png, jpeg or webp |
seed | integer | random | Reuse a seed to get similar results for the same prompt |
negative_prompt | string | none | What to keep out of the image |
response_format | string | b64_json | Only b64_json is supported |
store | boolean | false | true also saves a copy to your gallery; false returns the image without keeping it |
Edit an image
Send one image per request, as a file upload (multipart, as the OpenAI SDKs do) or as base64 in JSON. To keep editing, send the result back as the next request's image.
curl https://api.ruvicode.com/v1/images/edits \
-H "Authorization: Bearer rvcd_..." \
-F model="ruvicode-image-edit" \
-F prompt="Replace the sky with a sunset" \
-F image=@photo.png \
-F store=falseresult = client.images.edit(
model="ruvicode-image-edit",
image=open("photo.png", "rb"),
prompt="Replace the sky with a sunset",
extra_body={"store": False},
)JSON works too: "image" takes a base64 string or a data:image/png;base64,... URI. Image URLs are not accepted.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model | string | required | An image edit model id |
prompt | string | required | What to change, up to 10,000 characters |
image | file or base64 | required | One image: PNG, JPEG or WebP, at least 256x256, up to 20 MB |
aspect_ratio | string | auto | auto keeps the shape of the input, or one of the model's generation ratios |
output_format | string | png | png, jpeg or webp |
n | integer | 1 | Edits return one image |
store | boolean | false | true also saves a copy to your gallery (multipart: store=true) |
seed and negative_prompt work on generations only. An edit request that sends either is refused with 400 and nothing is charged.
Response
{
"created": 1792618679,
"model": "ruvicode-image",
"data": [
{ "b64_json": "iVBORw0KGgo...", "id": "img_2e2cd91a7a6b18380b8189505e815d5a" }
],
"output_format": "png",
"cost": 0.03
}| Field | Description |
|---|---|
data[].b64_json | The image, base64-encoded |
data[].id | The image's id in your dashboard gallery (only when store is true) |
cost | What this request cost, in USD (also sent as the X-Cost header) |
blurred | Present and true when part of the image was blurred by the content filter |
Your gallery
By default the API only returns the image and keeps no copy. Send "store": true to also save it to your dashboard gallery in Studio. Images made in Studio are always saved, since the gallery is Studio's history.
- Images are encrypted at rest with AES-256 and open only to your account.
- We never use your images to train models.
- Saved images are deleted automatically after 30 days. You can delete any image, or all of them, at any time.
Save the b64_json you receive if you need an image for longer than 30 days.
Errors
Image requests use the standard error format. Specific to images:
| Status | Type | Meaning |
|---|---|---|
| 400 | content_policy_violation | The prompt or image was rejected by the content policy. Nothing is charged |
| 400 | invalid_request_error | A parameter is out of range or not supported by the endpoint (for example seed on an edit), or an input image is too small, too large or not PNG, JPEG or WebP |
| 403 | invalid_request_error | The key may not use this model, or it is an Unlimited Pass key (passes cover chat models only) |
| 404 | invalid_request_error | Unknown or temporarily unavailable model |
| 429 | rate_limit_error | Image generation is busy, retry in a moment |
Image requests count toward the same per-key and account rate limits as chat requests.