API
Images
POST /images/generations: images as base64, priced per image.
Request
`POST /images/generations` takes `prompt`, optional `model` (an image model id from `/models`), `n` (1 to 4), `size` (each model lists its sizes on `/models`; the default is `1024x1024`) and `quality` (`low`, `medium` or `high`; the default is the provider's medium). Images are returned as `b64_json` only: Allwit keeps no copy of your images, so there is nothing to serve from a URL, and `response_format: "url"` is refused with 400.
The WIT reserved and charged is the model's `per_request` price times `n`, whatever the size or quality.
from openai import OpenAI
client = OpenAI(
base_url="https://www.allwit.ai/api/v1",
api_key="aw_live_…", # from /app/account/api-keys
)
import base64
result = client.images.generate(
model="<an image model id from GET /models>",
prompt="A lighthouse at dusk, long exposure",
n=1,
response_format="b64_json",
)
open("lighthouse.png", "wb").write(base64.b64decode(result.data[0].b64_json))import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://www.allwit.ai/api/v1",
apiKey: process.env.ALLWIT_API_KEY, // aw_live_…
});
const result = await client.images.generate({
model: "<an image model id from GET /models>",
prompt: "A lighthouse at dusk, long exposure",
n: 1,
response_format: "b64_json",
});
await fs.promises.writeFile("lighthouse.png", Buffer.from(result.data[0].b64_json, "base64"));curl https://www.allwit.ai/api/v1/images/generations \
-H "Authorization: Bearer $ALLWIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "<image model id>", "prompt": "A lighthouse at dusk", "n": 1}'