# Grida FX > Grida FX is a workflow engine for generating and processing assets. It combines model calls > for images, video, audio, 3D and structured text with local code. The command is `grida fx`. Version: 0.13.0 An FX project keeps its settings in `fx.yaml`. A workflow wires inputs, steps and outputs in YAML or through a Python or TypeScript builder. Planning resolves the steps and model routes and forecasts cost before execution. A run executes the plan, reuses cached work and saves a record you can inspect through the CLI, SDKs or local browser viewer. For example, one workflow can draw an icon, check its transparency with local code, and deliver the accepted PNG. ## Find what you need - **Try FX.** [Install the CLI](#install-and-check) and [test an image workflow offline](#plan-an-icon-and-test-it-offline). - **Author a workflow.** See [project setup](#a-project), [workflow syntax](#the-workflow-file) and [example projects](https://github.com/gridaco/fx/tree/main/examples). - **Use a model.** Read the [spending and credential rules](#rules-for-agents) and [choose a route and provider](#routes-and-providers). - **Work with a run.** See [run, inspect and recover](#running), [viewer and SDK access](#viewer-and-sdks) and [troubleshooting](#when-something-fails). - **Look up details.** Use the [guide index](https://github.com/gridaco/fx/blob/main/docs/guide/README.md) for tasks and the [spec index](https://github.com/gridaco/fx/blob/main/spec/README.md) for contracts. This index takes precedence over the guide, README and skills for the release it describes. The engine and spec are authoritative. For an installed CLI, use `grida fx --version`, `grida fx --help` and `grida fx --help` to check available commands and flags. Use `grida fx nodes` to list built-in types, `grida fx nodes TYPE` to inspect settings, ports and shipped routes, and `grida fx schema TARGET` for a workflow's inputs. ## Rules for agents - **Plan first.** Use `grida fx plan TARGET --check` to validate the workflow and show the user its steps and forecast. Planning never makes paid model calls. It can load workflow code, run local `at: plan` steps and fetch read-only metadata for a selected missing GG/OpenRouter image binding. - **Get approval to spend.** Pass `--live` only with the user's approval and an agreed ceiling. Runs using only the user's Codex or Grok Build still need approval because they use the user's subscription quota, even though FX books them at $0. - **Keep credentials private.** Let the user configure keys in the environment, project `.env`, or Grida's credential store for eligible providers. Use `grida fx doctor TARGET` to check readiness without reading key values. Keep secrets out of authoring files, prompts, provider options and run records. - **Confirm route changes.** Ask before changing a paid route. A new route changes identity and can require new generation. - **Let FX own retries and records.** Use the run commands and SDKs to read or resume runs. Leave generated `runs/` and `.fx/` files to FX. The engine owns provider retries, accounting for each attempt. - **Share the viewer URL.** Share the URL emitted by `run` or `rerun` for live work when available. The shared run link opens the latest attempt. The viewer's attempt history gives exact links. For a plan or an exact saved attempt, register it and resolve its route against the verified service URL for that project. Use `--open` when the user asks to launch the browser. - **Control runs from the viewer.** The local run page offers Pause, Resume, Rerun and Cancel through **Run actions**. Use the CLI when a start needs live approval or additional context. [Run control](https://github.com/gridaco/fx/blob/main/docs/guide/08-run-control.md#control-a-run-in-the-viewer). ## Install and check Use Node.js 24 or later for the `grida` command. ```sh npm install -g grida grida fx --version grida fx doctor ``` Use `npx grida fx` without a global install. The CLI supports macOS and Linux (glibc 2.28+) on x64 and arm64, and Windows through WSL 2. Python 3.11+ with `pip install grida` is required for Python bodies and built-in local image, JSON and file processing. TypeScript bodies need Node 24+ and the project dependency `npm install @grida/fx`. Use `GRIDA_FX_PYTHON` or `GRIDA_FX_NODE` to select a host interpreter. For a pinned native CLI in CI, see [Standalone downloads](https://github.com/gridaco/fx/blob/main/docs/guide/17-standalone-downloads.md). ## A project - `grida fx init my-assets` writes a starter workflow and project files in a new or empty directory. In an existing FX project, plain `init` checks `fx.yaml`. For an existing non-empty folder, add `fx.yaml` yourself. - `grida fx init --list-templates --json` lists starters. `grida fx add hello` copies a first-party example into its own project. `grida fx add OWNER/REPO@REF --github-auth` copies a private GitHub template at a tag or full commit SHA with authenticated `gh`. See [template setup and receipts](https://github.com/gridaco/fx/blob/main/docs/guide/01-getting-started.md#start-from-a-template). - FX finds the nearest `fx.yaml` above the working directory. The file declares `fx: project/v1`. Workflows usually live under `workflows/`, and run records under `runs/`. Project settings include `routes`, `provider_preferences`, `route_tables` and `budget.max_usd`. Workflow references beginning with `./` or `../` are relative to the workflow's home project, the nearest `fx.yaml` above its source file. ## The workflow file A workflow needs `fx: workflow/v1`, a stable `id`, `title` and `steps`. Its `outputs` map declares what callers can use or deliver. Steps run in dependency order, in parallel when ready. Node behavior, declared settings, resolved inputs, routes and takes determine cache identity. Paid requests also have their own cache. Renaming or reordering steps alone preserves reusable results. | Write | Use | |---|---| | `inputs` | Declare scalars (`string`, `integer`, `number`, `boolean`), `file` or `files` with a `kind`, `list` with `items`, `map` with `values`, or nested field maps. Use `default`, `required`, and schema constraints such as `max_items`. An optional input without a default is null. | | `uses` and `with` | Select a built-in type such as `fx/image.generate@1`, a local node such as `./nodes/draw.py#draw`, or a workflow such as `./workflows/draw.yaml`. Set its inputs and settings in `with`. | | `${{ inputs.name }}` and `${{ steps.draw.outputs.image }}` | Read inputs and wire outputs. A whole expression keeps its type. Interpolation inside text produces a string. Also read `let`, `tables`, `item`, `matrix`, and reported facts such as `steps.review.facts.verdict`. | | `for_each`, `key`, `matrix`, nested `steps` | Repeat over a list or combinations, use stable keys, and group steps. Read a collection with `steps.icon.*.draw.outputs.image`. When a list comes from a run-time step, set `max` to bound the later phase. | | `if`, `assert`, `needs`, `at: plan` | Gate steps, assert conditions, add ordering without a data dependency, or compute values in a free deterministic step during planning. | | `judges`, `on_reject`, `regenerate`, `takes`, `pick` | Report an `accept` or `reject` verdict, choose how downstream work proceeds, and control alternative results. A regeneration limit includes the initial take. | | `route`, `requires`, `budget`, `concurrency` | Override the capability route, require features, limit authorization or limit concurrent instances of a repeated node step. | | `notes`, `preview` | Document the workflow or group with `notes`. A node step's `preview: { video: video, poster: poster }` selects its own video and optional image output ports for display. | Use `--inputs FILE` for input YAML, required for list and map inputs. Paths inside it are relative to the input file. Scalar values can also be supplied after `--`, as in `grida fx plan icon -- --name lantern`. Quote ambiguous YAML strings such as `"on"`, `"16:9"`, and dates. Duplicate keys, anchors, aliases and tags are refused. Use `??` for a null, skipped result or missing final field. Use `facts(file)` for recorded properties such as image width or alpha, and `accepted(collection)` to filter judged results. See the [workflow reference](https://github.com/gridaco/fx/blob/main/docs/guide/02-workflow-file.md), [YAML rules](https://github.com/gridaco/fx/blob/main/spec/yaml.md), and [expression contract](https://github.com/gridaco/fx/blob/main/spec/expressions.md). ### Built-in and custom nodes `grida fx nodes TYPE` gives the built-in type's settings, output ports and shipped routes. For example, `fx/image.generate@1` takes `prompt` and can take `size`, `background` and `references` on compatible routes. Its output is `image`. Use `fx/image.edit@1` for edits, `fx/structured.generate@1` for a JSON Schema answer, and local nodes such as `fx/image.resize@1`, `fx/image.check_alpha@1` and `fx/package@1` for processing, judging and packaging. The catalog includes planned types. Check the [node guide](https://github.com/gridaco/fx/blob/main/docs/guide/03-nodes.md) for execution support. Custom nodes declare `inputs`, `params`, `outputs` and any `resources`, `tools` or maximum `calls` they use. Read declared data through `ctx`, return declared outputs, and route paid work through FX's managed capability methods. Source changes affect identity by default. For a versioned node or adapter, use `grida fx lock` to track changes in `fx.lock` and bump its version for changed behavior. See [Python and TypeScript authoring](https://github.com/gridaco/fx/blob/main/docs/guide/03-nodes.md) and [annotations and judges](https://github.com/gridaco/fx/blob/main/docs/guide/06-annotations-and-judges.md). ## Routes and providers - In `fx.yaml`, `routes` sets model defaults per capability and `provider_preferences` pairs unqualified model IDs with explicit providers. A concrete `model@provider` selects an exact route and overrides the preference. A step's `route` overrides the capability default. Credentials never select a provider. For example, choose `openai/gpt-image-2.5-sunburst` with preference `gg`, or directly choose `openai/gpt-image-2.5-sunburst@gg`. - For a missing GG/OpenRouter image binding, FX can look up model metadata for the selected provider. `GRIDA_FX_NETWORK=off` forbids the lookup and all requests through FX's transport. Explicit `--routes` turns off discovery. Use [model selection](https://github.com/gridaco/fx/blob/main/spec/model-selection.md) for precedence and offline behavior. - FX checks a nonblank process environment value, then project `.env`, then eligible saved Grida keys. The [provider guide](https://github.com/gridaco/fx/blob/main/docs/guide/13-providers.md) lists key names and route features. `imagegen@codex` and `imagine@grok` use installed, signed-in tools. Leave `size` unset on these routes and resize locally for exact dimensions. See [Codex](https://github.com/gridaco/fx/blob/main/docs/guide/12-codex.md) and [Grok Build](https://github.com/gridaco/fx/blob/main/docs/guide/14-grok.md) for their respective capabilities. - Use `route_tables` for additional `fx: routes/v1` tables. `extends` inherits from an earlier or built-in route of the same capability and provider. Standard paid steps accept JSON options in `with.provider_options.`. FX refuses files and parameters it owns. For a provider FX does not ship, declare it with `family: openai-compatible` for structured generation or agent turns, or use a Python or TypeScript `adapter` for other operations. Follow the [community provider guide](https://github.com/gridaco/fx/blob/main/docs/guide/15-community-providers.md) for declarations, native capabilities and diagnostics. - A dollar-billed live run takes its ceiling from `--max-usd`, the workflow's `budget.max_usd`, or the project's `budget.max_usd`, in that order. FX reserves authorization before each paid attempt, waits for temporary holds, and stops admitting work when the budget is exhausted. It books reported charges in full, including charges above the hold. The ceiling controls admission to FX calls and cannot cap a provider invoice. - A complete route can omit `price` for an unknown forecast. Use `price: null` to clear an inherited price. An unpriced attempt usually holds the remaining applicable budget. `price: { cap_usd: N }` sets a per-call hold while keeping the forecast unknown. When actual cost goes unreported, FX books the whole hold and keeps actual cost unknown. Use `--require-estimates` on `plan` or `run` to require forecasts for uncached paid work. See [cost and cache](https://github.com/gridaco/fx/blob/main/docs/guide/04-cost-and-cache.md). ## Running `TARGET` is a workflow ID, YAML path, or a builder like `file.py:build` or `file.ts:build` with `--arg name=value`. In `inspect`, `rerun`, and run control commands, a run ID or `WORKFLOW_ID/NAME` selects the latest attempt. `inspect WORKFLOW_ID` selects the newest independent run of that workflow. An exact attempt folder pins its record. For `observe` and `project`, pass that folder. Read it from `run.folder` in `inspect RUN --attempt N --json` or from `inspect RUN --history --json`. | Job | Command | |---|---| | Validate inputs and plan before running | `grida fx schema TARGET` and `grida fx plan TARGET --check --json`. Use `--check` to make planning problems fail the command. | | Preview one image call without a workflow | `grida fx call image.generate --prompt TEXT --dry-run`. Set `--route` when the project has no image default. An approved live call can copy the saved PNG with `--out FILE` to an unused destination. | | Run local work or admit paid calls | `grida fx run TARGET`. After approval, add `--live --max-usd N` for dollar-billed work. `--yes-up-to N` adds an approval gate for later phases. | | Run with simulated provider answers | `grida fx run TARGET --stand-in FILE#FUNCTION`. A stand-in runs offline, uses a separate cache, and conflicts with `--live` and `--yes-up-to`. | | Inspect a result and verify files | `grida fx inspect RUN --verify --json`. Use `grida fx observe FOLDER --snapshot` or `grida fx observe FOLDER --after CURSOR` to read the selected attempt's state and events. | | Supply external input during a run | An `fx/await@1` step declares `with.schema` and can add a human-readable `message`. List requests using `grida fx inspect RUN --requests --json` and submit `grida fx respond RUN REQUEST_ID --json JSON`. Use the exact folder or `WORKFLOW_ID/NAME`. Read the value from `outputs.answer`. An optional candidate map also yields `outputs.selected`. Continue a parked run with `grida fx resume RUN` after submitting the input. With `--wait-for-answers` the attached runner continues automatically. [Waiting steps](https://github.com/gridaco/fx/blob/main/spec/waiting.md). | | Check or cancel one exact invocation | `grida fx inspect RUN --control --json`, then `grida fx cancel RUN --invocation ID --wait --json`. Use an exact attempt folder to pin the selected attempt. Local completion and provider completion are separate. See [run control](https://github.com/gridaco/fx/blob/main/docs/guide/08-run-control.md). | | Pause at a step boundary and continue later | `grida fx pause RUN --wait --json` lets active steps finish and records a durable pause. `grida fx resume RUN` continues that exact attempt from saved context. For live work, supply the usual spending authorization. | | Run it again under the same ID | `grida fx rerun RUN` verifies saved execution context and adds a numbered attempt. A run ID or name follows its latest attempt. `grida fx inspect RUN --history --json` lists attempts, and `grida fx inspect RUN --attempt N --json` pins one for reading. [Rerun and inspect earlier attempts](https://github.com/gridaco/fx/blob/main/docs/guide/05-running.md#rerun-and-inspect-earlier-attempts). | | Deliver or share outputs | `grida fx run TARGET --deliver output=path` copies declared outputs. Use `{key}` in the destination for keyed collections. `grida fx export RUN --out DIR --json` creates a portable export of a finished run. See [export disclosure options](https://github.com/gridaco/fx/blob/main/docs/guide/11-exports.md). | | Choose another result | `grida fx reroll RUN STEP` and `grida fx pick RUN STEP TAKE` change the selection for later runs. Re-plan before repeating the run because a new take or changed downstream work may cost money. | | Clean up | `grida fx runs list --json`, `grida fx runs remove RUN`, and `grida fx cache prune`. Removal and pruning preview until `--yes`. See [cleanup and refusals](https://github.com/gridaco/fx/blob/main/docs/guide/10-cleanup.md). | **Resume and recover.** Create a named run with `--name NAME`. Continue with `grida fx resume RUN`. When saved context is missing, repeat the original target, inputs and plan-affecting options with `--resume NAME` or the same `--run DIR`. Resume requires the same plan and preserves the original spending ledger. A new run record can still reuse cached work. Keep an exact attempt folder when acting on a previously observed result. A fresh rerun opens new review requests and deadlines and uses normal cache and spending rules. The original workflow command creates an independent run. If FX retained a provider task handle, use `--live --recover` with the existing run selector to collect the original result, replay cache and run local work while blocking new paid dispatch. See `run.call_recoveries` and `run.call_attempt_failures` in `grida fx inspect RUN --json`. `grida fx jobs` lists retained jobs. Check the provider outcome and get approval for a replacement before using `grida fx jobs --forget KEY`. See [resuming and job states](https://github.com/gridaco/fx/blob/main/docs/guide/04-cost-and-cache.md#resuming). ### Viewer and SDKs - Start the service with `grida fx start --background`. Open a plan with `grida fx plan TARGET --open` or a saved run with `grida fx inspect RUN --open`. Add `--standalone` for an independent viewer. `viewer.display` in `fx.yaml` controls workflow input, output and note visibility. See [viewing workflows and runs](https://github.com/gridaco/fx/blob/main/docs/guide/07-viewing.md). - For host apps, use `grida fx plan TARGET --register --json` or `grida fx inspect RUN --register --json`. Registration returns a relative route and stable reference. Use `grida fx status --project-root DIR --json` for the matching service URL. With a plan, check `plan_ok` or pass `--check`. For selection, presentation and native file actions, see the [viewer API](https://github.com/gridaco/fx/blob/main/docs/guide/16-viewer-api.md) and [file resolution contract](https://github.com/gridaco/fx/blob/main/spec/files.md). - Python (`grida.fx`) and JavaScript (`@grida/fx`) expose `plan` and `run`. Check the plan's problems and the result's `ok` and failures. A failed step can return a result. For saved runs, `load_run` / `loadRun` pin a record with `snapshot`, `events`, `follow`, and `export`. Both SDKs offer `pause`, `resume`, and `rerun`. Use `run_history` / `runHistory` to get each attempt's exact folder. Recovery uses `recover=True` or `recover: true` with live mode and the existing run selector. See the [SDK guide](https://github.com/gridaco/fx/blob/main/docs/guide/09-sdk-runs.md) and [SDK contract](https://github.com/gridaco/fx/blob/main/spec/sdk.md). ## Recipes Use a fresh directory for each recipe. Save each file block to the path in its first comment, omitting that comment. Run the shell commands from the project root. ### Plan an icon and test it offline Install the Python package with `pip install grida` on Python 3.11+. A stand-in supplies a local PNG in place of the provider answer, so you can test the image step and its transparency judge without credentials. A live run uses Grida Gateway and can draw up to three takes if the judge rejects an image. ```yaml # fx.yaml fx: project/v1 routes: image.generate: openai/gpt-image-2.5-sunburst provider_preferences: image.generate: gg ``` ```yaml # workflows/icon.yaml fx: workflow/v1 id: icon title: Item icon inputs: name: { type: string } steps: draw: uses: fx/image.generate@1 with: prompt: "A ${{ inputs.name }} game icon, centered, no text." size: 1024x1024 background: transparent check: uses: fx/image.check_alpha@1 judges: draw with: { image: "${{ steps.draw.outputs.image }}", expect: transparent } on_reject: regenerate: { max: 3 } outputs: icon: ${{ steps.draw.outputs.image }} ``` ```python # tests/stand_in.py import io from PIL import Image from grida.fx import Answer def answer(call): width, height = map(int, call.request["size"].split("x")) picture = Image.new("RGBA", (width, height)) picture.paste((180, 100, 50, 255), (width // 4, height // 4, width * 3 // 4, height * 3 // 4)) with io.BytesIO() as output: picture.save(output, "PNG") return Answer(files={"image": output.getvalue()}) ``` ```sh grida fx plan icon --check -- --name "copper lantern" grida fx run icon --stand-in tests/stand_in.py#answer --name preview --deliver icon=lantern.png -- --name "copper lantern" grida fx inspect icon/preview --verify ``` The plan forecasts the cost of real generation. Add `--json` to the plan command before `--` to see the resolved route. The offline run copies the test image to `lantern.png` and saves the run as `icon/preview`. The second `--name`, after `--`, sets the workflow input. To generate the real icon, have the user configure `GG_API_KEY` or a saved Grida Gateway key and check readiness with `grida fx doctor icon`. After approval, set `APPROVED_USD` to the agreed USD ceiling and give the live run its own name. ```sh grida fx run icon --live --max-usd "$APPROVED_USD" --name final --deliver icon=lantern-live.png -- --name "copper lantern" ``` ### Run a local TypeScript node Run `npm install` in this project with Node 24+ before planning. `uses` points to the named node export. ```json // package.json { "type": "module", "private": true, "dependencies": { "@grida/fx": "0.13.0" } } ``` ```ts // nodes/label.ts import { node } from "@grida/fx"; export const label = node( { name: "label", params: { name: "string" }, outputs: { label: "text/plain" } }, (ctx) => ({ label: ctx.out.text(`Item: ${ctx.params.name}`) }), ); ``` ```yaml # workflows/label.yaml fx: workflow/v1 id: label title: Label an item inputs: name: { type: string } steps: label: uses: ./nodes/label.ts#label with: { name: "${{ inputs.name }}" } outputs: label: ${{ steps.label.outputs.label }} ``` ```sh grida fx plan label --check -- --name lantern grida fx run label --deliver label=label.txt -- --name lantern ``` The local run writes `Item: lantern` to `label.txt`. ## When something fails | Symptom | Action | |---|---| | `plain scalar 'on' is ambiguous …; quote it` | Quote ambiguous YAML strings. | | `inputs: 'name' is a required property` | Supply `-- --name VALUE` or `--inputs FILE`. Check `grida fx schema TARGET`. | | `… is a paid call; run with --live` or `a live run needs a ceiling` | Plan first, then obtain approval and provide the agreed ceiling. Use a stand-in for an offline test. | | `… does not support exact_size`, `alpha`, `mask` or `image_input` | Remove the incompatible setting or agree on a compatible route with the user. Inspect the type with `grida fx nodes TYPE`. | | `no adapter serves …` or missing credentials | Use `grida fx doctor TARGET`. Check route capability, adapter declaration and host dependencies. Have the user configure the key if needed. | | A later phase stops at `--yes-up-to` | Show its forecast and resume the existing run with a higher approved threshold. | | A provider call failed | Inspect the exact run and its safe diagnostics. Check for a retained task before authorizing any replacement generation. | ## Further reading - [CLI and SDK examples](https://github.com/gridaco/fx/blob/main/docs/guide/05-running.md) - [Runnable projects](https://github.com/gridaco/fx/tree/main/examples), including [batch icons](https://github.com/gridaco/fx/tree/main/examples/item-icons), [phased generation](https://github.com/gridaco/fx/tree/main/examples/concept-gallery) and [text to 3D](https://github.com/gridaco/fx/tree/main/examples/text-to-3d) - Schemas for the [workflow](https://github.com/gridaco/fx/blob/main/spec/schemas/fx-workflow-v1.schema.json) and [project](https://github.com/gridaco/fx/blob/main/spec/schemas/fx-project-v1.schema.json), and the [release history](https://github.com/gridaco/fx/blob/main/CHANGELOG.md) - Install the [FX agent skill](https://github.com/gridaco/fx/blob/main/skills/grida-fx/SKILL.md) with `npx skills add gridaco/fx`.