Image edits
Upload an image and describe what to change.
Compatible with the OpenAI image edit endpoint. Send image files as multipart/form-data, or pass image URLs as JSON (see "JSON requests" below). Image models are listed on the Model Square, for example gpt-image-1.
POST https://tokenfunc.com/v1/images/editscURL
curl https://tokenfunc.com/v1/images/edits \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-F model="gpt-image-1" \
-F image=@cat.png \
-F prompt="Give the cat a small red hat"Python
from openai import OpenAI
client = OpenAI(base_url="https://tokenfunc.com/v1", api_key="sk-xxxxxxxxxxxxxxxx")
resp = client.images.edit(
model="gpt-image-1",
image=open("cat.png", "rb"),
prompt="Give the cat a small red hat",
)Node.js
import { createReadStream } from 'node:fs'
import OpenAI from 'openai'
const client = new OpenAI({ baseURL: 'https://tokenfunc.com/v1', apiKey: 'sk-xxxxxxxxxxxxxxxx' })
const resp = await client.images.edit({
model: 'gpt-image-1',
image: createReadStream('cat.png'),
prompt: 'Give the cat a small red hat',
})Request parameters
200
{
"created": 1760000000,
"data": [{ "b64_json": "iVBORw0KGgo..." }]
}The response has the same shape as Image generation, including usage and the other fields. Image URLs usually expire, so download them promptly.
JSON requests
If uploading files is inconvenient, send JSON instead: put the source images in an images array, each item {"image_url": "..."} holding an image URL or a Base64 data URL. mask takes the same form, and the other parameters match the table above.
curl https://tokenfunc.com/v1/images/edits \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-d '{
"model": "gpt-image-1",
"images": [{ "image_url": "https://example.com/cat.png" }],
"prompt": "Give the cat a small red hat"
}'Billing
Billed the same way as image generation. See the Model Square for prices.