Skip to main content

JarvisClaw Agent SDK — Agent-Native AIP with autonomous tool loops, budget guards, streaming, and OpenAI drop-in compatibility.

Project description

JarvisClaw SDK v2.0 — Agent-Native AIP

The fastest way to build AI agents with automatic intent routing, budget control, and crypto payments.

Install

pip install jarvisclaw

3-Line Quickstart

from jarvisclaw import Agent

agent = Agent()  # uses JARVISCLAW_API_KEY env var
print(agent.ask("explain quantum computing in one sentence"))

That's it. AIP resolves the best model for your intent, routes the request, handles payment (API key or x402 crypto), and returns the result.

Autonomous Agent with Tools

from jarvisclaw import Agent
import requests

agent = Agent(default_budget=0.50)  # max $0.50 per run

@agent.tool
def search(query: str) -> str:
    """Search the web for current information."""
    resp = requests.get(f"https://api.search.com/v1?q={query}")
    return resp.json()["results"][0]["snippet"]

@agent.tool
def calculator(expression: str) -> str:
    """Evaluate a mathematical expression."""
    return str(eval(expression))  # sandboxed in production

# The agent autonomously decides when to use tools
result = agent.run("What's the mass of Jupiter in kg, and what's that divided by Earth's mass?")
print(result.text)           # Final answer
print(result.cost.spent_usd) # How much it cost
print(result.iterations)     # How many LLM calls

Streaming

from jarvisclaw import Agent

agent = Agent()
for chunk in agent.stream("write a haiku about distributed systems"):
    print(chunk, end="", flush=True)

OpenAI Drop-in Replacement

Zero code changes. Just swap the import:

# Before:
# from openai import OpenAI

# After:
from jarvisclaw.openai_compat import OpenAI

client = OpenAI()  # uses JARVISCLAW_API_KEY
resp = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "hello"}],
)
print(resp.choices[0].message.content)

You get AIP intent routing, automatic provider failover, and optional x402 crypto payments — all invisible to your existing code.

Budget Guards

Never overspend. Set limits at any level:

# Per-agent default
agent = Agent(default_budget=5.00)

# Per-run override
result = agent.run("analyze this dataset", budget=1.00)

# Session tracking
print(agent.cost_summary())
# {'budget_usd': 5.0, 'spent_usd': 0.0342, 'remaining_usd': 4.9658, 'requests': 3}

# Server-side limits
agent.set_limits(daily_max_usd=10.0, per_request_max_usd=0.50)

If budget is exceeded, BudgetExceededError is raised — your agent stops cleanly, never runs away.

x402 Crypto Payments (Wallet Mode)

Pay per-request with on-chain USDC. No API key needed:

from jarvisclaw import Agent

# EVM wallet
agent = Agent(private_key="0x...")

# Solana wallet  
agent = Agent(private_key="base58...", network="solana")

# Works identically — AIP handles payment signing
result = agent.ask("summarize this research paper")
print(agent.session_cost.spent_usd)  # exact cost

Intent Resolution

See what AIP routes look like under the hood:

resolution = agent.resolve(
    "image_generation",
    max_price=0.05,
    features=["high_resolution"],
    optimize="quality"
)
print(resolution["matches"][0]["provider_id"])  # e.g. "dall-e-3"

All Capabilities

Feature Method Description
Single Q&A agent.ask(prompt) One-shot, returns text
Autonomous agent.run(task) Multi-turn with tools
Streaming agent.stream(prompt) Yields chunks
OpenAI compat OpenAI().chat.completions.create(...) Drop-in
Balance agent.balance() Wallet/quota info
History agent.history() Transaction log
Providers agent.list_providers() Available models
Limits agent.set_limits(...) Spending caps

Configuration

Env Variable Purpose
JARVISCLAW_API_KEY API key authentication
JARVISCLAW_WALLET_KEY x402 private key (EVM or Solana)
JARVISCLAW_BASE_URL Custom endpoint (default: https://api.jarvisclaw.ai)

Architecture: How AIP Works

Your Code → Agent SDK → Intent Resolution → Risk Check → Route to Best Provider
                              ↓                                    ↓
                       Budget Guard                         Execute + Settle
                              ↓                                    ↓
                       Cost Tracking ←←←←←←←←←←←←←←←← Audit Trail

The Agent Intent Protocol (AIP) resolves your request to the optimal provider based on:

  • Cost: cheapest model that meets quality threshold
  • Quality: best model within budget
  • Latency: fastest response time

Migration from v1.x

# v1.x — still works!
from jarvisclaw import ChatClient
client = ChatClient(api_key="sk-...")
resp = client.chat("hello")

# v2.0 — recommended
from jarvisclaw import Agent
agent = Agent(api_key="sk-...")
print(agent.ask("hello"))

All v1.x client classes (ChatClient, ImageClient, etc.) remain available and unchanged.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jarvisclaw-2.0.0.tar.gz (47.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jarvisclaw-2.0.0-py3-none-any.whl (46.3 kB view details)

Uploaded Python 3

File details

Details for the file jarvisclaw-2.0.0.tar.gz.

File metadata

  • Download URL: jarvisclaw-2.0.0.tar.gz
  • Upload date:
  • Size: 47.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for jarvisclaw-2.0.0.tar.gz
Algorithm Hash digest
SHA256 2e15ded06f936c082ad60517c03848be0181888993e95c39cf779c8e5def1dfd
MD5 f0b3d774951fc3fa926ae9ef4895e406
BLAKE2b-256 f839c6a455a6cc8acbba0d12f4cb3acb9729fbf2485ce39bb7760823cdbf20d1

See more details on using hashes here.

File details

Details for the file jarvisclaw-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: jarvisclaw-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 46.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for jarvisclaw-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2c11ae0e2f2488ee02c79201ffb1d1d6f72e5cffdb69981ee9adc25b468b59f
MD5 a2cb341fbe3a65933df609745207495b
BLAKE2b-256 62e3115857d90420b2eeae4a4863c82d4f88e4761d1220020b690fed16fde3ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page