Edit with AI in the editor
The Edit with AI prompt box floats at the bottom center of the editor canvas, including when you are signed out. Describe a new design or changes to the current artwork, then choose the cyan up-arrow button or press Enter. Hover over the usage ring for AI usage; click it for daily and monthly allowances and progress bars. Choose + to attach one PNG, JPEG or WebP reference image (up to 10MB before resizing). Choose + again to replace it, or X on its preview to remove it. You can also drag one image onto the prompt box. It highlights and shows drop image here instead of the prompt and controls; leaving the box restores them without changing your text. Dropped images use the same size limits and replace any current reference. Images are converted locally to a still PNG, with metadata removed, at most 512px per side and 128KB. Detailed images may be reduced further to fit the byte limit. The server independently validates dimensions, byte size and image data before reserving tokens. Use Shift+Enter for a newline. If you are signed out, this opens sign-in and returns you to the same editor afterward, preserving your prompt. The prompt grows with its content up to three rows, then scrolls vertically. Only signed-in accounts can send generation requests. Your prompt, document summary, optional reference image and relevant artwork JSON are sent to Google Gemini; do not include sensitive information. Select layers or folders to show dashed candidate pills, then choose their + buttons to attach them. Attach several items by changing the selection; attached pills stay until you remove them or their targets are deleted. Reference images share this pill row and keep their thumbnail inside the pill. Layer pills show the same artwork previews as the layer list. Each attachment includes its current artwork JSON and document path. Prompts, reference images and artwork attachments are preserved in this tab when returning from sign-in. Reference images are not inserted into or saved with the artwork project.
Generate or edit image layers
Advanced members can ask for raster images, for example: "Generate a photograph of a misty forest as a background." To edit image contents, attach an existing image layer and ask, for example: "Make the sky in this photo sunset orange." Gemini generates a new PNG, JPEG, or WebP file; image edits replace only the selected layer's image reference, preserving its layout and styling. CSS/vector artwork and editable reference reconstruction continue to use native layers.
Image generation uses the existing AI token allowance and image-storage limits. Generated images and authorized source images for editing are sent to Gemini; do not use sensitive images. Provider refusals or failed uploads do not apply partial artwork.
If your artwork is unsaved, the editor saves it only after generated images are returned, then uploads those files to private storage and applies the complete edit. Ordinary AI edits do not automatically save. Use Update to keep the new image layers. Undo restores the previous artwork and image references; existing saved-removal rules still apply. Fork another user's project before generating images into it. Generated image data is not stored in project JSON or local drafts.
Reference-image prompts without attached artwork layers use an experimental
native JSON → rendered feedback → one correction path.
Except for explicit raster requests, Advanced reference prompts also use this
path after the planner selects native construction. Gemini returns new,
editable project layers directly; the server fills omitted native defaults and
validates them with the project schema and current aggregate budgets.
The server measures source pixels: exact dominant palette colors, bounds,
centers, principal axes and transparent spans. Safe shared-coordinate arithmetic
and source-space path normalization support deliberate geometry without executing
model-written code. Selected source regions can be fitted to native one/two-color
rectangles and rounded rectangle shapes with clipped paint, or traced into editable Bézier contours
with transparent holes. Tracing removes pixel stair-steps and fits broad Bézier
spans while retaining strong corners, rather than making a tiny cubic for each
pixel edge. The default fitting tolerance is two source pixels.
Fitting is an estimate, not general image segmentation;
palette regions may contain disconnected parts, and complex traces can exceed
the editor's limits. Existing artwork, document settings,
variables, bindings, fonts and clone sources are preserved locally rather than
rewritten by the model. New layers are added in front of existing artwork.
Chromium renders only the new artwork with the same native CSS/markup used by
HTML export, so existing artwork does not contaminate the comparison. Gemini
receives both the original reference image and that actual render for one
bounded, focused correction to generated parts. The corrected project is
validated and rendered again before being applied. Alpha-silhouette overlap and
premultiplied pixel differences provide diagnostics; a correction that worsens
pixel error without improving the silhouette retains the validated draft.
The correction also receives per-shape anchor and short-edge counts. Densifying
the same contours with more sub-two-pixel edges cannot replace the cleaner draft;
when visual scores tie, the less complex contour wins. Shaded silhouettes can
declare one inline gradient, which the server expands to editable native paint
and its clipping base in the correct stacking order.
Measured rectangular fits also accept an optional paint override without
replacing their measured geometry or rectangle clipping base. Linear/conic
override angles are converted from the source pose into the fitted folder's
rotated frame; other paint parameters are local to the fitted part. Omitting
the override retains the automatically sampled finish.
This is visual feedback, not an objective quality
score or a guarantee of reference fidelity: silhouettes and pose can still be
wrong. Invalid corrections fail the run rather than triggering more attempts.
Preview rendering blocks network requests and scripts; external-only fonts are
not loaded in this isolated preview. Local servers need Chromium installed for
playwright-core, or CHROMIUM_EXECUTABLE_PATH pointing to an existing browser.
Hosted rendering uses the existing @sparticuz/chromium dependency.
Investigating a failed run
Generation failures show a Reference ID in the editor. Match it to runId
in the server's [ai] Edit failed log, or the
X-GradientArt-AI-Run-ID response header. Logs include the stage, native phase
(for example draft-validation or correction-render), elapsed time, calls,
tokens and validation rules. Semantic rules such as clipping,
variable_binding and project_budget are reported even when there is no
JSON-schema error. Ordinary logs and public errors do not include artwork,
prompts, model output or reference pixels.
For exact local investigation, stop the development server and restart with:
AI_DEBUG_TRACE=1 npm run dev -- --port 3013
This opt-in works only in local development, not production or Vercel.
Each run writes a private, Git-ignored .ai-traces/<runId>/ directory.
outcome.json contains the exact error, stack and validation details.
call-N-request.json and call-N-response.json retain the model inputs,
visible output and usage, including malformed output. Native runs also retain
the construction recipe, candidate before validation and any rendered previews
(PNG data encoded in JSON). These artifacts let you inspect the rejected
candidate without making another billed model call. API-key headers and model
thought text are not captured.
Traces contain private prompts, images and project data. Do not commit or
share them without review. Storage is limited to 32 MiB per run; capture errors
are logged without changing the generation result. There is no automatic
retention cleanup: delete the specific run directory when finished. Restart
without AI_DEBUG_TRACE=1 to disable capture. Earlier failures cannot be
recovered retroactively if capture was disabled.
Other AI editing uses PLAN → IMPLEMENT → VERIFY, including prompts with
explicitly attached artwork layers. The planner receives a compact
document tree and explicit attachments. Each plan item starts a fresh worker
conversation with relevant JSON from the latest in-memory document, not the
entire project or previous workers' chat history. Workers use artwork tools for
layers, folders, properties, SVG paths, clipping, clones and variables. There
are no zoom, pan or history tools. The tools also expose native folder borders
and shadows: ask for stacked Solid, Dashed, Dotted, Waves, or
Squiggle rows with inside, center, or outside placement, rather than duplicate
outline shapes. Border widths remain fixed when a folder scales. Rectangle
rounding is a shape property, not a folder property. Workers can discover the
current schemas, defaults, and binding paths through describe_properties.
Gemini's structured output returns a
flat operations list instead of native function calls. Each entry contains
tool, JSON-encoded arguments, and an output alias as (or null).
The list is the batch: operations execute sequentially and atomically against
the updated document. Multiple calls to the same tool are supported.
Workers receive a schema-derived catalog with explicit argument contracts;
complex batch schemas are not hidden inside the model's native tool template.
Local validation retains the editor's original schemas and RGBA constraints.
Array-length caps are enforced locally rather than in Gemini's decoding schema,
where large limits can exceed the provider's decoding-state capacity.
A shape's paint stays in gradient.figure; texture settings belong to
a separate texture layer. Only folders can contain nodes; base layers and
their overlays must be siblings.
Verification checks completion, recorded effects and project validity without
another AI call; it does not evaluate the visual quality of the result.
Drawing instructions are subject-independent: the planner describes structural
parts, proportions, placement and materials; workers construct the SVG geometry,
frame it closely and use separate layers for different paints.
Illustration plans specify shared part bounds, axes and attachment coordinates.
Unspecified poses use a clear flat, axis-aligned construction; workers establish
connected primary silhouettes before adding aligned shading or detail.
Descriptions allow up to 1,000 characters for this shared layout within the
unchanged run budget. Adding artwork does not imply removing existing layers
or apparent placeholders.
New standalone illustration plans request canvas containment. After verification,
the app measures only new artwork with the editor's native geometry, including
folder rotations and resolved bindings. If it overflows, an outer folder
uniformly shrinks and recenters it without rewriting its editable parts.
Existing artwork and attached edits are not moved; intentional cropping,
patterns and full-canvas backgrounds retain their requested placement.
Folder translations are offsets from the canvas-centered rotation pivot,
not absolute center coordinates.
Each prompt is capped at 4 plan items and 6 Gemini generation calls. The total input/output budget is 40,000 tokens for Basic or 200,000 for Advanced, including thinking tokens. Read-only follow-ups count toward these limits. Every completed item must change the working document, and subsequent items see that change. Optional read-tool schemas are omitted when they would crowd out the worker's full implementation response budget; call and token caps remain unchanged. An oversized read result returns an explicit budget error to the worker rather than consuming the remaining implementation budget with whole-layer defaults. One focused correction per run can repair recoverable rejected tool arguments or invalid SVG geometry, or supply a missing planned tool. It uses the same call, token and time caps, reserves calls for remaining items, and does not retry the whole prompt. Rate limits, outages, interrupted calls and incomplete responses are not retried.
The entire editor is disabled while a prompt is being processed. The header, left tools and right sidebar dim to show that editing is blocked. A spinner replaces the send arrow; no dialog covers the artwork. A successful response is validated and applied automatically as one undoable edit, then the prompt text clears. Use Undo to restore the previous artwork. Each AI history entry has a short descriptive title, such as Added a sunset background, supplied with the original plan. The title covers the whole edit, survives Undo/Redo, and requires no additional AI call. Failures or exhausted budgets discard all staged edits and show an error. Failed submissions keep the prompt text so you can revise or retry it. Tokens already spent still count. If the AI returns the same project, the editor reports that no changes were made instead of adding an empty undo step. Changes are not saved automatically. Results cannot overwrite a different or newer project.
Basic accounts receive 40,000 tokens daily and 400,000 monthly. Advanced accounts receive 200,000 tokens daily and 2,000,000 monthly, counting input, output and thinking tokens. Counters reset at midnight UTC and the first of the month. A single conservative budget and account lease cover the entire run. Planning, reference images, tool schemas, worker inputs, read responses and model outputs all count. Reference images use Gemini's high media resolution, not base64 characters as text. Planning, implementation, read follow-ups and corrections can each receive the image, with at most six calls per run. A conservative 2,048-token image allowance per call is included in budget checks; settlement uses Gemini's actual reported usage. Unused tokens are returned when the run settles. A large document or attachment may not fit the remaining allowance even if a shorter request would. Invalid or incomplete AI responses still consume their reported tokens. If a call's usage cannot be confirmed (for example, after a timeout), only that call's bounded authorization is charged conservatively, together with earlier consumed tokens. A provider rejection refunds that call, not prior completed calls. Gemini's shared provider limits also apply, even to unlimited accounts.
Server configuration
Set GEMINI_API_KEY on the server (never a NEXT_PUBLIC_ variable), then restart
the server. For local development, use the Git-ignored .env.development.local;
this can hold the Gemini key without changing a shared .env.local symlink.
An unlimited account allowance does not mean the running server has
loaded the provider key. Configuration errors are shown when you submit; a stale
or unavailable allowance display does not block generation.
The editor uses Google's gemini-3.8-flash model, available on the Gemini API free tier.
Requests use the native generateContent REST API with JSON responses
(schema-constrained for the planner and tool workers),
one candidate and low thinking. maxOutputTokens bounds both thinking and visible
output; reported input, output and thinking usage all count toward allowances.
Workers can allocate up to 8,192 response tokens per call from the plan's
run budget so thinking does not crowd out multi-layer artwork output.
When the conservative byte estimate would reduce that allocation, the server
first calls Gemini's countTokens endpoint with the same input, including the
reference image, and retains framing headroom. It never replaces a real token
count with a characters-per-token guess. Counting failures stop that call before
generation; actual generation usage is still checked and charged.
Token-count preflights do not generate output or consume a generation-call slot.
The server run timeout is 105 seconds, shorter than both the 120-second client
timeout and 180-second quota lease.
Cached input is included in reported prompt usage and is not counted twice.
No Groq key or fallback provider is used.
On the free tier, Google may use inputs and outputs to improve its products,
including human review. Review the Gemini API terms
before public rollout; Google requires paid services for API clients available
to users in the EEA, Switzerland or the United Kingdom.
Planning uses a bounded JSON schema; workers receive only the tools applicable
to their item. Instructions live in utility/ai-planner-prompt.md and
utility/ai-system-prompt.md; native generation and visual correction share
utility/ai-native-prompt.md and utility/ai-native-correction-prompt.md. Operation transport and focused tool correction have
their own utility/ai-tool-*-prompt.md files. Instructions are read when used,
so changing a prompt does not require restarting a development server.
The loop and each tool have dedicated implementation
files under utility/ai/, with constants and schemas in .const.js files.
Creation tools merge properties with the editor's current defaults.
Creation can set geometry, colors and material properties in one operation;
defaults fill only omitted fields. Dependent creation and edits can run in a
single sequential batch, without another implementation iteration.
Creation arguments are inline: solid layers accept an RGBA color, and
draw_shape uses SVG-style d, viewBox, fill, stroke and strokeWidth
alongside layer position, size and repeat. The executor maps these into
canonical artwork JSON. Existing nested properties and path arguments
remain supported locally; conflicting duplicate fields are rejected.
Texture palettes use gradient.texture.foreground and background RGBA colors.
The built-in presets are paper, clouds, marble and wood; other materials can be
composed from fills, patterns and custom SVG paths.
Shape creation and drawing tools list supported layer and figure fields and
reject unknown properties before applying a document change.
Every tool describes its arguments. A read-only describe_properties tool
provides the complete property reference for documents, every layer family,
folders, clones and variables. It explains each control, accepted values,
ranges, array fields, conditional requirements and actual creation defaults,
derived from the editor's schemas and constructors. Optional missing fields are
explicitly marked as absent, rather than assigned invented defaults.
Workers can query up to four related JSON-pointer paths together, including
nested effects, bindings and font settings. Only requested groups are returned;
the full reference is not included in every prompt. These reads share the same
call/token limits and must be followed by a document-changing tool call.
Tree structure and clone-source fields remain managed by their dedicated tools.
Workers receive the original request as well as their plan item. Drawing context
includes the canvas bounds and the fixed 0 0 200 200 SVG shape viewBox:
the drawing tool requires an explicit source viewBox matching its path
coordinates and normalizes that path into the editor's fixed viewBox.
A 20-unit path can therefore use [0,0,20,20] without shrinking into a dot.
Context also supplies an optional centered illustration frame covering 80% of
the shorter canvas dimension. Paths may share that frame, or use tight local
viewBoxes with individual canvas bounds; the two placement conventions must not
be mixed. SVG normalization uses absolute coordinates before rounding so
relative-segment accumulation cannot reject a valid boundary endpoint.
Layer position and size remain canvas pixels; stroke widths remain editor units.
Reference recreation favors native CSS gradients for simple parts, rounded
rectangle clipping masks, and a single custom silhouette with clipped paint for
irregular multicolored parts. Folder children retain canvas coordinates and
folders never clip without masks. A common assembly transform rotates
around canvas center. Gradient stop positions are percentages, including
duplicate-position hard stops for flat two-tone finishes.
Reference images use high media resolution to preserve contour and finish
details. These construction instructions are subject-independent, not recipes
for particular objects. Schema validation does not guarantee visual fidelity;
reference recreation can still differ from the source image.
Workers discover defaults on demand through describe_properties, rather than
receiving sample geometry or randomly colored example defaults to copy.
Property edits accept JSON pointers or dotted paths. Keys containing literal
dots, such as binding paths, require a JSON pointer (/bindings/size.0).
Type-specific instructions include only the layer types created or edited by
the current item, including nested targets and nodes fetched by a read tool.
Workers receive the selected tree branches and their ancestors, plus artwork
created earlier in the current run, including its actual paint and geometry.
Folder subtrees are sent once, not repeated again for each included descendant;
the tree still supplies every descendant's handle.
Unrelated pre-existing artwork is omitted. The planner still receives the full
tree. This leaves more of the
existing per-prompt budget for implementation.
Server-side schema and semantic validation remain mandatory.
There are no model-generated project rewrites or unbounded retry loops.
Provider rejections log their status
and safe error codes, never the prompt or failed generated artwork, and show an
explicit error instead of hiding the cause behind a generic unavailable message.
Plan-validation failures log a specific reason, item index, known tool/layer
types and token usage in the server console. They never log the prompt, artwork,
descriptions, target values or raw model response.
Run failures show a short message in the editor; diagnostic codes, stages and
token-accounting details stay in the server console.
The failure summary includes a provider rejection's actual HTTP status/error
code, or an incomplete response's safe finish reason and response budget. It
never includes raw generated arguments, refusal text or provider error messages.
Numeric provider retry windows are included when Gemini supplies Retry-After
or a structured RetryInfo delay.
Development responses also include a sanitized diagnostic header for UI
debugging; production responses omit it. Unexpected argument names are logged
only when they match a fixed allowlist of known API/SVG fields.
Incomplete model responses log a safe finish reason, refusal flag and response
token budget, never their text. AI failure logs also include the error status.
If the next call cannot fit within the per-prompt budget, the console logs its
input and remaining budgets; the editor distinguishes this from account and
provider limits. Unlimited accounts still have the same per-prompt safety cap.
Artwork validation errors also log schema rules, required fields and limits,
without artwork values or document paths. New construction-guide groups inherit
missing fields from the editor defaults; existing guide limits still apply.
Required output aliases and planned mutation tools are checked after execution;
temporary aliases are also supported. Incomplete implementations
log AI_IMPLEMENTATION_INCOMPLETE, missing tool names and output counts, not
artwork names or generated arguments.
Missing planned mutations can continue against the staged document within the
same bounded worker and run limits, without replaying successful operations.
Accounts with the server-managed MongoDB admin role have no daily or monthly
AI token limits. Per-prompt safety caps and Gemini's provider limits still apply.
Access is never inferred from email. An operator can grant or revoke a separate
unlimited exception with:
node db/tools/set-ai-access.mjs <account-email> unlimited
node db/tools/set-ai-access.mjs <account-email> free
The script loads local server configuration and updates exactly one existing
account. Revoking an exception does not remove an admin's role-based unlimited
access. Usage reservations and counters live in ai_usage. There is currently
no subscription checkout. A server-managed tier: 'paid' grants Advanced AI
allowances. An active ai.paidUntil date also grants paid AI allowances; custom
ai.dailyTokens / ai.monthlyTokens values can increase them while the account
has a paid tier or active paid entitlement. Profile updates cannot change these
fields. Unlimited exceptions are separate from subscriptions and retain the plan's per-prompt cap.
Start with a prompt
Describe your idea to your favorite agent, then keep shaping the result in GradientArt. This works with web agents such as ChatGPT and local agents such as Copilot. No plugin, repository checkout, or GradientArt account is needed to open or import a design.
Paste into your agent, then replace the description in brackets with your idea.
Your agent creates the artwork; GradientArt validates it and opens it as editable layers. A documentation link does not grant an agent API access. What happens next depends on the tools your agent has.
Web agents, including ChatGPT
Paste the prompt into your chat. If the agent can call HTTP APIs, it can return an Open in GradientArt link. Browsing a website alone is not enough to make the required POST request.
If it cannot call the API, ask for a .gradient-art.json file instead. Open the
editor, choose Project actions > Import JSON, and select the file.
If the agent gives you a code block, save only the JSON as design.gradient-art.json
first. See Import an editable JSON file.
If your agent cannot browse the guide, download and attach the authoring guide, self-contained schema, and minimal example to the conversation. Do not ask it to guess the file format.
A dedicated ChatGPT GPT
A configured GPT can call the preparation API through an Action and return the editor link directly. There is no published GradientArt GPT linked here yet. The GPT setup kit includes ready-to-paste instructions, knowledge files, and a self-contained Action definition.
Creating and publishing a GPT depends on your ChatGPT account and workspace. OpenAI currently restricts new GPT creation on personal accounts and has announced a move toward plugins. Check OpenAI's current availability guidance before setting one up. The universal prompt and file-import route do not require a custom GPT.
Connect a ChatGPT plugin with MCP
If your plugin can generate designs but cannot make the POST request, connect the hosted MCP server at https://gra.dient.art/api/mcp using Streamable HTTP with no authentication. It exposes one tool, prepare_design, which accepts the complete versioned file in its document argument.
The MCP connection guide includes a prompt for updating your existing plugin without changing its identity or private visibility. The endpoint is publicly callable even if your plugin stays private.
The tool returns the same one-hour editor links and uses the same validation and quotas as the HTTP API. It does not save projects. Plugin availability and connection permissions depend on your account.
Copilot and local agents
Paste the same prompt into Copilot or another agent with terminal access. Allow it to read the public guide and, when asked, make the HTTP request. No MCP server, API key, or local GradientArt installation is required.
After writing design.gradient-art.json, the agent can submit it with:
curl --fail-with-body \
-H 'Content-Type: application/json' \
--data-binary @design.gradient-art.json \
https://gra.dient.art/api/v1/designs/prepare
The response contains editorUrl, expiresAt, and saved: false.
Ask the agent to return that exact URL, not a URL containing the design JSON.
Small and large designs use the same temporary-link API.
Open, edit, and keep your design
Links expire one hour after creation. Anyone with the link can access the original generated design until expiry, so keep it private and leave sensitive information out of your design. The API temporarily stores the design; it does not create a saved project.
Opening a design does not save it. Choose Save to create an online project (sign-in required), or Export > JSON project to keep a local editable file. Save or export before reloading or closing the editor.
If you already have work in the editor, you must confirm replacement. Cancel keeps that work intact. Reopening the original link restores the agent's design, not edits you made afterward.
When something goes wrong
- The link expired: Ask the agent to prepare a new link from its original JSON.
- The API rejected the design: Give the structured error back to the agent so it can repair the indicated fields. Schema validation alone does not check all clone relationships, formulas, and design limits.
- The API is rate-limited or unavailable: Respect
Retry-Afterand retry with backoff, or ask for a JSON file to import. Never treat an error as a prepared link. - A ChatGPT Action cannot send a large design: Actions have a smaller payload limit than this API. Use the JSON-file route or a terminal-capable agent.
Integration reference
Use the agent guide for generation rules, quotas, and retention details. The modular schema lets agents read only the layer types they need; the OpenAPI definition describes the HTTP contract. For MCP-compatible clients, use the remote MCP connection guide.