Skip to main content

metaphi

The Metaphi AI command line. Sign in, manage your organization's people and keys, and twin agent traces.

Install

brew install metaphi-labs/tap/metaphi    # macOS and Linux

No Homebrew? Download the binary for your platform from the latest release, unpack it and put metaphi on your PATH. Each release lists its checksums.txt.

Calling it from Python instead: pip install metaphi-ai gives you the same command and the library (see below).

Quickstart (2 minutes)

metaphi login                  # opens the browser; confirm the code you see in the terminal
metaphi keys create prod --save
metaphi credits                # your organization's prepaid balance
metaphi twin trace.json        # writes trace.twin.json

metaphi login signs you in as yourself. metaphi keys create makes an organization key (mai_sk_...). The key is shown once, so store it as a secret. --save also keeps it on this machine: in the OS keychain when there is one (macOS Keychain, Windows Credential Locker, Secret Service on Linux), otherwise in the config file.

metaphi keys create dev --test makes a test-mode key (mai_sk_test_...). Its runs go through the same pipeline but cost nothing; files can be at most 256 KiB and an organization gets 20 runs a day. Test twins and live twins never see each other.

A key you already have is saved with metaphi login --with-api-key, which reads it from stdin (or prompts without echo), so it never lands in your shell history or the process list.

Use it from your servers

Every call that does work runs on an organization key, never on a person's sign-in:

export METAPHI_API_KEY=mai_sk_...
metaphi twin trace.json -o out.json --json

One trace file in, one twinned file out, in the same format. --json prints {"output"} on stdout, with progress on stderr. Or from Python:

from pathlib import Path
from metaphi.twin import twin

result = twin(Path("trace.json"), Path("out.json"), api_key="mai_sk_...")
result["output"]   # where the twinned trace was written

One key per environment (prod, staging) or per customer is a good default. Revoking one stops only that key.

Twin options

Flag What it does
-o, --output Where the twinned trace goes. Default: <name>.twin<ext>.
--key <64 hex> Keys the stand-in values. The same key gives a person the same stand-in in every trace, so a corpus stays consistent. Default: a fresh key per trace.
--confidential <org> Replaces an organization even though it is public, e.g. your customer. Repeatable.

The organization key comes from METAPHI_API_KEY, then the saved key. (--api-key still works but is deprecated: an argument is visible in shell history and to other processes.)

People, private organizations, accounts and secrets are always replaced, each with one consistent synthetic value of the same kind, and the trace keeps its structure. An adversarial pass then reads the output for anything still real.

Errors

Every error from the service carries a stable code. Switch on the code or the exception class, never on the message. On a failure the CLI exits 1 and prints:

error: This organization's prepaid balance is used up; add credits to continue. Nothing was started. (code: out_of_credit, request: req_5f1c...)

With --json, stdout also gets the error object: {"error": {"type", "code", "message", "retryable", "request_id"}}, plus run_id when a run failed. Quote the request_id to support.

From Python, each error type raises its own class from metaphi.errors. All of them subclass MetaphiError:

from pathlib import Path
from metaphi.errors import BillingError, MetaphiError, RateLimitError
from metaphi.twin import twin

try:
    twin(Path("trace.json"))
except BillingError:            # out_of_credit
    ...                         # add credit: `metaphi credits buy`
except RateLimitError as e:     # rate_limited_concurrent, rate_limited_daily
    ...                         # e.retryable is True: try again when a run ends
except MetaphiError as e:
    print(e.code, e.request_id, e.retryable)
Class type Codes, for example
BillingError billing_error out_of_credit
AuthError auth_error no_organization
RateLimitError rate_limit_error rate_limited_concurrent, rate_limited_daily
InvalidRequestError invalid_request_error invalid_key, upload_already_run, task_not_found
RunError run_error twin_unclean, not_text, too_large, session_failed, budget_exceeded
IdempotencyError idempotency_error idempotency_key_reused, idempotency_key_in_use
APIError api_error unavailable, balance_unavailable, run_unavailable

retryable says whether making the same call again later may succeed. For a failed run, it means uploading the same trace again. An error the CLI says itself, such as a missing key, is a plain MetaphiError with code set to None.

Your organization

metaphi whoami
metaphi members list
metaphi members add dev@yourco.com --role admin   # admins manage keys and people; members don't
metaphi members remove dev@yourco.com
metaphi keys list
metaphi keys revoke key_0123abcd

If you manage more than one organization, name it with --org <id>.

Credits

Each completed trace draws your organization's prepaid credit; a run that fails costs nothing. When the balance reaches zero, new runs are refused until credit is added.

metaphi credits                       # the balance (owners, admins and billing members)
metaphi credits buy --amount 200      # pay through Stripe Checkout in the browser; waits until it lands
metaphi members add ap@yourco.com --role billing   # sees the balance and buys credit, nothing else

Only owners and billing members can buy.

Configuration

Variable Default
METAPHI_API_KEY the key saved by metaphi login --with-api-key or keys create --save
METAPHI_API https://api.metaphi.ai/v1/kennet, the Kennet API
METAPHI_HOME ~/.config/metaphi (directory mode 700, config file mode 600)
METAPHI_TWIN_TIMEOUT 7200: seconds metaphi twin waits for its twin to end (--timeout per call)
METAPHI_NO_KEYRING unset: secrets go to the OS keychain when one is available; 1 keeps them in the config file
METAPHI_ALLOW_CUSTOM_HOST unset: the CLI talks only to https://*.metaphi.ai; 1 allows another https host

Sign out with metaphi logout. It ends this sign-in everywhere it is used.

Metadata

Release files for metaphi-ai 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metaphi-ai 0.1.4
File Size Uploaded
metaphi_ai-0.1.4.tar.gz 19.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metaphi-ai 0.1.4
File Interpreter ABI Platform
metaphi_ai-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 42.3 kB

Release files / metaphi_ai-0.1.4.tar.gz

Download URL metaphi_ai-0.1.4.tar.gz
Size 19.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8375c6ea81107a7eeee03e152c59f4bc1f6ce2aa55c1a9200ee07e1976686b7c
BLAKE2b-256 checksum
How to use checksums
95ac830046046abf01516ec787fbf30dd4898a26d7ea766a89ba6c35e51dba11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / metaphi_ai-0.1.4-py3-none-any.whl

Download URL metaphi_ai-0.1.4-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
862b98172e36bfd74ddb3da15e0a245c9fbb7e61481192e9850039eb89ad6540
BLAKE2b-256 checksum
How to use checksums
d72925d242adf67c4100aa7d2925e66165227fcb6279a4f0296b2f2e5b07371d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page