AMJ / agent media jobs

LOCAL RUNNER / FAL.AI

Paid media jobs need a paper trail.

The agent can prepare and follow a generation job. A trusted reviewer accepts the exact request and its spending limit before anything reaches fal.ai.

Trace a job ↓
JOB MANIFEST example.json
model fal-ai/flux/schnell
estimated cost $0.01 caller supplied
maximum $0.10
approval required before submit
provider request not yet sent
Synthetic input. No generation runs on this page.
prepared → approved → submitting → submitted → completed → delivered

THE RUNBOOK

Five commands, two different actors.

The agent host can prepare, submit, poll, and fetch. The approval command must run from a trusted shell that the agent cannot call.

01 / agent

Prepare

Save the model ID, JSON input, estimate, and maximum spend. The output includes a job ID and approval hash.

bun run src/cli.ts prepare fal-ai/flux/schnell input.json 0.01 0.10
02 / reviewer

Approve the saved request

Inspect the model, input, estimate, and maximum. The hash binds this approval to that saved request; it does not authenticate the reviewer.

bun run src/approve.ts JOB_ID APPROVAL_HASH REVIEWER_ID
03 / agent

Submit once

With FAL_KEY configured, the runner writes submitting before the network call. A repeated submission is rejected.

bun run src/cli.ts submit JOB_ID APPROVAL_HASH
04 / agent

Follow the provider request

Once fal returns a request ID, the runner can resume queue checks after a restart.

bun run src/cli.ts status JOB_ID
05 / agent

Fetch and verify

completed means processing finished. delivered means a local MP4, PNG, or JPEG passed signature checks and has a recorded SHA-256 and byte count.

bun run src/cli.ts fetch JOB_ID ./outputs

WHEN THE NETWORK FAILS

Don't turn an unknown charge into a second one.

If submit times out, the manifest becomes uncertain. Inspect the fal dashboard or provider API before creating any new job. The runner will not retry the request for you.

SAFE TO RETRY Result retrieval

The queue completed, but the media URL or download failed. Retry fetch, not submit.

NEEDS INVESTIGATION Submission timeout

The provider may have accepted the request. Check its state before spending again.

The estimate comes from the caller. This tool does not fetch current model prices or validate each model's input schema. Review both against the model documentation.

LOCAL, SINGLE HOST

The manifest is the record. The artifact is the proof.

Read the architecture ↗ View source ↗