For the complete documentation index, see llms.txt. This page is also available as Markdown.

Image Editing

Use a model tagged Image-Edit to change an existing image. Browse supported models.

import base64
from pathlib import Path

from openai import OpenAI

client = OpenAI(base_url="https://api.cortecs.ai/v1", api_key="<API_KEY>")

with Path("input.png").open("rb") as image:
    response = client.images.edit(
        model="gemini-2.5-flash-image",
        image=image,
        prompt="Change the background to black.",
    )

image_base64 = next((item.b64_json for item in response.data if item.b64_json), None)
if image_base64 is None:
    raise RuntimeError("The response did not contain a Base64-encoded image.")

Path("edited-image.png").write_bytes(base64.b64decode(image_base64))
import fs from "fs";
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.cortecs.ai/v1",
  apiKey: "<API_KEY>"
});

const response = await client.images.edit({
  model: "gemini-2.5-flash-image",
  image: fs.createReadStream("input.png"),
  prompt: "Change the background to black."
});

const imageBase64 = response.data.find((item) => item.b64_json)?.b64_json;
if (!imageBase64) throw new Error("The response did not contain a Base64-encoded image.");

await fs.promises.writeFile("edited-image.png", Buffer.from(imageBase64, "base64"));

Last updated