Tokenify
Get API keyConsole
Menu

Images with the google-genai SDK

generateContent, with your parts array and generation config unchanged — answered by Seedream, which is what you are buying.

View as markdown
These are not Google’s models and we do not sell them. What carries over is the request shape: the same SDK, the same contents, the same generationConfig. Asking for gemini-… here is a 404 that lists what we do serve, because the alternative is you believing you bought something you did not. Tokenify is not affiliated with Google.

What you change

Three things: the base URL, the key, and the model name.

import os
from google import genai
from google.genai import types

client = genai.Client(
api_key=os.environ["TOKENIFY_API_KEY"],
# their SDK defaults to v1; this endpoint answers on v1beta, as theirs does
http_options=types.HttpOptions(base_url="https://api.tokenify.dev", api_version="v1beta"),
)

res = client.models.generate_content(
model="seedream-5.0-pro",
contents="A still life of three pears, soft window light",
config=types.GenerateContentConfig(
response_modalities=["IMAGE"],
image_config=types.ImageConfig(aspect_ratio="16:9", image_size="1K"),
),
)
for part in res.candidates[0].content.parts:
if part.inline_data:
open("out.jpg", "wb").write(part.inline_data.data)
import { GoogleGenAI } from "@google/genai"

const ai = new GoogleGenAI({
apiKey: process.env.TOKENIFY_API_KEY,
// their SDK defaults to v1; this endpoint answers on v1beta, as theirs does
httpOptions: { baseUrl: "https://api.tokenify.dev", apiVersion: "v1beta" },
})

const res = await ai.models.generateContent({
model: "seedream-5.0-pro",
contents: "A still life of three pears, soft window light",
config: { responseModalities: ["IMAGE"], imageConfig: { aspectRatio: "16:9", imageSize: "1K" } },
})

The Python SDK reads both settings from the environment too — GOOGLE_GEMINI_BASE_URL for the base URL and GOOGLE_GENAI_API_VERSION=v1beta for the version — so two environment variables are enough if you would rather not touch the client. The version is the one that is easy to miss: without it the SDK asks for v1, which this endpoint does not serve, and the answer is a bare 404. The key goes in x-goog-api-key, which is where the SDK puts it; ?key= and Authorization: Bearer are accepted as well, and a header wins over a query parameter.

Model names

The path puts the model before a colon, so it cannot contain a slash — use the plain name. Both of these spellings work for each model:

ModelName here
Seedream 5.0 Proseedream-5.0-pro · seedream-5-0-pro
Seedream 5.0 Liteseedream-5.0-lite · seedream-5-0-lite
Seedream 5.0 Flashseedream-5.0-flash · seedream-5-0-flash

Sizes

imageConfig.aspectRatio and imageConfig.imageSize become one exact width and height — exact because you named the shape, so the model is not left to choose a different one.

imageSizeHere
512The model's smallest tier — nothing here generates anything that small.
1KThe 1K tier where the model has one, otherwise its smallest.
2KThe 2K tier.
4KThe 4K tier where the model has one, otherwise its largest.
(absent)The model's own default.

What that comes to in pixels, per model — the pair you send on the left, the exact width and height we send upstream and charge for on the right:

seedream-5.0-pro — imageSize maps onto 1K, 1.5K, 2K; 512 takes the smallest of those and 4K the largest.

aspectRatio1K1.5K2K
1:11024x10241536x15362048x2048
4:31152x8641792x13442368x1776
3:4864x11521344x17921776x2368
16:91424x8002048x11522816x1584
9:16800x14241152x20481584x2816
3:21248x8321872x12482496x1664
2:3832x12481248x18721664x2496
21:91568x6722352x10083136x1344

seedream-5.0-lite — imageSize maps onto 2K, 3K, 4K; 512 takes the smallest of those and 4K the largest.

aspectRatio2K3K4K
1:12048x20483072x30724096x4096
4:32304x17283456x25924704x3520
3:41728x23042592x34563520x4704
16:92848x16004096x23045504x3040
9:161600x28482304x40963040x5504
3:22496x16643744x24964992x3328
2:31664x24962496x37443328x4992
21:93136x13444704x20166240x2656

seedream-5.0-flash — imageSize maps onto 1K, 1.5K, 2K; 512 takes the smallest of those and 4K the largest.

aspectRatio1K1.5K2K
1:11024x10241536x15362048x2048
4:31152x8641792x13442368x1776
3:4864x11521344x17921776x2368
16:91424x8002048x11522816x1584
9:16800x14241152x20481584x2816
3:21248x8321872x12482496x1664
2:3832x12481248x18721664x2496
21:91568x6722352x10083136x1344

The ratios published for each tier on the image generation page resolve to exactly those sizes. The other ratios this SDK accepts — 1:4, 4:1, 1:8, 8:1, 4:5 and 5:4 — are computed: the tier’s own area at the ratio you asked for, each side rounded to a multiple of 16 (which is the grid every published size sits on), then clamped into the model’s pixel range. The reply tells you what you got, and the width and height we sent are what you are charged for.

More ratios than that API takes. Google’s own aspectRatio is a fixed list; here any W:H inside the model’s range works — 7:3, 5:2, whatever your layout needs — because the size is computed from the tier’s area rather than looked up. Code written for that API keeps working; code written for this one may not move back.

A ratio outside the model’s range — beyond 1:16 either way — is a 400 rather than a squashed picture, and so is one that cannot be produced between 0.92 megapixels and 4.62 megapixels.

What carries over, and what does not

FieldHere
contents[].parts[].textThe prompt. Several text parts are joined.
contents[].parts[].inlineDataA reference image. snake_case inline_data is accepted too.
contents[].parts[].fileDataA reference image, if fileUri is a public https URL. Their file service URIs mean nothing here.
generationConfig.candidateCountHow many images, within the model’s ceiling.
generationConfig.responseModalitiesIMAGE or [TEXT, IMAGE]. A text-only request is a 400 — there would be no image in the reply.
generationConfig.imageConfigThe size and the shape. See above.
temperature, seed, topP, topK, safetySettings, systemInstruction, thinkingConfig, toolsAccepted and ignored. None of them changes what these models generate, and refusing them would break an unchanged SDK call.
:streamGenerateContentA 400 for now. The reply is one document.

A content refusal comes back the way yours does: a 200 with finishReason: "IMAGE_SAFETY" and no image part. Nothing is charged for it.

Layer decomposition is not available through this shape — it has no equivalent concept here. Use either of the other two.

Errors

google.rpc.Status, which is what the SDK raises from:

{ "error": { "code": 400, "message": "…", "status": "INVALID_ARGUMENT" } }

UNAUTHENTICATED for a key problem, PERMISSION_DENIED for a key that may not use that model, NOT_FOUND for a model we do not serve, RESOURCE_EXHAUSTED for a rate limit or an empty balance, UNAVAILABLE and INTERNAL for our side.

Last updated 2026-10-13.