POST /api/v1/generate-texture

Texture generation API for AI agents

One POST request turns a base image into the PBR maps a game engine imports. Use it from a script, a CI job, or a coding agent.

GenPBR's API turns one base image into normal, roughness, metallic, ambient occlusion, and height maps. Send the image as base64 in a POST to /api/v1/generate-texture with an X-API-Key header. Each map returns as a PNG data URL in the JSON response. A free key covers 25 requests a month, no card needed.

Free key · no card · 25 requests a month · 5 a minute

Normal map generated from the sample albedo texture
01

Four steps from an agent to a map file

  1. 01

    Check that the API is up

    GET /api/v1/health-check needs no key. A healthy service returns HTTP 200 and status "healthy". A 503 means the service is degraded or down, so wait and retry instead of sending the image.

  2. 02

    Store one key in the environment

    Create a key at /dashboard/api-keys (up to 5 keys per team) and save it as GENPBR_API_KEY. Keep it out of source files and prompts.

  3. 03

    Send the image and the map list

    POST the base image to /api/v1/generate-texture. Set textureTypes to the maps you need from normal, roughness, metallic, ao, and height. Send the key as the X-API-Key header or as a Bearer token.

  4. 04

    Decode each map and read the quota

    Each value in textures is a data:image/png;base64 string. Strip the prefix, decode the base64, and write the PNG. Read usage.remainingQuota from the same response, or call GET /api/v1/usage-stats.

Request

curl -X POST https://genpbr.com/api/v1/generate-texture \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $GENPBR_API_KEY" \
  -d '{
    "baseImage": "<base64 PNG>",
    "textureTypes": ["normal", "roughness", "metallic", "ao", "height"]
  }'

Response, trimmed

{
  "success": true,
  "textures": {
    "normal": "data:image/png;base64,iVBORw0KGgo...",
    "roughness": "data:image/png;base64,iVBORw0KGgo...",
    "metallic": "data:image/png;base64,iVBORw0KGgo...",
    "ao": "data:image/png;base64,iVBORw0KGgo...",
    "height": "data:image/png;base64,iVBORw0KGgo..."
  },
  "metadata": { "width": 1024, "height": 1024, "processingTime": 1250, "...": "..." },
  "usage": { "remainingQuota": 24, "monthlyQuota": 25, "rateLimit": 5 }
}
02

The numbers an agent needs

API facts for generate-texture
EndpointPOST https://genpbr.com/api/v1/generate-texture
AuthenticationX-API-Key: <key>, or Authorization: Bearer <key>
Required fieldsbaseImage (base64 or a data URL) and textureTypes (a non-empty array)
Map typesnormal, roughness, metallic, ao, height. Albedo is the input, not an output
Output formatPNG for every map, as data URLs in the JSON response
Body limit4 MB on this route. Larger bodies return 413. Base64 adds about a third to file size, so keep the source image near 3 MB or less
Normal map conventionOpenGL green by default (Roblox, Unity, Blender). Set options.invertNormalY to true for DirectX engines such as Unreal
Free tier25 requests a month per team, shared by all its keys. Any signed-in team that has never subscribed. No card
Free rate limit5 requests a minute per key
Quota windowCalendar month, counted from the 1st
Repeat requestsAn image and map type generated before do not use quota again
Health checkGET /api/v1/health-check, no key
Usage checkGET /api/v1/usage-stats, with the key

Optional settings, under "options"

Options for generate-texture with defaults and ranges
SettingDefaultRange
normalStrength50.1 to 5
roughnessIntensity20.1 to 5
metallicIntensity0.80.1 to 5
aoIntensity20.1 to 5
aoRadius121 to 12
heightContrast10.1 to 3
heightBrightness0-0.5 to 0.5
heightInvertfalsetrue or false
invertNormalYfalsetrue or false (true gives DirectX green)

Put these under "options" in the body. A value you send is clamped to its range. An omitted value uses the fallback.

03

What goes wrong, and what the response says

  • 401, "API key is required"

    No key reached the server.

    Fix: Send X-API-Key, or an Authorization Bearer header.

  • 401, "Monthly quota exceeded"

    The team has used its monthly quota.

    Fix: Read usage-stats. Free teams wait for the next calendar month, or move to a paid plan at /pricing.

  • 429, "Rate limit exceeded"

    The key sent more requests than its minute allowance (5 on the free tier).

    Fix: Wait 60 seconds, then send the same request again.

  • 413, "Request body too large"

    The base64 body is over 4 MB.

    Fix: Resize the source image before you encode it.

  • 400, "Invalid texture types"

    A name in textureTypes is not on the list.

    Fix: Use the names in the validTypes field of the response.

  • 400, "Invalid image data"

    baseImage is not valid base64.

    Fix: Encode the file bytes as base64, or send a data URL with a complete payload.

  • 500, "Failed to generate textures"

    Generation failed on the server.

    Fix: Retry once. If it fails again, report the request size and the response on /support.

  • 402, "Insufficient quota"

    The request needs one use per map, and the team has fewer uses left. Nothing is generated and nothing is counted.

    Fix: Send fewer texture types, or split the batch across months. A repeat of an earlier request is free and skips this check.

04

When the API is the wrong tool

Use the API when a script, a CI job, or an agent runs the same steps on many images.

The browser tool at /generate needs no key and no code. It suits one image at a time, with a person adjusting the settings. The API does not generate textures from a text prompt, make 3D meshes, or write Substance Designer graphs. For those jobs, the comparison page at /compare lists the other tools.

05

Questions agents and developers ask

Can an AI agent generate PBR maps without a person in the loop?
After a person creates a key, yes. The agent reads the key from GENPBR_API_KEY and calls POST /api/v1/generate-texture. Keys are made in the dashboard, not by the API, so the first key always needs a signed-in account.
Does the free API tier need a credit card?
No. Any signed-in team that has never subscribed gets 25 requests a month, shared by all its keys, with a limit of 5 requests a minute per key. Paid plans raise both numbers.
Which file format do the maps come back in?
PNG. Each map you asked for is a separate data URL in the textures object. The metadata reports the width and height of the output.
Can an agent check the API without using quota?
Yes. GET /api/v1/health-check needs no key and reports the service status. GET /api/v1/usage-stats uses your key and returns the month to date. Neither call generates a texture.
Does the API return the albedo or the source image?
No. Albedo is the input. The API returns normal, roughness, metallic, ao, and height maps.
06

For agents

The same steps work without this page. Ask for this page with Accept: text/markdown to get the same copy as plain text.

Make the first call

A free key needs a signed-in account and no card. Your first request uses one of the 25 monthly requests.