Official Python SDK for SynapseNetwork agent service discovery, paid API invocation, and receipts
Project description
SynapseNetwork Python SDK
Official Python SDK for agents and applications that use SynapseNetwork to discover services, invoke APIs, and receive auditable USDC settlement receipts.
SynapseNetwork gives agents a scoped Agent Key instead of an unlimited API key or credit card. Your code can search for a service, invoke it with an explicit price or spend cap, then verify the receipt that records what happened.
Install
pip install synapse-network-ai-sdk
Python 3.9 or newer is required.
Five-minute quickstart
Create an Agent Key in the SynapseNetwork dashboard, then export it before your app starts:
export SYNAPSE_AGENT_KEY=agt_xxx
Production is the default SDK environment and uses:
https://api.synapse-network.ai
Search for a service, invoke it with the discovered fixed price, then read the receipt:
from synapse_client import SynapseClient
client = SynapseClient()
services = client.search("invoice extraction", limit=5)
service = services[0]
result = client.invoke(
service.service_id,
{"invoice_url": "https://example.com/invoice.pdf"},
cost_usdc=str(service.pricing.amount),
idempotency_key="invoice-job-001",
)
receipt = client.get_invocation(result.invocation_id)
print(receipt.status, receipt.charged_usdc)
Try the free echo service
For a production connectivity smoke test, call the first-party echo service. It is intended for SDK checks and should charge 0 USDC.
python -m pip install synapse-network-ai-sdk
export SYNAPSE_AGENT_KEY=agt_xxx
from synapse_client import SynapseClient
client = SynapseClient()
result = client.invoke(
"svc_synapse_echo",
{"message": "hello from the Python SDK"},
cost_usdc="0",
idempotency_key="python-echo-001",
)
receipt = client.get_invocation(result.invocation_id)
print(receipt.status, receipt.charged_usdc)
Invocation modes
| Mode | Use for | SDK method | Billing input |
|---|---|---|---|
| Fixed-price API | Normal provider APIs with a known price | invoke() |
Pass the latest discovered price as cost_usdc |
| Token-metered LLM | LLM services priced by input and output tokens | invoke_llm() |
Pass an optional spend cap such as max_cost_usdc |
LLM example:
result = client.invoke_llm(
"svc_deepseek_chat",
{
"messages": [{"role": "user", "content": "Summarize this document."}],
"max_tokens": 512,
},
max_cost_usdc="0.010000",
idempotency_key="llm-job-001",
)
print(result.usage.input_tokens, result.usage.output_tokens)
print(result.synapse.charged_usdc)
Provider APIs
Most users start as consumers with SynapseClient. If you operate an API that agents should call, use SynapseAuth and the provider facade from backend or operator tooling after owner authentication.
Provider setup lets you register services, publish pricing, inspect health, and reconcile earnings. Keep normal agent runtime code on SynapseClient with an existing Agent Key.
Safety rules
- Do not commit Agent Keys, owner private keys, provider secrets, wallet seed phrases, or production tokens.
- Pass money values as strings such as
"0"or"0.05"; do not recompute settlement amounts with floating-point math. - Use the discovered fixed price for
invoke()and a spend cap forinvoke_llm(). - Use
gateway_urlonly for private deployments or documented sandboxes. Public examples should target production.
Links
- SDK docs: docs.synapse-network.ai/sdks/python
- PyPI: pypi.org/project/synapse-network-ai-sdk
- Source: github.com/SynapseNetworkAI/Synapse-Network-Sdk
- Issues: github.com/SynapseNetworkAI/Synapse-Network-Sdk/issues
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file synapse_network_ai_sdk-1.0.1.tar.gz.
File metadata
- Download URL: synapse_network_ai_sdk-1.0.1.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b1479276eb12cf6f80307d9693c6080a941fcfbe39e30480f4853716bdd43c8
|
|
| MD5 |
db5590bf06c20100253f383267c8b0ec
|
|
| BLAKE2b-256 |
20b9de64b4ff7a7afc259eaec7443ae1ac5c3930ec467ab244428466f968ab26
|
File details
Details for the file synapse_network_ai_sdk-1.0.1-py3-none-any.whl.
File metadata
- Download URL: synapse_network_ai_sdk-1.0.1-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35a298f1d70a1112dd23cb62e37fbaae114a9bb66ef483645abd221f7f08b0a5
|
|
| MD5 |
6c7aa17a507740d21e6a9c6c7b3306fb
|
|
| BLAKE2b-256 |
47bb779eac74bef113b7425a1e851040c5f3b4bc2f5127b491e647e4e3dc5b16
|