Skip to main content

Python Integration

An official Python SDK is on the roadmap. For now, use the REST API directly with requests. The examples below show you how.
These examples use the REST endpoint (/v1/mcp/tools/call), which is the recommended default. For the JSON-RPC endpoint (/mcp) used by MCP-native frameworks, see the TypeScript SDK. Both use the same API key authentication.

Quick Start

Install requests (if you haven’t already) and set your API key:
Verify connectivity with a free tool — no payment required:

Call a Tool

Most tools are paid. The flow is: call → receive 402 quote → pay on Solana → retry with proof.

Inference Chat

Use the inference_chat tool for LLM completions:

Code Execution (Sandbox)

Run Python code in a secure sandbox:

Multi-turn Chat

Maintain conversation history with a helper class:

Budget Protection

Track spending and enforce limits to prevent runaway costs:

Async with httpx

This section uses httpx for async HTTP. Install it with pip install httpx. The requests library (used above) does not support async.

Error Handling

Handle transient errors with exponential backoff:

MCP Integration

Use the JSON-RPC endpoint directly for MCP-native agent integrations:

Next Steps

Examples

Working examples for common use cases

Agent Quickstart

Full agent onboarding in under 2 minutes

API Reference

Complete API documentation

Payment Flow

Detailed Solana payment guide