Skip to content

Repository files navigation

General Liquidity Python SDK

The Python client for the General Liquidity machine economy API, generated from the general-liquidity-openapi spec.

Install

Once published:

pip install general-liquidity

From source:

git clone https://github.com/general-liquidity/general-liquidity-python
cd general-liquidity-python
pip install -e .

Usage

The surface is split into seven API classes, each constructed from a shared ApiClient:

  • MoneyApi: pay
  • CommerceApi: buy, quote
  • IdentityApi: resolve, disclose, verify
  • GovernanceApi: audit, audit_stream, get_intent, get_intent_events, list_intents, get_mandate, get_usage, health, agent_card, ucp_profile
  • MemoryApi: remember, recall, assemble, verify, forget
  • OperatorApi: the detached GL-Operator authority (approve, refund, kill switch)
  • WebhooksApi: endpoint registration and rotation

Two of the governance reads are worth naming. get_mandate reports the spend authority covering the caller and what is left of it, so a commitment can be sized before it is made rather than discovered by refusal. list_intents lists the caller's own intents newest-first and takes a status: pending finds an intent a gate confirm parked, whose id was returned once, on the approval.pending problem, and not kept.

health is the one operation served without a credential, which is what makes it useful for diagnosis: it separates a deployment that is down from one that refused the credential.

from general_liquidity import ApiClient, Configuration, MoneyApi
from general_liquidity.models.intent import Intent

config = Configuration(host="https://api.general-liquidity.com")

with ApiClient(config) as api_client:
    money = MoneyApi(api_client)

    intent = Intent.from_dict({
        # ... signed Intent fields per the spec ...
    })

    receipt = money.pay(
        idempotency_key="your-client-generated-key",
        intent=intent,
    )
    print(receipt)

pay submits a signed Intent; the sovereign gate evaluates mandate, caps, risk, velocity, and deny-list, then settles on the routed rail and returns a Receipt. The caller never holds a settle primitive. The idempotency_key is required on mutating operations (pay, buy) as a correctness guarantee against double-spend.

Model names (Intent, Receipt, Mandate, Order, QuoteRequest, Counterparty, ...) live under general_liquidity.models. See the generated docs/ directory for the full method and model reference.

API groups

The client is generated from the spec, so it covers every route in seven groups. Each is its own API class.

Group What
identity resolve, verify, disclose
money pay — submit a signed Intent; the gate decides before anything settles
commerce quote, buy — opt-in per deployment; a stack without the tier answers 404
governance audit, auditStream, getIntent, getIntentEvents, getUsage
memory remember, recall, assemble, verify, forget
operator approve, refund, killSwitch, resetCircuitBreaker — a separate credential
webhooks endpoint CRUD — operator authority

The gate's verdict on pay is allow, confirm or deny, deny-first. A confirm is not a receipt: it parks the intent for an operator to release. Branch on the RFC 9457 problem code, not on prose.

Commerce takes lines rather than an amount. The price comes from the server-authoritative cart the merchant priced, and only a cart in status ready can be bought.

Signing

This generated client covers transport and models only. Intent envelope signing is client-side and is not included here. You are responsible for constructing and signing the Intent before passing it to pay or buy. Only the hand-written TypeScript SDK carries the built-in operator signer today.

Layout

The package uses the Python src-layout: the importable package lives at src/general_liquidity/, and the import name stays general_liquidity. pip install -e . picks it up via package_dir={"": "src"} in setup.py.

Generation

This SDK is generated from the general-liquidity-openapi spec with openapi-generator (python generator) and is regenerated whenever the spec changes. Do not hand-edit the generated modules; change the spec and regenerate.

openapi-generator emits the package at the repo root as general_liquidity/. After regenerating, move it under src/ so the src-layout is preserved:

git mv general_liquidity src/general_liquidity

(This mirrors the Go SDK, which relocates its generated sources into client/ after each run.)

About

The General Liquidity Python SDK, generated from the machine economy API spec.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages