The Rust quickstart supports macOS and Linux. Install the PostgreSQL 17 server tools and Rust with rustup. Put the server's bin directory on PATH. The launcher looks for postgres, initdb, pg_ctl, pg_isready, and createdb in the same directory. It can also find the directory through pg_config --bindir.
For a first run, follow the synthetic image quickstart. It uses tokencraft doctor --fixture before startup and checks the served OpenAPI before it creates a disposable project.
From the core repository root, run:
cargo run --locked -p tokencraft -- devThe gateway defaults to http://localhost:4000, PostgreSQL to 127.0.0.1:55439, and the bundled connector to 127.0.0.1:4019. The launcher stores local data in .tokencraft-dev/. Use --state-dir to choose a new location or reopen an existing private state directory. The same command accepts --api-port, --db-port, --connector-port, and --web-port.
First start migrates PostgreSQL and builds the gateway against that schema for SQLx. For an offline start with cached dependencies, pass --offline to both Cargo and the dev command. For a prebuilt installation, put matching tokencraft and api-gateway binaries in the same directory on PATH, then run tokencraft dev.
From the core repository root, build and start the demo using Docker Engine 28 or newer and Docker Compose. The image builds through the same packaging check as the native distribution. At runtime it starts PostgreSQL 17, the gateway, and the synthetic image connector on a single machine. Docker port publishing
docker compose -f deploy/container/compose.yaml up --build --wait
curl -fsS http://localhost:4000/ready
bash examples/connector/smoke.sh http://localhost:4000The last command uses the local smoke test tools.
The host publishes the API on IPv4 loopback. PostgreSQL and the connector listen on loopback inside the container. The named volume holds accounts, requests, artifacts, and the launcher's generated keys. docker compose -f deploy/container/compose.yaml down stops the demo and leaves that volume available for the next start.
To add the browser console, first compile the frontend. Pass the absolute path to its dist directory as a read-only mount and open localhost:3000.
TOKENCRAFT_CONSOLE_DIR=/absolute/path/to/dist \
docker compose -f deploy/container/compose.yaml -f deploy/container/console.compose.yaml up --build --waitFor an operator catalog and externally managed PostgreSQL, use the gateway runtime image.
Choose the .tar.gz for your OS and architecture and keep its .sha256 file alongside it. The archive includes the matching launcher, gateway, migration tool, OpenAPI contract, connector primitive registry, public pricing catalog, inference plugins, compute plugins, and deployment files. It also includes the optional media worker with the workflow and media setup guides, plus the separate Operations console and its sample configuration. Install the PostgreSQL 17 server tools before starting the launcher. PostgreSQL for Ubuntu · PostgreSQL 17 for macOS
shasum -a 256 -c tokencraft-0.1.0-darwin-arm64.tar.gz.sha256
tar -xzf tokencraft-0.1.0-darwin-arm64.tar.gz
cd tokencraft-0.1.0-darwin-arm64
./bin/tokencraft doctor --fixture
./bin/tokencraft dev --fixtureUse sha256sum -c on systems with GNU coreutils. From a second terminal in the package directory, run the synthetic image quickstart. To start with your own catalog, use ./bin/tokencraft dev --profile ./reviewed-models.
Archives ending in -console.tar.gz include a console/ directory. Run ./bin/tokencraft dev --console-dir ./console and open the localhost console URL printed by the launcher. The same command accepts --profile for a reviewed catalog. Use --web-port when the default port 3000 is occupied.
Maintainers can run the Native packages workflow to build Ubuntu x86-64 and Apple Silicon archives as workflow artifacts. Select Include the compiled console to build a console from the same commit. The workflow records that commit in VERSION.json. To build on your own host, install the pinned Rust toolchain, PostgreSQL 17 and Python 3.12 or newer, then run the packaging script from the source checkout. The packager compares the version and source revision reported by each extracted binary with VERSION.json. It then compares migration checksums, exercises signed webhook delivery, and restores a published workflow that uses the packaged media runner. The package test uses Bash, curl, jq, OpenSSL, and a SHA-256 command. Workflow artifacts
python3 scripts/native_package.py --output ./native-packagesTo reuse binaries compiled with TOKENCRAFT_SOURCE_REVISION, pass that same revision to --source-revision along with --bin-dir. Run any of tokencraft --version, api-gateway --version, or admin-cli --version to inspect the build before packaging.
In a second terminal, run the smoke test against the running gateway. It needs Bash, curl, jq, OpenSSL and shasum or sha256sum.
bash examples/connector/smoke.sh http://localhost:4000The smoke test creates a local account, project, and service principal. It calls POST /v1/image for example_image, polls the returned status_url, validates the downloaded PNGs, and restores a sealed event export. Run it against a disposable dev directory to keep the generated account and images out of a shared database.
Start tokencraft dev with a disposable state directory and the bundled connector. From the core checkout, run the bounded load check with Python 3.
python3 -B examples/connector/load.py --requests 128 --concurrency 24Use --admission-rate 2 to model a steady two admission attempts per second across the pool. The rate includes retries. The default sends a burst as workers become available.
The check provisions a project and submits synthetic image requests for two client references using one key. It retries submission and active-work limits and honors Retry-After when the gateway reports database_busy. Retries preserve the submission's idempotency key. It reports the number of retries by error code, time to admission including those waits, the successful response time, and observed completion. It samples each active status through the public request history API and verifies the filtered history and usage totals after the queue drains. It polls with the response's Retry-After and ETag headers when present, so observed completion includes the polling interval. Compare runs with the same concurrency, fixture, hardware, and build profile.
Run the same local gateway with a catalog you curate and provider services you already started. Put the reviewed files in a directory separate from dev state.
| Profile file | Contents |
|---|---|
catalog.json |
Required version 1 routing catalog, with your model IDs, capabilities and rates. |
connector-bindings.json |
Queue connector bindings for services such as fal and Kinovi. |
chat-bindings.json |
OpenAI-compatible chat bindings for an OpenRouter bridge or a local model. |
rates.json |
Reviewed rate feed for the configured offers. Required if the catalog sets rate_feed_offers. |
Set the service credentials referenced by the two binding files in the shell. Keep vendor credentials in their provider services. Use the binding preflight to check the profile's files before starting the gateway. Use the prebuilt launcher to start the reviewed profile.
tokencraft dev --profile ./reviewed-models --state-dir ./.tokencraft-reviewedThe profile starts a private PostgreSQL cluster and gateway. It uses the supplied connector services in place of the bundled image connector. The launcher reads the catalog and binding files once at startup and supplies the referenced binding credentials. Restart to apply catalog or binding changes or to add a rate feed to a profile that started without one. When rates.json is present at startup, the gateway checks it every 15 seconds. Use an atomic file replacement after validating it with catalog check-rate-feed. Reuse the state directory to keep accounts, encryption keys, and request history. Let in-flight work finish before retiring its original binding.
Check the loaded models at GET /v1/catalog/models. Use GET /v1/catalog/models/scoped with a project credential that has requests:submit to discover private models shared with that project. Import ArtCraft presets into the catalog
Start the launcher once to create your account and project. Use their IDs in a reviewed workflow tool registry and configure each named service token to match its runner's token. Start the runner independently, then restart the launcher with the registry and the same dev state.
tokencraft dev --workflow-tools ./reviewed-tools/tool-bindings.jsonThe launcher reads a snapshot of the registry and manifests on startup. Relative manifest paths resolve from the registry's directory. Use the same flag with --profile to attach tools to a reviewed provider catalog. After changing a binding or manifest, restart the launcher. Keep the registry, manifests, and runner credentials with your recovery configuration.
Start your receiver on a loopback address and save its destination in webhooks.json.
{"destinations":{"local_events":"http://127.0.0.1:4011/events"}}tokencraft dev --webhook-config ./webhooks.jsonThe development launcher accepts HTTP on a literal IPv4 or IPv6 loopback address with an explicit port. The flag also works with --profile. In the console or project API, register a subscription using local_events, save the issued signing secret in your receiver, and reference the subscription when submitting a request. Restart the launcher to apply configuration changes. Subscription and signature verification
The state directory preserves the signing identity across restarts and restores. Keep the destination file with your configuration and pass it again when reopening restored state. For an internet-facing gateway, configure reviewed HTTPS destinations and its persistent signing key. Webhook setup
Use the macOS fixture with an existing Claude Code 2.1.319 executable, matching TokenCraft gateway and admin binaries, and the PostgreSQL 17 tools on your path. It launches the client with fresh settings and a synthetic project key in a temporary directory. The only tool is Read, confined to the fixture workspace. The client subprocess can connect only to its loopback Messages recorder.
python3 -B scripts/smoke_claude_agent.py "$gateway_bin" "$admin_bin" --claude "$claude_bin"The fixture uses the client's built-in Messages stream parser to execute a tool call whose arguments arrive in two fragments. It verifies that Claude Code returns the synthetic file's unique content as a tool result, receives the final text stream, and creates two scoped receipts with trace and usage.
The browser console is built from the frontend checkout. For a console you can run with the native launcher, build the frontend from its frontend/ directory with Node.js 22.
npm ci --ignore-scripts
VITE_TOKENCRAFT_PACKAGED=true npm run buildPoint tokencraft dev --console-dir at the resulting dist/ directory. The launcher serves it on the web port and supplies the active API port to the frontend. Use that compiled directory with scripts/native_package.py --console-dir ./path/to/dist to include the console in a native package. When packaging with --source-revision, set TOKENCRAFT_SOURCE_REVISION to the same commit when building the console. Packaging checks the launcher API setting in release.json, the console's embedded OpenAPI and catalog bytes, and the source revision for stamped packages.
For frontend development, run these commands from frontend/ with the gateway already running.
npm ci --ignore-scripts
npm run dev -- --host 127.0.0.1 --port 3000 --strictPortOpen local sign-up. Use localhost for both browser-facing URLs so the session cookie works across ports. If you change Vite's port, pass the same --web-port to tokencraft dev. Provider inventory and operational views use the gateway's configured offers.
In the signed-in Playground, choose Compare routes to compare prices for the selected project. The model picker includes custom models shared with that project. Each route shows its price deadline when it uses a reviewed rate feed. When a quote expires, choose Refresh quote to see the currently eligible routes before submitting. Submit from the comparison to follow the request trace in the same workspace.
On the public Compare models page, gateway prices for configured models use the remaining eligible rates as individual prices expire. Choose Refresh prices to request new estimates from the connected gateway.
Run the Chromium fixture from the TokenCraft repository with an ArtCraft checkout that includes Analyze media and the standalone Studio relay. The fixture uses a fresh loopback PostgreSQL database and synthetic image, audio, video, and document inputs. It checks that Studio rejects a sibling principal’s document, quotes and submits the exact inputs in order through the native Rust transport, and recovers the original receipt after losing the admission response. It also checks that the provider receives each original input and dispatches once.
Use matching TokenCraft api-gateway and admin-cli binaries. Have Python 3.10 or later, PostgreSQL 17 tools, FFmpeg, and Node.js 22 on your path. Supply paths to cached Chromium and the installed Playwright index.mjs. The fixture uses React, React DOM, and esbuild from frontend/node_modules by default.
If the relay is already built, point studio_relay at it. To build the checked-in relay from an existing Cargo cache, run the following with artcraft_checkout and relay_target set.
cargo build --locked --offline \
--manifest-path "$artcraft_checkout/tools/tokencraft-studio-relay/Cargo.toml" \
--target-dir "$relay_target"
studio_relay="$relay_target/debug/studio-browser-relay"Set the remaining paths for your checkout and cached tools, then run the fixture.
python3 -B scripts/smoke_studio_analyze.py "$gateway_bin" "$admin_bin" \
--studio-checkout "$artcraft_checkout" \
--relay "$studio_relay" \
--playwright "$playwright_entry" \
--chromium "$chromium_bin"Pass --frontend-dependencies "$frontend_dependencies" to use frontend packages from a separate checkout.
Add --retained-speech to move the prior audio into the fixture archive before Studio quotes and reuses it.
Use the native launcher to save a logical PostgreSQL dump together with the local encrypted artifacts, event archives, connector job records, and the keys needed to reopen them. Finish queued and running requests and any queued, running, or reconciling workflows, then stop the launcher.
tokencraft backup .tokencraft-dev ./tokencraft-backup
tokencraft restore ./tokencraft-backup ./restored-dev
tokencraft dev --state-dir ./restored-devUse cargo run --locked -p tokencraft -- before the subcommand when running from source. The commands use pg_dump, pg_restore, and pg_controldata from the selected PostgreSQL server installation. Use matching PostgreSQL versions for the source and recovery environment.
Use a new destination each time. Restore verifies the file checksums before loading the database in one transaction and checks that PostgreSQL records a clean shutdown before publishing the new state. The next dev launch applies any pending migrations. Keep backups in private storage and restore from trusted copies. The backup holds the keys that protect local content as well as the database.
Keep the reviewed profile, its service credentials, and any webhook and workflow tool configuration with your deployment files. Supply that configuration when reopening restored state.
These commands cover state managed by tokencraft dev. Restore recovers the contents as of the backup. For a separately deployed gateway, coordinate PostgreSQL, object storage, connector state, and secret recovery with the deployment's retention and content-removal records.
Capture a checkpoint from the latest stopped state. Keep it with your recovery materials and pass it when restoring an older backup.
tokencraft checkpoint .tokencraft-dev ./content-removals
tokencraft restore ./tokencraft-backup ./restored-dev --content-removals ./content-removalsThe checkpoint authenticates removal records with the original state's payload key. Restore applies the records to matching requests, preserves their original removal timestamps and event IDs, and rebuilds the PostgreSQL cluster from a scrubbed logical dump. The new state retains request history and usage and excludes removed local media bytes. A checkpoint covers the removals recorded when it was captured.
Use provider bindings to add queue-based media or OpenAI-compatible chat services. Deployment covers starting the gateway with your catalog instead of the bundled example.
Create and test reviewed field translations with the provider mapping guide.