Python SDK: suede-ai
suede-ai is the Python client for Suede's x402 endpoints. It reads the 402 challenge, signs the EIP-3009 USDC authorization on Base with your key, and replays the request, so your code sends prompts and gets back a job to collect. Version 0.4.0 was released on PyPI on 2026-08-29 under the MIT license.
Install
pip install suede-ai
Requires Python 3.10 or later. It installs httpx (0.27 or later), eth-account (0.10 or later) and pydantic (2.6 or later).
Generate an image and collect it
import os
import time
import httpx
from suede_ai import SuedeClient
with SuedeClient(wallet_private_key=os.environ["SUEDE_WALLET_KEY"]) as suede:
job = suede.agent_image(
prompt="Album cover, neon city at night, rain on glass",
aspect_ratio="1:1",
output_format="png",
)
# A paid call is queued, so the SDK returns the 202 body with a pollUrl.
while True:
state = httpx.get(job["pollUrl"]).json()
if state["status"] in ("completed", "failed"):
break
time.sleep(5)
print(state.get("imageUrl"))
The key signs real USDC transfers on Base mainnet. Keep it in an environment variable or a secret store, and use a wallet funded with what you plan to spend. The SDK sends PAYMENT-SIGNATURE on the retry, which makes the call asynchronous by default, so every typed method returns a job to poll. Polling is free; the endpoint reference lists each poll route and its finished state.
Client options
| Argument | Default | Use |
|---|---|---|
wallet_private_key | Required | Hex private key, with or without 0x. Signs the EIP-3009 authorizations. |
base_url | https://app.suedeai.ai | API host. |
http_client | None | Your own httpx.Client. |
timeout | 60 s read, 10 s connect | Per-request timeout. |
max_payment_attempts | 1 | Paid retries after a 402: one challenge, one paid retry. |
Methods for the live endpoints
| Method | Calls | Body it sends |
|---|---|---|
create_music(prompt, duration_seconds=30, style=None) | POST /create-music | prompt, durationSeconds, style |
agent_video(prompt, duration_seconds=8, aspect_ratio=None, resolution=None) | POST /agent/video | prompt, durationSeconds, aspectRatio, resolution |
agent_image(prompt, aspect_ratio=None, output_format=None) | POST /agent/image | prompt, aspectRatio, outputFormat |
manifest() | GET /.well-known/x402.json | None. Free; read prices before you sign. |
request(method, path, json=None, params=None) | Any path | Your JSON. Handles the 402 the same way. |
The typed methods take keyword arguments only. For /create-music fields the typed method does not expose, such as lyrics, custom_mode, make_instrumental, vocal_gender or tags, call request():
job = suede.request("POST", "/create-music", json={
"prompt": "A melancholic acoustic guitar ballad about rain",
"make_instrumental": True,
})
# Poll job["pollUrl"] until model_version is no longer "pending".
How the SDK pays
- It sends your request with no payment.
- On a 402 it reads the
PAYMENT-REQUIREDheader, falling back to the JSON body. - It picks the
acceptsentry with schemeexact, networkeip155:8453and the USDC contract0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913. - It signs
TransferWithAuthorizationforamounttopayTo, with a random 32-byte nonce,validAfter60 seconds in the past andvalidBeforeat now plus the larger of 600 seconds andmaxTimeoutSecondsplus 60. - It base64-encodes an x402 version 2
PaymentPayload(x402Version,resource,accepted,extensions,payload) and replays the request withPAYMENT-SIGNATURE. - It returns the JSON of the first response that is not a 402.
The quickstart shows the same exchange with curl, field by field.
Exceptions
| Exception | Raised when |
|---|---|
suede_ai.PaymentRequired | The 402 offers no exact USDC-on-Base entry to sign. |
suede_ai.X402Error | The response is still 402 after max_payment_attempts paid retries. PaymentRequired is a subclass. |
httpx.HTTPStatusError | Any other non-2xx response, such as a 422 or 429. See the errors page. |
Test the SDK boundary before an upgrade
- Pin the package version your application tested and record it in the release notes. Run
python -m pip show suede-aito check the installed version. - Fetch the manifest without submitting a paid job. Compare the methods and body fields you use with the current OpenAPI. A parameter in a typed SDK method describes what the client sends, not a guarantee of output duration, resolution or framing.
- Use local fixtures for a successful accept, missing payment option, 422, 429 and a transport timeout. On accept, persist the returned job reference. A timeout from the submit call should not cause your application to invoke the typed method again automatically.
- Poll the saved job from a read-only worker. Test one fixture with in-progress status and another with completed status but a missing asset URL. Neither is ready for delivery.
Route payment negotiation and API errors differently: PaymentRequired is a subtype of X402Error, so catch it first when you need distinct behavior. Use the recovery table for HTTP or transport outcomes.
Releases
| Version | Released |
|---|---|
| 0.4.0 | 2026-08-29 |
| 0.3.1 | 2026-07-09 |
| 0.3.0 | 2026-06-17 |
| 0.2.0 | 2026-06-17 |
| 0.1.0 | 2026-06-05 |
The package also ships helpers for older /v1/* routes, such as extend, cover and stems_pro. Those routes are not in the live x402 manifest; the three typed methods above cover the current catalog.
Frequently asked questions
How do I install the Suede Python SDK?
Run pip install suede-ai on Python 3.10 or later. The package is suede-ai on PyPI and is imported as suede_ai.
Does the SDK poll for the finished asset?
No. Each typed method returns the 202 body with a pollUrl, and your code polls it, as in the example above. Polling needs no payment and no wallet key.
How do I send lyrics or an instrumental flag to Create Music?
The typed create_music method does not expose lyrics, custom_mode, make_instrumental, vocal_gender or tags. Send them with request(), which handles the 402 the same way.
Can the SDK charge my wallet more than once for one call?
By default it makes one paid retry after the 402 challenge (max_payment_attempts=1). If the response is still 402 after that, it raises suede_ai.X402Error instead of signing again.
Is the SDK open source?
Yes. It is released under the MIT license, and the source is in the Suede-AI/suede-sdk-python repository.
Sources
- suede-ai on PyPI: version, release dates, Python requirement, dependencies and license.
- Suede-AI/suede-sdk-python: the SDK repository. The client and payment behavior on this page was read from the 0.4.0 wheel on PyPI on 2026-10-11.
- app.suedeai.ai/.well-known/x402: the manifest the SDK reads.