Prerequisites
- Python 3.10 or later
- A SolvaPay account with a product and at least one plan
Install the package
Set up with the CLI
In an existing project,npx solvapay init signs you in, writes SOLVAPAY_SECRET_KEY and SOLVAPAY_PRODUCT_REF to .env, and adds solvapay pinned exactly with uv or Poetry (for pip it prints the install command). It needs Node.js 22 or later to run. The SDK reads environment variables, not .env, so load .env when your app starts (python-dotenv) or export the variables.
npx solvapay doctor checks that the SDK is the newest release and prints the upgrade command. See CLI setup for the flags.
Set environment variables
To get the values:
- In SolvaPay Console, go to Developers > API Keys and copy a sandbox secret key into
SOLVAPAY_SECRET_KEY. - Open your product and copy its reference into
SOLVAPAY_PRODUCT_REF.
create_solvapay() reads these variables. It raises SolvaPayError with code missing_secret when there is no secret key. A paid function or MCP tool raises missing_product when it’s registered without a product.
Configure in code
Pass the same settings as arguments to override the environment:max_retries applies only to requests that are safe to send twice: reads, and writes with an idempotency key. It retries on 429, 502, 503, 504 and network errors.
Versions
The Python SDK has its own version line, starting at 0.1.0. Its numbers don’t follow the TypeScript packages. What the two share is the API spec and the conformance suite, so a Python release behaves the same as the TypeScript release that passes the same suite version. Until 1.0.0, a minor release (0.x to 0.y) may change the API. Pin a minor version in production:Next steps
- Quick start: make a function paid.
- Paid MCP server: charge for MCP tools.