Introduction
Operations
Platform
Image APIs
Flux.1 Kontext API
Maintain brand consistency with style tokens, semantic locks, and layered PSD outputs for downstream editing. · Updated 2025-03-18
Overview
Flux.1 Kontext applies reusable style tokens and semantic constraints to produce on-brand visuals. Each render can export layered PSD assets, making it well-suited for marketing teams and creative operations.
Style Tokens
- Create tokens via the dashboard or
POST /style-tokens. - Each token stores palette, typography, texture, and composition rules.
- Reference tokens in requests to reapply the same look across campaigns.
Example Request
curl -X POST "https://api.transendai.net/v1/images/flux-kontext/generation" \
-H "Authorization: Bearer $TRANSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Surreal gradient background with a single hero product centered",
"style_token": "@sunset_glow",
"semantic_locks": {
"subjects": 1,
"hero_position": "center"
},
"output": { "type": "psd", "layers": ["background", "subject", "foreground"] }
}'
Response Payload
{
"image": {
"url": "https://edge.transendai.net/flux/task_fx91.psd",
"layers": [
{ "name": "background", "url": "https://edge.transendai.net/flux/layers/task_fx91_bg.png" },
{ "name": "subject", "url": "https://edge.transendai.net/flux/layers/task_fx91_subject.png" }
],
"brand_score": 0.93
}
}
brand_score indicates how closely the output adheres to the token rules (0–1).
Semantic Locks
| Constraint | Description |
|---|---|
subjects | Enforce the number of primary subjects (e.g., 1 hero product). |
hero_position | Values: center, left, right, custom with coordinates. |
color_exclusion | Prevent specific colors (hex values) from appearing. |
Versioning Style Tokens
Update a token by PATCHing the resource:
curl -X PATCH "https://api.transendai.net/v1/style-tokens/%40sunset_glow" \
-H "Authorization: Bearer $TRANSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "palette": ["#FF8A65", "#FFC371", "#FFD452"] }'
Changes propagate to subsequent renders immediately.
Error Codes
| Code | Meaning | Resolution |
|---|---|---|
404 | Unknown style token. | Confirm token exists and is prefixed with @. |
409 | Semantic constraints conflict. | Adjust locks (e.g., subjects count) to match the prompt. |
422 | PSD layer mismatch. | Limit layers to background, subject, foreground, or effects. |
Best Practices
- Keep a design review loop by logging
brand_scoreto analytics. - Use
color_exclusionto avoid restricted hues for regulated industries. - Store PSD layer URLs in your DAM for future revisions.