ExchangeOptions object selects mode, supplies credentials, and overrides defaults. Hosted is the default; self-hosted is the explicit fallback when no pmxt_api_key is present.
ExchangeOptions
Constructor arguments, Python kwargs alongside TypeScript option keys.Hosted (the default)
Self-hosted (fallback)
Whenpmxt_api_key is absent, the SDK enters self-hosted mode and routes through the local pmxt-core server. Venue-native credentials apply here.
See Self-hosted for per-venue credential examples.
Environment variables
Constructor arguments always take precedence over environment variables. The env-var path is for ergonomics in deploy environments where you set
PMXT_API_KEY once.Base URL resolution
When the SDK makes a request, it picks one of three base URLs based on the operation and configuration:trade.pmxt.dev(hosted trading) — used for/v0/trade/*,/v0/user/*, and/v0/escrow/*wheneverpmxt_api_keyis set. Override withtrade_base_urlorPMXT_TRADE_BASE_URL.api.pmxt.dev(hosted catalog + reads) — used for/v0/markets,/v0/events,/api/{venue}/*wheneverpmxt_api_keyis set and the operation is not a hosted-trading write. Override withbase_urlorPMXT_BASE_URL.http://localhost:3847(self-hosted) — used for every operation whenpmxt_api_keyis absent. Override port withlocal_portorPMXT_LOCAL_PORT.
Precedence (highest to lowest)
- Explicit constructor
base_url/trade_base_url. PMXT_BASE_URL/PMXT_TRADE_BASE_URLenv var.- Default (
https://api.pmxt.dev/https://trade.pmxt.dev/http://localhost:3847).
Worked example
Hosted as default
The configuration philosophy:- Setting
pmxt_api_key(orPMXT_API_KEY) is the single switch that opts in to hosted mode. No other flag is required. - All hosted-specific URLs default to PMXT’s production endpoints — no setup beyond the API key.
- Self-hosted is the explicit fallback path. The SDK only attempts to spawn
pmxt-corewhen no API key is configured.
PMXT_API_KEY) plus a constructor with a wallet and private key is everything you need to trade.
Self-hosted fallback (advanced)
If you have specific reasons to run local — sub-100ms latency, raw venue credentials, regulatory custody — drop the API key. See Self-hosted for the full guide and Server Management for lifecycle controls.See also
- Authentication — API keys and venue credentials.
- Self-hosted — running pmxt-core locally.
- Server Management — local server lifecycle.
- Hosted vs self-hosted — when each mode applies.

