Metadata-Version: 2.4
Name: gate402
Version: 0.1.0
Summary: Python client for Gate402 — pay-per-call GPU/CPU compute, open-model LLM inference, and crypto/finance data for AI agents over x402 (USDC on Base). No signup, free tier.
Project-URL: Homepage, https://gate402.app
Project-URL: Documentation, https://gate402.app/llms.txt
Project-URL: Repository, https://github.com/pgalyen1987/gate402-py
Author: Gate402
License: MIT
License-File: LICENSE
Keywords: agent-tools,agents,ai-agents,base,compute,defi,gpu,gpu-compute,inference,llama,llm-inference,mcp,micropayments,onchain,pay-per-call,rent-gpu,usdc,x402
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Requires-Dist: requests>=2.25
Description-Content-Type: text/markdown

# gate402

Python client for **[Gate402](https://gate402.app)** — pay-per-call **GPU/CPU compute + open-model LLM inference**, plus crypto/finance data and web tools, for AI agents over **x402** (USDC on Base). **No signup**: a free-tier key is auto-claimed on first use.

```bash
pip install gate402
```

## Quick start

```python
from gate402 import Gate402

g = Gate402()  # free-tier key auto-claimed on first call (or set GATE402_API_KEY)

# Open-model LLM inference, billed per token
print(g.infer(prompt="Say hello in five words.")["text"])

# Rent GPU/CPU compute for a container job, billed per second
job = g.compute(image="ghcr.io/acme/vllm:latest", gpu="rtx4090", duration_sec=300, model="llama-3.1-8b")

# On-chain wallet / token intel on Base
print(g.onchain("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"))
```

## Methods

| Method | Endpoint | What it does |
|---|---|---|
| `infer(prompt=…, model=…)` | `/v1/infer` | Per-token LLM inference (Llama 3.1 / Qwen / Mistral) |
| `compute(image, gpu, duration_sec)` | `/v1/compute` | Rent metered GPU/CPU per second; signed receipt |
| `onchain(address)` | `/v1/onchain` | Wallet/token intel on Base |
| `dex(address)` | `/v1/dex` | Live DEX price / liquidity / volume |
| `token_risk(address)` | `/v1/token-risk` | Rug/tradeability verdict + honeypot sim |
| `momentum(address)` | `/v1/momentum` | Momentum + order-flow signal |
| `best_swap(address, size_usd=…)` | `/v1/best-swap` | Best pool + price impact for a trade size |
| `launches()` | `/v1/launches` | Freshest Base token launches |
| `news(query)` / `edgar(ticker=…)` | `/v1/news`, `/v1/edgar` | News+sentiment / SEC filings |
| `scrape(url, stealth=False)` | `/v1/proxy` | Fetch a page as clean Markdown |
| `minify(text)` / `dedup(query)` | `/v1/minify`, `/v1/dedup` | Token compression / semantic cache |
| `catalog()` | `/v1` | **Free.** Machine-readable endpoint catalog |
| `providers()` | `/v1/providers` | **Free.** Browse the GPU marketplace supply |
| `market_infer(model, prompt=…)` | `/v1/market/infer` | Marketplace inference — **x402-native** (see below) |

## Billing

The payment *is* the auth — there are no accounts to create. On first use the client
self-claims a **free-credit key** from Gate402 and reuses it. When credit runs out,
calls raise `Gate402PaymentRequired` with a top-up link. Pass `api_key=…` or set
`GATE402_API_KEY` to use a funded account.

```python
from gate402 import Gate402, Gate402PaymentRequired
try:
    g.infer(prompt="…")
except Gate402PaymentRequired as e:
    print(e)  # → top-up link
```

## GPU marketplace

`providers()` lists third-party GPU/compute supply (free). The buyer endpoint
`market_infer()` is **x402-native** — it settles on-chain per call with
escrow-on-success, so the free-tier / API-key rail cannot pay it and it raises
`Gate402PaymentRequired`. Use an x402 payment client to call `POST /v1/market/infer`
directly. To *sell* your GPU, register at `POST /v1/providers/register`.

## Configuration

| Env var | Default | Purpose |
|---|---|---|
| `GATE402_API_KEY` | _(auto free tier)_ | A funded account key to skip the free tier |
| `GATE402_BASE_URL` | `https://gate402.app` | Override the gateway base URL |

MIT licensed.
