For AI agents: this page is also available as Markdown at https://docs.refabric.com/task-api-reference/pattern.generate.md, and the index of every page is https://docs.refabric.com/llms.txt.

Design generation

Generate textile patterns

Create textile repeats from a prompt and optional reference images. Each pattern is delivered as an image file you can reuse as a print.

Endpoint: POST https://api.refabric.com/v1/tasks/pattern.generateTask: pattern.generateScope: tasks:runCategory: Design generation

Quick start

import os
import time
import requests

headers = {"Authorization": f"Key {os.environ['REFABRIC_API_KEY']}"}

job = requests.post(
    "https://api.refabric.com/v1/tasks/pattern.generate",
    headers=headers,
    json={
        "prompt": "small tossed florals on a deep navy ground, two-colour",
    },
).json()
print(job["job_id"])

while True:
    status = requests.get(job["status_url"], headers=headers).json()
    if status["lifecycle"] == "terminal":
        break
    time.sleep(5)

print(requests.get(job["result_url"], headers=headers).json())

cURL waits for the result with Prefer: wait; when the job outlives the wait, it answers 202 with the job's URLs.

Input schema

  • stringrequired

    What the repeat should show — motif, scale, colours, style. Required, also with references.

    Example: small tossed florals on a deep navy ground, two-colour

  • stringoptionalDefault: 2K

    How large each repeat is. 2K is sharp enough for screens and review; ask for 4K when the result will be printed or zoomed into.

    Values

    • 2K — Standard size, for screens and review.
    • 4K — Large size, for print and zoom. When the image will be printed or zoomed into.

    Example: 2K

  • integeroptionalDefault: 1

    How many repeats to make, 1–40. Each delivered repeat is charged; one that fails is not. One, so you see a first result before you ask for more. Higher makes more independent repeats in one job, each from the same request.

    1 to 40

    Example: 2

  • array<object>optional

    Up to 14 images to base the repeat on, each {image, fidelity}: a print photo, a swatch, an image.extract_print result or any earlier file. The whole pattern follows ONE fidelity, the first reference's; a fidelity on a later reference is refused.

    at most 14 items

    Example: [{"image":"art:a1b2c5","fidelity":70},{"image":"https://files.example.com/pattern.generate/1.jpg"}]

  • stringoptionalDefault: auto

    The shape of the repeat, as width:height. auto follows the first reference's shape; with no reference a suitable shape is chosen. auto lets your first reference set the repeat's shape, so a print photo or swatch keeps its proportions; with no reference the shape is chosen for you. Name a ratio when the repeat must fit a fixed shape.

    Values

    • auto — Keep the shape of the input image; with none, a suitable shape is chosen.
    • 1:1 — Square. For square places: product grids and social posts.
    • 3:4 — Portrait, slightly taller than wide. For portrait product pages.
    • 4:3 — Landscape, slightly wider than tall. For landscape layouts and slides.
    • 9:16 — Tall portrait, as for phone screens and stories. For phone screens: stories and reels.
    • 16:9 — Wide landscape, as for banners and video. For banners, headers and video frames.
    • 2:3 — Portrait, as for a classic photo print. For a portrait print or a lookbook page.
    • 3:2 — Landscape, as for a classic photo print. For a landscape print.
    • 4:5 — Portrait, as for social feeds. For portrait posts in social feeds.

    Example: 1:1

Output schema

  • array<object>optional

    One repeat image (image/*) per delivered pattern, each on a new design record. Pass one on as a reference (image.generate with use_case: "print") or to an edit.

  • objectoptional

    How many repeats came back. It can be fewer than image_count: one that fails is left out and not charged.

Required-fields example

{
  "prompt": "small tossed florals on a deep navy ground, two-colour"
}

Full example

{
  "prompt": "small tossed florals on a deep navy ground, two-colour",
  "references": [
    {
      "image": "art:a1b2c5",
      "fidelity": 70
    },
    {
      "image": "https://files.example.com/pattern.generate/1.jpg"
    }
  ],
  "resolution": "2K",
  "aspect_ratio": "1:1",
  "image_count": 2
}

Response example

{
  "job_id": "5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968",
  "lifecycle": "queued",
  "status_url": "http://v3-api.refabric.com/v1/jobs/5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968",
  "result_url": "http://v3-api.refabric.com/v1/jobs/5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968/result",
  "cancel_url": "http://v3-api.refabric.com/v1/jobs/5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968/cancel"
}

Result example

{
  "job_id": "5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968",
  "files": [
    {
      "file": "art:7c1e01",
      "url": "https://files.example.com/pattern.generate/2.png",
      "media_type": "image/png",
      "task": "pattern.generate",
      "job_id": "5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968",
      "created_at": "2026-10-01T10:02:11Z"
    },
    {
      "file": "art:7c1e02",
      "url": "https://files.example.com/pattern.generate/3.png",
      "media_type": "image/png",
      "task": "pattern.generate",
      "job_id": "5f0c2a1e9b8d4c7a8e6f1d2c3b4a5968",
      "created_at": "2026-10-01T10:02:12Z"
    }
  ],
  "has_more": false,
  "summary": {
    "delivered": 2
  }
}

The first reference's fidelity (70) applies to both references: their motifs and layout are kept. aspect_ratio is left out, so the repeat takes the first reference's shape. Each repeat is saved as a new design.

Describe a print — its motif, scale, colours and style — and get textile repeats back. Add reference pictures such as a print photo, a swatch or an extracted print, and set on the first one how closely every repeat follows them. Each repeat is saved as a new design you can pass on as a print.

Built for

  • Prints for a new collection
  • A repeat built from a print photo or a swatch
  • Prints to apply to your garment designs

What you get

  • One repeat image per delivered pattern, each saved as a new design.
  • A summary whose delivered counts the repeats that came back — the ones charged.

Specs

Input formatsImages, each one string: a URL, an upload (file:…) or a file from an earlier result (art:…). Upload types and sizes: GET /v1/meta limits.upload.
Input countreferences: up to 14, each with its image
Output formatFiles: each one line with its url and its media_type, in the job's result.
Output resolution2K, 4K
Aspect ratiosauto, 1:1, 3:4, 4:3, 9:16, 16:9, 2:3, 3:2, 4:5
Outputs per jobOne file per delivered repeat, up to image_count.

Choosing a task

Errors

Good to know

  • image_count is from 1 to 40.
  • references holds at most 14 items.
  • references[].fidelity is from 0 to 100.

Pricing: Estimate a request before you run it, or see the price of each option.

For agents and code generation

Schema changes follow Versioning.