Solana-native payment gateway for AI agents — pay for LLM calls with USDC, no API keys
Project description
solvela
Python SDK for Solvela — a Solana-native AI agent payment gateway. AI agents pay for LLM API calls with USDC-SPL on Solana via the x402 protocol.
Installation
pip install solvela-sdk
For development:
pip install -e ".[dev]"
Quick Start
import asyncio
from solvela import SolvelaClient, ClientConfig, Wallet
async def main():
wallet, mnemonic = Wallet.create()
print(f"Wallet: {wallet.address()}")
print(f"Mnemonic (save this!): {mnemonic}")
config = ClientConfig(gateway_url="http://localhost:8402")
client = SolvelaClient(config=config, wallet=wallet)
# List available models
models = await client.models()
for m in models:
print(f" {m.id} — {m.display_name}")
# Estimate cost (triggers 402)
cost = await client.estimate_cost("gpt-4o")
print(f"Cost: {cost.cost_breakdown.total} {cost.cost_breakdown.currency}")
asyncio.run(main())
OpenAI-Compatible Interface
from solvela import SolvelaClient
from solvela.openai_compat import OpenAICompat
client = SolvelaClient()
openai = OpenAICompat(client)
# Same interface as the OpenAI Python SDK
response = await openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
Smart Features
- Response caching —
enable_cache=Truededuplicates identical requests - Session tracking —
enable_sessions=Truetracks conversation context with three-strike escalation - Quality checks —
enable_quality_check=Truedetects degraded responses and retries - Balance guard — automatic fallback to free models when USDC balance hits zero
- Balance monitor — background polling with low-balance callbacks
Configuration
from solvela import ClientConfig, ClientBuilder
# Dataclass
config = ClientConfig(
gateway_url="http://localhost:8402",
enable_cache=True,
enable_sessions=True,
enable_quality_check=True,
free_fallback_model="deepseek-chat",
max_payment_amount=100_000, # atomic USDC (0.10 USDC)
)
# Fluent builder
config = (
ClientBuilder()
.gateway_url("http://localhost:8402")
.enable_cache(True)
.max_payment_amount(100_000)
.build()
)
Running Tests
# Unit + integration tests
pytest tests/unit/ tests/integration/ -v
# Live contract tests (requires running gateway)
SOLVELA_LIVE_TESTS=1 pytest tests/live/ -v
# Linting
ruff check src/ tests/
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 solvela_sdk-0.1.3.tar.gz.
File metadata
- Download URL: solvela_sdk-0.1.3.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9382876c4627fab1d385087c5b134e7befd52ad8da7fd1a33dfccc5012158ca7
|
|
| MD5 |
251c5f1e0bd1dc7006a2fce6f9108078
|
|
| BLAKE2b-256 |
b5489be3deac777016345a6fca5f6792968e1bdc93e414f1c7e1d5433020f9d8
|
Provenance
The following attestation bundles were made for solvela_sdk-0.1.3.tar.gz:
Publisher:
release-pypi.yml on solvela-ai/solvela-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
solvela_sdk-0.1.3.tar.gz -
Subject digest:
9382876c4627fab1d385087c5b134e7befd52ad8da7fd1a33dfccc5012158ca7 - Sigstore transparency entry: 1403819691
- Sigstore integration time:
-
Permalink:
solvela-ai/solvela-python@2d7db70476b87c008d49bdc93ccf9ef4acc0481c -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/solvela-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@2d7db70476b87c008d49bdc93ccf9ef4acc0481c -
Trigger Event:
push
-
Statement type:
File details
Details for the file solvela_sdk-0.1.3-py3-none-any.whl.
File metadata
- Download URL: solvela_sdk-0.1.3-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d94d26c549b4a5b890e211588ec82a7ed3a5f73f4ab04b7afe54f09c4000952
|
|
| MD5 |
74323fac53f23e348da32f47dd34e645
|
|
| BLAKE2b-256 |
9f0132466142600ae8612eb4a91103175ac1f0bffc921eae228ded0f3f96624a
|
Provenance
The following attestation bundles were made for solvela_sdk-0.1.3-py3-none-any.whl:
Publisher:
release-pypi.yml on solvela-ai/solvela-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
solvela_sdk-0.1.3-py3-none-any.whl -
Subject digest:
4d94d26c549b4a5b890e211588ec82a7ed3a5f73f4ab04b7afe54f09c4000952 - Sigstore transparency entry: 1403819831
- Sigstore integration time:
-
Permalink:
solvela-ai/solvela-python@2d7db70476b87c008d49bdc93ccf9ef4acc0481c -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/solvela-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@2d7db70476b87c008d49bdc93ccf9ef4acc0481c -
Trigger Event:
push
-
Statement type: