Skip to main content

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("openai/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="openai/gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
)

Smart Features

  • Response cachingenable_cache=True deduplicates identical requests
  • Session trackingenable_sessions=True tracks conversation context with three-strike escalation
  • Quality checksenable_quality_check=True detects 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/

Documentation

docs.solvela.ai/sdks/python — full reference, async patterns, error handling.

License

Apache-2.0

Release files for solvela-sdk 0.4.0

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

Source distribution (sdist)

Source distribution for solvela-sdk 0.4.0
File Size Uploaded
solvela_sdk-0.4.0.tar.gz 39.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for solvela-sdk 0.4.0
File Interpreter ABI Platform
solvela_sdk-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 84.9 kB

Release files / solvela_sdk-0.4.0.tar.gz

Download URL solvela_sdk-0.4.0.tar.gz
Size 39.0 kB
Tags Source
SHA-256 checksum
How to use checksums
12cddd9fe1a718537cc90f8bb282903c790918d18a46a689302f7fb441a4acbd
BLAKE2b-256 checksum
How to use checksums
4c13cf0b7616c8060017eb0adb8f6b60b4d03078e7c8be72536daaa005e17048
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.

Transparency log

Release files / solvela_sdk-0.4.0-py3-none-any.whl

Download URL solvela_sdk-0.4.0-py3-none-any.whl
Size 45.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d975d8ca7808573a3c6293a09324766de515b3cfa14150e9a31752528249d1c
BLAKE2b-256 checksum
How to use checksums
3cf1adbe22ab88644c4a10b887db02c8c10f1c5bebad5e3c01dd9c68df0a97d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

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