Use TokenCraft’s synthetic connector to generate a PNG, replay the request, and read its trace. The fixture runs on loopback with a private PostgreSQL cluster.
Use the launcher from a native package on macOS or Linux. Put the PostgreSQL 17 server tools on PATH. The image example also needs Bash, curl, jq, and OpenSSL.
fixture_state=$(mktemp -d "${TMPDIR:-/tmp}/tokencraft-fixture.XXXXXXXX")
./bin/tokencraft doctor --fixture --state-dir "$fixture_state"
./bin/tokencraft dev --fixture --state-dir "$fixture_state"For a source checkout, run the same commands with the pinned toolchain.
fixture_state=$(mktemp -d "${TMPDIR:-/tmp}/tokencraft-fixture.XXXXXXXX")
cargo run --locked -p tokencraft -- doctor --fixture --state-dir "$fixture_state"
cargo run --locked -p tokencraft -- dev --fixture --state-dir "$fixture_state"Doctor reports the selected state and log paths, PostgreSQL tools, gateway binary or source build, and occupied loopback ports. It leaves the selected state directory untouched. If a port is busy, pass the same override to both commands. For example, use --api-port 4400 and export TOKENCRAFT_BASE_URL=http://localhost:4400 in your client shell.
The fixture defaults to .tokencraft-fixture if you omit --state-dir. With the explicit directory above, reusing it after a restart preserves your test accounts and requests. Press Ctrl+C to stop the launcher. Keep the state directory to reopen the fixture, or delete that specific temporary directory once the launcher has stopped and you are finished.
In a second terminal, use the files from the same archive or checkout as the gateway.
# For a native package, use the source revision from the archive manifest.
export TOKENCRAFT_EXPECTED_REVISION="$(jq -r '.source_revision // empty' VERSION.json)"
# Run this command from the native package or source checkout.
bash examples/connector/quickstart.shWith a source build, run the script without setting TOKENCRAFT_EXPECTED_REVISION unless you stamped the gateway yourself. The script compares the served OpenAPI with the bundled contract before creating a disposable project key. It discovers example_image, gets a scoped estimate, and submits the normalized input and estimate ID with an idempotency key. The same submission returns the original receipt. The script follows its status URL, checks for one provider attempt, and prints paths to a checksum-verified image.png and its trace.json.
In a second terminal at the checkout root, provision a test key without printing it. Use the examples from the source revision in the package’s VERSION.json. Rust example · TypeScript example
export TOKENCRAFT_BASE_URL=http://localhost:4000
export TOKENCRAFT_API_KEY="$(bash examples/connector/quickstart.sh --key-only)"Run the Rust example with Cargo and the pinned toolchain.
TOKENCRAFT_REQUEST_KEY="rust-$(openssl rand -hex 16)" \
TOKENCRAFT_OUTPUT_DIR="$(mktemp -d)" \
cargo run --locked -p tokencraft_sdk --example first_imageFor TypeScript, use Node.js 22 and install the SDK tarball in a clean consumer directory.
consumer=$(mktemp -d)
npm --prefix sdk/typescript ci --ignore-scripts
npm --prefix sdk/typescript run build
(cd sdk/typescript && npm pack --ignore-scripts --pack-destination "$consumer")
cp sdk/typescript/examples/first-image.mts "$consumer/"
(
cd "$consumer"
printf '{"private":true}\n' > package.json
npm install --offline --ignore-scripts --no-audit --no-fund ./tokencraft-sdk-*.tgz
TOKENCRAFT_REQUEST_KEY="typescript-$(openssl rand -hex 16)" \
node --experimental-strip-types first-image.mts
)Each example prints the request ID and trace URL and writes a verified image.png. The native package workflow runs all three clients against the extracted gateway. Its TypeScript run discards the first accepted response and checks that the SDK recovers the same receipt. The workflow expects one synthetic connector job per client.
- Lost submission response. Keep the exact submission body and idempotency key before sending. Replay both if no receipt arrives. A successful replay returns the admitted request ID and status URL.
- Throttled before acceptance. Follow
Retry-Afterand reuse the same key and body. If the gateway returnsawaiting_reconciliation, inspect the trace for the existing request and wait for reconciliation. - Expired artifact. Use the request ID to inspect status and retention metadata. Ask the project operator about retrieval or restore if the content was archived.
- Wrong deployment. The console links to its release manifest and the target gateway’s OpenAPI. A self-hosted native archive also records the gateway revision in
VERSION.json. Use the contract from the gateway you call.