Skip to main content
The Python exposes the Machine Markets API on the existing PeaqosClient via client.orchestration. Flat methods, sync, snake_case, frozen-slotted dataclasses.
client.orchestration works only on a client constructed without tokenomics20. On a Tokenomics 2.0 client (tokenomics20 passed to the constructor, or TOKENOMICS_DEPLOYMENT_ID set in the environment that from_env() reads, which peaqos init writes), list_machines, get_machine, create_machine, update_machine, create_machine_identity_challenge, create_agent_pairing_challenge, and search_market raise TokenomicsIntegrationUnavailableError before any request is sent, so pairing and ordering cannot start. Pairing also needs an active, bonded Tokenomics 1.0 machine; see Scale.

Setup

Functional form, handy for testing:
Accessing client.orchestration without orchestration_url raises OrchestrationConfigError.

Configuration

Constructor kwargs

Env vars (via PeaqosClient.from_env())

Transport constants:
User-Agent: peaqos-sdk-py/<version>. Per-method timeout overrides are not exposed on public methods.

Envelopes

204 No Content returns None. validate_list_limit rejects limit < 1 or limit > 500 with OrchestrationValidationError.

Machines

Machine shape:

Machine agents

enroll_machine_agent returns ItemResponse[MachineAgent]. The server sends the one-time token as agentToken, and the Python SDK maps item.provisioning_token from a provisioning_token key that the server does not send, so it comes back None. To capture the token, call POST /machines/:machineId/agents/enrollment directly (see the orchestration API) and read item.agentToken. machine_agent_heartbeat uses no auth header: agent_token rides in the JSON body.

Machine identity challenges

Requests a server-issued challenge tied to a did:peaq:0x... or peaqos:machine:<id> identity reference. The DID controller signs item.message with EIP-191 personal_sign and submits the resulting {challengeId, signature} as identity_proof when creating or updating the machine record.

Agent pairings

Pairing is challenge-based end to end:
  1. create_agent_pairing_challenge returns a server-issued challenge keyed to agent_address, agent_provider, agent_role, and optional agent_did.
  2. The item.message (EIP-191) with the key behind agent_address.
  3. create_agent_pairing accepts the proof in params.agent_proof and returns the pairing with a signed HS256 session JWT in pairing_token. The token is returned once at create.
  4. create_agent_pairing_session rotates the session token before expiry with a fresh proof. Required after any update_agent_pairing to the , since policy changes invalidate the current token’s delegation_policy_hash.
Both create methods set pairing_token exactly once each. AgentPairing.__repr__ redacts the token to keep it out of logs. CreateAgentPairingRequest requires agent_proof: AgentProofInput and accepts an optional agent_did. delegation_policy carries service-level allow/deny lists (allowed_service_ids, denied_service_ids) next to the skill-level ones.

Runtime endpoints

upsert_runtime_endpoint validates that endpoint_base_url parses as http/https with a non-empty host. auth_token is treated as a secret in error redaction.

Skills

Market services

search_market uses x-agent-pairing-token auth: the token rides as the second argument and is sent per call. get_market_search uses platform auth.

Market orders

list_market_orders and get_market_order use platform auth; the four mutating calls require the agent’s pairing_token. execute_market_order returns execution.run and execution.outcome for a native run (execution.status_code == 200). When the order resolves to an external handoff the server answers 202, the order moves to handoff, and the call raises OrchestrationApiError with code INVALID_RESPONSE_SHAPE. Catch it and read the handoff from the order: once client.orchestration.get_market_order(order_id).item.status == "handoff", item.handoff carries label, url and notes. For x402-rail services, sign_x402_payment signs the provider challenge from create_payment_intent locally, submit_x402_payment_proof records the signature, and the same signature goes on ExecuteMarketOrderRequest.payment (X402ExecutePayment).

Payment settlement

submit_payment_proof accepts both EVM and Solana proof shapes; verification_mode is "recorded" | "rpc". RPC verification cross-checks the ERC-20 Transfer log against expected token, payer_address, payee_address, and amount.

Pagination

Six sync auto-paginated iterators:
Each *_all accepts the same filter kwargs as its non-iterator counterpart, minus cursor. limit controls page size; cursor is managed internally. For manual pagination, the underlying list_* methods accept cursor and limit as keyword-only args:
MarketSearch:

Policies

Cross-cutting policy records above and beyond a pairing’s delegation policy. Platform auth.
There is no get_policy method. Fetch policies with list_policies.

Observability

check_health requests /api/v1/health, which returns 404 on the hosted orchestrator: the health route is GET /health at the host root, so call it over HTTP. list_audit_events sends machine_id, but the server ignores it and filters only on type, resourceType and resourceId; filter the returned events by machine yourself.

HTTP-only endpoints

These endpoints exist on the HTTP API (see Machine Markets API: Orchestration) and have no SDK method. Call them over HTTP:
  • Tasks: create, list, get, discover, resolve, execute
  • Graph: read a machine graph, create/update/delete nodes and edges
  • Policies: get a single policy
  • Runs: list runs, get a run

Errors

All extend peaq_os_sdk.exceptions.base.PeaqosError:
CommonErrorCode literal: AUTH_REQUIRED, AUTH_INVALID, AGENT_AUTH_REQUIRED, AGENT_AUTH_INVALID, AGENT_AUTH_EXPIRED, VALIDATION_ERROR, NOT_FOUND, MACHINE_NOT_ACTIVE, MACHINE_NOT_ACTIVATED, MACHINE_IDENTITY_EXISTS, MACHINE_IDENTITY_IMMUTABLE, MACHINE_IDENTITY_PROOF_REQUIRED, MACHINE_IDENTITY_PROOF_INVALID, MACHINE_IDENTITY_PROOF_EXPIRED, PEAQOS_IDENTITY_UNAVAILABLE, AGENT_PAIRING_PROOF_REQUIRED, AGENT_PAIRING_PROOF_INVALID, AGENT_PAIRING_PROOF_EXPIRED, AGENT_PAIRING_UNAVAILABLE, AGENT_PAIRING_REQUIRED, AGENT_PAIRING_INACTIVE, AGENT_POLICY_DENIED, AGENT_SPEND_LIMIT_EXCEEDED, AGENT_DAILY_LIMIT_EXCEEDED, QUOTE_EXPIRED, ORDER_CLOSED, ORDER_NOT_DELIVERED, EXECUTION_UNSUPPORTED, PAYMENT_REQUIRED, PAYMENT_RPC_REQUIRED, PAYMENT_RPC_ERROR, PAYMENT_NOT_MINED, PAYMENT_TX_FAILED, PAYMENT_TRANSFER_NOT_FOUND. Proof and credential types:
MarketPaymentRailType literal: "not-required", "wallet", "xvv42", "x402", "vault-stripe", "escrow", "offchain-record", "external", "onchain-escrow", "wdk-usdt-transfer". The transport synthesises BAD_RESPONSE (non-JSON body) and INVALID_RESPONSE_SHAPE (envelope mismatch) when the server response is malformed.

Sync vs async

Sync only. Every public function is plain def over requests.Session. The transport reuses client.session, so you can wrap retries externally.

Credential handling

  • Platform (x-api-key): set once on the client via api_key, sent on every call by default.
  • Agent pairing (x-agent-pairing-token): passed per call as the last argument to search_market, the order mutations, and the payment mutations. The SDK does not store or rotate it.
  • None: used only by machine_agent_heartbeat (token rides in the body).
_sanitize_body redacts any field whose name contains token, key, secret, password, credential, or auth (case-insensitive) before attaching the body to an error.