Skip to main content

BaseCodeAgent SDK

Python SDK for interacting with BaseCodeAgent — discoverable AI agent services on Base with x402 payments.

Installation

pip install httpx  # required dependency
# or install from local path:
pip install -e .

Quick Start

Sync Client

from basecodeagent import BaseCodeAgent

# Initialize
client = BaseCodeAgent(url="https://agent-service-production-bb95.up.railway.app")

# Discover services
services = client.discover()
for svc in services:
    print(f"• {svc.name}: {svc.price_usd}")

# Check health
health = client.health()
print(f"Agent: {health['agent']}")

# Get metrics
metrics = client.get_metrics()
print(f"Requests: {metrics['requests']['total']}")

# Call a service (requires payment token)
result = client.call_service(
    service="code-review",
    payment_token="x402-mock-abc123",
    code="def hello(): print('world')",
    language="python"
)

if result.is_success:
    print(result.result)

Async Client

import asyncio
from basecodeagent import AsyncBaseCodeAgent

async def main():
    async with AsyncBaseCodeAgent() as client:
        # Discover services
        services = await client.discover()
        
        # Call service
        result = await client.call_service(
            service="code-review",
            payment_token="x402-mock-abc123",
            code="def hello(): print('world')",
            language="python"
        )
        print(result)

asyncio.run(main())

Context Manager (Auto-close)

from basecodeagent import BaseCodeAgent

with BaseCodeAgent() as client:
    services = client.discover()
    print(f"{len(services)} services available")
    # Client automatically closed

API Reference

BaseCodeAgent(url, timeout=30, verify_ssl=True)

Parameters:

  • url: Agent service base URL
  • timeout: Request timeout in seconds
  • verify_ssl: Verify SSL certificates

Methods:

  • discover() → List[ServiceInfo] — List all services
  • discover_dict() → Dict[str, ServiceInfo] — Services as dict
  • health() → Dict — Health check
  • get_metrics() → Dict — Service metrics
  • call_service(service, payment_token, **kwargs) → ServiceResponse — Call a service
  • settle_payment(pay_to, service, price, admin_api_key) → Dict — Admin settlement
  • close() — Close HTTP connection

AsyncBaseCodeAgent(url, timeout=30, verify_ssl=True)

Same interface as sync client, but all methods are async.

ServiceInfo

Dataclass with service metadata:

  • name, description, price_usd, price_atomic
  • network, tags, required_fields, allowed_fields, examples
  • price_float — Parsed price as float

ServiceResponse

Dataclass with service response:

  • status, service, request_id, result, payment_verified, timestamp
  • is_success — Property returning True if successful

Requirements

  • Python 3.9+
  • httpx (automatically installed)

License

MIT

Release files for basecodeagent 0.1.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 basecodeagent 0.1.0
File Size Uploaded
basecodeagent-0.1.0.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for basecodeagent 0.1.0
File Interpreter ABI Platform
basecodeagent-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / basecodeagent-0.1.0.tar.gz

Download URL basecodeagent-0.1.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
aa806f60527ecd51240cc35b76ef6963d1ef575b37cde9ff90c677e70c0403c8
BLAKE2b-256 checksum
How to use checksums
fac49ad8ae8c490c0d56c12613ad48115fa4f47026beee9376580ebb07147db4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release files / basecodeagent-0.1.0-py3-none-any.whl

Download URL basecodeagent-0.1.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b015ae58ca1e454f8d7de1683abc485d1567cb54b6b562e659f00a8eb048ceed
BLAKE2b-256 checksum
How to use checksums
eeeabf56d6f6cfb6ce05d350669c553cb94b718101b4aef0e66dab709e0abaf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

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