Better Gradient

(beta)
HomeGalleryGuideDevelopersResourcesBlog
Gradient background exampleCreate Gradient
DevelopersPublic API

Build gradients programmatically with the Better Gradient API

Generate mesh gradients on-demand in SVG, PNG, WebP, or CSS. The API is designed to be deterministic, fast, and easy to integrate into your product or pipeline.

Request API keyView API reference
Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

Formats

SVG, PNG, WebP, CSS

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

Deterministic

Seed or email inputs

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

Canvas sizing

width / height / size

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

Rate limits

30/min public • 300/min with key

Base URL

https://better-gradient.com/api/gradient

API reference

Everything you need to integrate the gradient API into your product.

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

Endpoint

GET /api/gradient

Use query parameters to customize output format, size, and generation seed.

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

Authentication

Add your API key as a bearer token to access higher limits (300/min per key). Public traffic is limited to 30/min per IP.

Authorization: Bearer YOUR_API_KEY
Parameter
Description
Default
format
Output type: svg, png, webp, css.
svg
width
Output width in pixels.
1920
height
Output height in pixels.
1080
size
Shortcut to set both width and height.
-
seed
Deterministic seed for repeatable gradients.
-
email
Derive a deterministic seed from email.
-
count
Number of shapes (3-10).
6
quality
WebP quality (0-1 or 1-100).
0.95
If you pass both seed and email, the seed takes precedence. Width and height override size when both are provided.
Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

cURL example

curl -H "Authorization: Bearer YOUR_API_KEY" \
  -o mesh.webp \
  "https://better-gradient.com/api/gradient?format=webp&width=1600&height=900&seed=hello"

Replace the seed value to generate a unique gradient.

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

Fetch SVG

const res = await fetch(
  "https://better-gradient.com/api/gradient?format=svg&size=1200&seed=sunrise"
);
const svg = await res.text();

The response body is the raw SVG markup.

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

CSS background

const css = await fetch(
  "https://better-gradient.com/api/gradient?format=css&size=1200&seed=studio"
).then((r) => r.text());
document.body.style.cssText = css;
Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

Response types

  • svg → image/svg+xml
  • png → image/png
  • webp → image/webp
  • css → text/css
Errors return plain text with status 400 or 500. Rate limits respond with 429 and include X-RateLimit headers.

Confirmation flow

Secure confirmation ensures keys are generated only by the owner.

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor
01

Request access

Submit your email to receive the confirmation link.

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor
02

Confirm your email

Open the email link to generate a key tied to your address.

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor
03

Receive your API key

Your key is revealed once and ready to use.

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

Request Access

Get your API key

Gradient sample

You will receive a confirmation link by email to generate your key.

Top-left cursorTop-right cursorBottom-left cursorBottom-right cursor

Build with Better Gradient

Create your first mesh gradient in the editor or integrate the API into your stack.

Open the Editor

Better Gradient

Free mesh gradient generator for modern web design

Product

  • Gradient Editor
  • Gallery

Resources

  • Guide
  • Developers
  • Blog
  • Resources

Connect

  • Twitter/XTwitter/X
  • GitHubGitHub
  • Share feedback

© 2025 Better Gradient. All rights reserved.