Images
Make images from a prompt with any image model.
Image models use OpenAI's Images API, so images.generate in any OpenAI SDK
works with the same base URL and key as text.
import { writeFile } from "node:fs/promises"
import OpenAI from "openai"
const ai = new OpenAI({
apiKey: process.env.UPSKY_API_KEY,
baseURL: "https://api.upsky.dev/v1/ai",
})
const image = await ai.images.generate({
model: "bfl/flux-2-pro",
prompt: "A lighthouse on a cliff at dawn, watercolor",
size: "1024x1024",
})
await writeFile("lighthouse.png", Buffer.from(image.data[0].b64_json, "base64"))Get the image models from the
models endpoint with ?type=image.
Options
n: how many images to make, from 1 to 4. Each one is charged.size: width and height in pixels, such as1024x1024. Each model supports its own sizes.aspect_ratio: width to height, such as16:9, for models that take a ratio instead of a size.seed: makes results repeatable, on models that support it.
Images always come back as base64 in b64_json, never as links, and Upsky
doesn't keep them. Other fields, such as quality or style, are ignored.
What it costs
Most image models charge a set price per image, listed on the models
endpoint as pricing.image. Some charge more for larger sizes, listed under
pricing.image_sizes. A size between two listed ones costs what the next
one up does, and a size larger than the largest is refused.
A few models, such as OpenAI's, are priced by tokens, like a text model. Upsky sets aside an estimate before the request and charges what the provider reports.
You're charged only for the images that come back. usage.cost on the reply
says what the request cost, in US dollars.
Test keys
A test key gets a 1×1 transparent PNG for each image asked for. It never calls a model and is never charged.