Skip to main content

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 for invoke_llm().
  • Use gateway_url only for private deployments or documented sandboxes. Public examples should target production.

License

MIT

Metadata

Release files for synapse-network-ai-sdk 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for synapse-network-ai-sdk 1.0.1
File Size Uploaded Provenance Actions
synapse_network_ai_sdk-1.0.1.tar.gz 22.4 kB Without provenance Details for synapse_network_ai_sdk-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for synapse-network-ai-sdk 1.0.1
File Interpreter ABI Platform Actions
synapse_network_ai_sdk-1.0.1-py3-none-any.whl Python 3 none any Details for synapse_network_ai_sdk-1.0.1-py3-none-any.whl

Total release size: 48.1 kB

Release files / synapse_network_ai_sdk-1.0.1.tar.gz

Download URL synapse_network_ai_sdk-1.0.1.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6b1479276eb12cf6f80307d9693c6080a941fcfbe39e30480f4853716bdd43c8
BLAKE2b-256 checksum
How to use checksums
20b9de64b4ff7a7afc259eaec7443ae1ac5c3930ec467ab244428466f968ab26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / synapse_network_ai_sdk-1.0.1-py3-none-any.whl

Download URL synapse_network_ai_sdk-1.0.1-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35a298f1d70a1112dd23cb62e37fbaae114a9bb66ef483645abd221f7f08b0a5
BLAKE2b-256 checksum
How to use checksums
47bb779eac74bef113b7425a1e851040c5f3b4bc2f5127b491e647e4e3dc5b16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for synapse-network-ai-sdk 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page