@aeon-ai-pay/aigateway 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +236 -66
- package/bin/cli.mjs +1 -0
- package/docs/env-vars.md +12 -14
- package/docs/exit-codes.md +25 -15
- package/docs/ide-setup.md +2 -2
- package/docs/output-schema.md +73 -58
- package/docs/recipes/cron-issue-cards.md +34 -16
- package/docs/recipes/error-recovery.md +47 -16
- package/docs/recipes/integrate-in-agent.md +37 -16
- package/docs/recipes/merchant-integration.md +61 -32
- package/docs/troubleshooting.md +61 -13
- package/package.json +11 -5
- package/skills/aigateway/SKILL.md +47 -25
- package/src/catalog.mjs +3 -2
- package/src/commands/sb-invoke.mjs +14 -2
- package/src/commands/sb-tools.mjs +4 -2
- package/src/commands/wallet-init.mjs +27 -1
- package/src/config.mjs +13 -0
- package/src/constants.mjs +3 -0
- package/src/coupon.mjs +62 -0
- package/templates/cline/.clinerules +36 -18
- package/templates/codex/AGENTS.md +48 -16
- package/templates/cursor/.cursor/rules/aigateway.mdc +27 -14
- package/templates/windsurf/.windsurfrules +24 -13
package/README.md
CHANGED
|
@@ -1,115 +1,285 @@
|
|
|
1
1
|
# AEON AI Gateway
|
|
2
2
|
|
|
3
|
-
> AI Agents
|
|
3
|
+
> **Co-presented by AEON & SkillBoss** — AI Agents pay per-call in USDT on BSC to invoke 200+ AI tool capabilities.
|
|
4
4
|
>
|
|
5
|
-
> **
|
|
5
|
+
> **Zero API keys · Zero prepay · x402 protocol pay-per-call · Natural-language driven**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## 🚀 AEON x BNB Chain: AI Agent Campaign
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
> **Your AI agent is ready to work — now let it pay.**
|
|
12
|
+
|
|
13
|
+
AEON and **BNB Chain** are launching the **AI Agent Campaign**, opening up a native payment rail for autonomous AI agents on BNB Chain. With BNB assets, your agent can now call LLMs, APIs, skills, and compute resources — and settle instantly on-chain.
|
|
14
|
+
|
|
15
|
+
**How it works**
|
|
16
|
+
|
|
17
|
+
Agents pay with BNB-native assets through AEON's infrastructure. Every API call, every model inference, every skill invocation — settled seamlessly, no human in the loop.
|
|
18
|
+
|
|
19
|
+
**🎁 First 1,000 users get $5 USDT in free credits** to start using AEON Skills and experience what agentic commerce actually feels like.
|
|
20
|
+
|
|
21
|
+
Build agents that don't just think — but **transact**.
|
|
22
|
+
|
|
23
|
+
→ **[Claim your $5 free credits (Google Form)](https://docs.google.com/forms/d/e/1FAIpQLSe8WF6-Y8Sh2AEC_hEGScyl_gQRahPYWPMDewdXJlfeVENENg/viewform?usp=publish-editor)** · Deploy your agent. Let it run.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
`@aeon-ai-pay/aigateway` is a unified CLI + Agent Skill. Through a single session-key wallet and the [x402 protocol](https://www.x402.org/), it opens up SkillBoss's 200+ tool capabilities (image / video / audio / search / scraping / email / document / social data / UI generation, etc.) to AI Agents for pay-per-call invocation.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## About SkillBoss
|
|
32
|
+
|
|
33
|
+
**SkillBoss** is a unified AI API + Agent Skills platform — a single API Key gives you access to models and tool capabilities from multiple providers, covering chat & reasoning, search, web scraping, image generation, video generation, audio, document processing, email, data services, and website / full-stack app deployment. Native support for Claude Code, Codex, Cursor, Windsurf, and other AI Agent tools.
|
|
34
|
+
|
|
35
|
+
| Dimension | Data |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| **Public API endpoints** | 359 |
|
|
38
|
+
| **Service providers** | 50 |
|
|
39
|
+
| **Official Skill packages** | 1 main + 4 sub: `skillboss` / `skillboss-image` / `skillboss-video` / `skillboss-marketing` / `skillboss-cold-email` |
|
|
40
|
+
| **Skills Marketplace** | 500+ ready-to-use skills |
|
|
41
|
+
|
|
42
|
+
**Full capability surface**: LLM / Chat · Embedding · Search · Scraping · Image · Video · Audio (TTS / STT) · Document · Social / Business Data · Email · Finance / Utility · Platform / Storage · Marketing / Cold Email · Full-stack App / Website Build & Deploy
|
|
43
|
+
|
|
44
|
+
### SkillBoss Resources
|
|
45
|
+
|
|
46
|
+
| Entry | URL |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| API web catalog | https://www.skillboss.co/docs/api-catalog |
|
|
49
|
+
| API JSON catalog | https://www.skillboss.co/api-catalog.json |
|
|
50
|
+
| Skills marketplace | https://www.skillboss.co/skills |
|
|
51
|
+
| Skills index API | https://www.skillboss.co/api/skills/index |
|
|
52
|
+
| Skills search API | https://www.skillboss.co/api/skills/search |
|
|
53
|
+
| Agent install entry | https://www.skillboss.co/skill.md |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Architecture
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
┌────────────────────────────────────────────────────────────┐
|
|
61
|
+
│ AI Agent (Claude Code / Cursor / Codex / Windsurf / ...) │
|
|
62
|
+
└────────────────────┬───────────────────────────────────────┘
|
|
63
|
+
│ natural-language instructions
|
|
64
|
+
▼
|
|
65
|
+
┌────────────────────────────────────────────────────────────┐
|
|
66
|
+
│ aigateway CLI (@aeon-ai-pay/aigateway) │
|
|
67
|
+
│ sb tools ──→ server catalog (model + tier + schema) │
|
|
68
|
+
│ sb invoke ──→ client-side inputs validation │
|
|
69
|
+
│ ──→ x402 phase 1 (402 response: live price) │
|
|
70
|
+
│ ──→ EIP-712 signing (session key, gasless) │
|
|
71
|
+
│ ──→ auto-download image / video / audio │
|
|
72
|
+
└────────────────────┬───────────────────────────────────────┘
|
|
73
|
+
│ HTTP + x402
|
|
74
|
+
▼
|
|
75
|
+
┌────────────────────────────────────────────────────────────┐
|
|
76
|
+
│ AEON x402 Gateway (ai-api.aeon.xyz) │
|
|
77
|
+
│ dynamic pricing by model.priceUnit × usage │
|
|
78
|
+
│ proxies calls to SkillBoss upstream │
|
|
79
|
+
└────────────────────┬───────────────────────────────────────┘
|
|
80
|
+
│
|
|
81
|
+
▼
|
|
82
|
+
┌────────────────────────────────────────────────────────────┐
|
|
83
|
+
│ SkillBoss (api.skillboss.co) │
|
|
84
|
+
│ 50 vendors · 359 endpoints │
|
|
85
|
+
└────────────────────────────────────────────────────────────┘
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Capability Categories
|
|
91
|
+
|
|
92
|
+
| Category | Pricing Unit | Description |
|
|
93
|
+
| --- | --- | --- |
|
|
94
|
+
| `image` | `per_image` | Image generation / editing / upscaling / background removal |
|
|
95
|
+
| `video` | `per_second` | Video generation (requires `duration_seconds`) |
|
|
96
|
+
| `tts` | `per_1k_chars` | Text-to-speech / sound effect generation |
|
|
97
|
+
| `stt` | `per_minute` | Speech-to-text (requires `duration_minutes`) |
|
|
98
|
+
| `search` | `per_request` | Web search / map search |
|
|
99
|
+
| `scraper` | `per_request` | Web scraping / structured extraction |
|
|
100
|
+
| `social_data` | `per_request` | Social / business data |
|
|
101
|
+
| `sms` | `per_request` | SMS / OTP / email verification |
|
|
102
|
+
| `document` | `per_request` | Document parsing (PDF / DOCX → Markdown) |
|
|
103
|
+
| `ui_generation` | `per_request` | UI / prototype / slide deck generation |
|
|
104
|
+
| `embeddings` | `per_million_tokens` | Text embedding vectors |
|
|
105
|
+
| `financial` | `per_request` | Stock / forex / crypto / financial news |
|
|
106
|
+
| `news` | `per_request` | News APIs |
|
|
107
|
+
| `utility` | `per_request` | Domain / QR code / geo / dictionary and other utility APIs |
|
|
108
|
+
|
|
109
|
+
### Querying models at runtime
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Fetch the full catalog
|
|
113
|
+
aigateway sb tools
|
|
114
|
+
|
|
115
|
+
# Filter by category
|
|
116
|
+
aigateway sb tools --category image
|
|
117
|
+
aigateway sb tools --category video
|
|
118
|
+
|
|
119
|
+
# Filter by tier (price percentile within a category: price / balanced / quality)
|
|
120
|
+
aigateway sb tools --tier price
|
|
121
|
+
aigateway sb tools --category image --tier quality
|
|
122
|
+
|
|
123
|
+
# Look up a single model (with effectiveSchema)
|
|
124
|
+
aigateway sb tools --model <model_id>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Response shape: `categories[].models[]`. Each model carries `id` / `vendor` / `useCase` / `price` / `priceUnit` / `tier` / optional `inputsOverride`. Each category carries `agentTrigger` / `defaultInputsSchema`.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Prerequisites
|
|
132
|
+
|
|
133
|
+
- Node.js ≥ 25
|
|
134
|
+
- A WalletConnect-compatible mobile wallet (MetaMask / OKX Wallet / Trust Wallet, etc.)
|
|
135
|
+
- Your main wallet holds USDT (BEP-20) plus a small amount of BNB (for the first-time approve gas, ~$0.002)
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Installation
|
|
140
|
+
|
|
141
|
+
### Step 1: Install the CLI (npm)
|
|
12
142
|
|
|
13
143
|
```bash
|
|
14
|
-
|
|
15
|
-
npx skills add AEON-Project/aigateway -g -y
|
|
144
|
+
npm install -g @aeon-ai-pay/aigateway
|
|
16
145
|
|
|
17
|
-
#
|
|
18
|
-
|
|
146
|
+
# Verify
|
|
147
|
+
aigateway --version
|
|
19
148
|
```
|
|
20
149
|
|
|
21
|
-
|
|
150
|
+
### Step 2: Install the Agent Skill (optional, for repair)
|
|
22
151
|
|
|
23
|
-
|
|
152
|
+
When you run `npm install -g`, the `postinstall` script already installs the skill into all detected agents. If something was missed, install it manually:
|
|
24
153
|
|
|
154
|
+
```bash
|
|
155
|
+
npx skills add AEON-Project/aigateway -g -y # install into all detected agents
|
|
156
|
+
npx skills add AEON-Project/aigateway -a claude-code -a cursor -a codex -g -y # install into specific agents
|
|
25
157
|
```
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
158
|
+
|
|
159
|
+
Supported: Claude Code, Cursor, Codex, OpenClaw, Gemini CLI, GitHub Copilot, Windsurf, Roo Code, [39+ more](https://agentskills.io).
|
|
160
|
+
|
|
161
|
+
### Step 3: Initialize the wallet
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
aigateway wallet-init # generates the session key at ~/.aigateway/config.json and prints address + balance
|
|
30
165
|
```
|
|
31
166
|
|
|
32
|
-
Step
|
|
167
|
+
### Step 4: First-time top-up (one-time)
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
aigateway wallet-topup --amount 5
|
|
171
|
+
```
|
|
33
172
|
|
|
34
|
-
|
|
173
|
+
After scanning the WalletConnect QR code, the main wallet signs 2 transactions: transfer USDT + a small amount of BNB to the session key; the session key then broadcasts a one-time `ERC20.approve(facilitator, MaxUint256)`. After that, `sb invoke` is fully gasless EIP-712 signing end-to-end.
|
|
35
174
|
|
|
36
|
-
|
|
175
|
+
### Step 5: Invoke SkillBoss tools
|
|
37
176
|
|
|
38
|
-
|
|
177
|
+
```bash
|
|
178
|
+
aigateway sb tools --category image # browse available models
|
|
179
|
+
aigateway sb invoke --model <model_id> --inputs '{"prompt":"..."}' # invoke
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Images / videos / audio are auto-downloaded into `~/aigateway-{images,videos,audio}/`.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## CLI Command Reference
|
|
187
|
+
|
|
188
|
+
Every command accepts `--app-id <id>` (merchant ID, defaults to `TEST000001`) and emits a single JSON envelope line to stdout: `{ ok, command, version, data | error }`.
|
|
189
|
+
|
|
190
|
+
| Command | Description | Key flags |
|
|
39
191
|
| --- | --- | --- |
|
|
40
|
-
| `wallet-init` | Check / create the local session wallet (
|
|
41
|
-
| `wallet-topup` | WalletConnect USDT top-up (≥5 USDT, presets 5/10/20/50) +
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
| `
|
|
45
|
-
| `wallet` |
|
|
46
|
-
| `wallet-
|
|
47
|
-
| `
|
|
48
|
-
| `clean` | Remove skill + uninstall global package | — |
|
|
49
|
-
|
|
50
|
-
Global flags: `--legacy-output` (old JSON shape), `--verbose`, `--quiet`.
|
|
51
|
-
|
|
52
|
-
## Wallet & Funding Model
|
|
53
|
-
|
|
54
|
-
- **Session key**: A locally-generated private key stored at `~/.aigateway/config.json` (mode 0o600). It signs all paid calls and never leaves your machine.
|
|
55
|
-
- **Main wallet**: Your existing MetaMask / OKX / Trust wallet. Connects only via WalletConnect QR — its key never touches the CLI.
|
|
56
|
-
- **First-funding floor**: ≥ **1 USDT** (`LOW_BALANCE_THRESHOLD`) is enforced before any paid call.
|
|
57
|
-
- **Per-top-up minimum**: ≥ **5 USDT** (`MIN_TOPUP_USDT`). Presets: 5 / 10 / 20 / 50, or custom ≥ 5.
|
|
58
|
-
- **Approve once**: `wallet-topup` broadcasts a one-time `ERC20.approve(facilitator, MaxUint256)` (consumes ~0.0003 BNB). Subsequent paid calls reuse this allowance — no more on-chain transactions for the user.
|
|
59
|
-
- **Gasless paid calls**: Both `create-card` and `create-image` are pure EIP-712 signatures; the facilitator pays gas for the actual USDT transfer.
|
|
192
|
+
| `wallet-init` | Check / create the local session wallet (purely local — no QR, no on-chain action) | `--app-id <id>` |
|
|
193
|
+
| `wallet-topup` | WalletConnect USDT top-up (≥5 USDT, presets 5/10/20/50) + first-time approve | `--amount <usdt>`, `--private-key <key>` |
|
|
194
|
+
| **`sb invoke`** | **The only x402 paid invocation entry point** — invoke any SkillBoss model | `--model <id>` (required), `--inputs <json>` (required), `--output <dir>`, `--raw`, `--topup-amount <usdt>` |
|
|
195
|
+
| **`sb tools`** | Fetch the model catalog from the server in real time (no cache) | `--model <id>` / `--category <key>` / `--tier <price\|quality\|balanced>` |
|
|
196
|
+
| `wallet-balance` | Show the session wallet's USDT + BNB balance | `--private-key <key>` |
|
|
197
|
+
| `wallet-gas` | Transfer BNB from the main wallet to the session key via WalletConnect | `--amount <bnb>` (default `0.001`) |
|
|
198
|
+
| `wallet-withdraw` | Withdraw USDT + BNB from the session key back to the main wallet | `--amount <usdt>` (default all), `--to <address>` |
|
|
199
|
+
| `clean` | Uninstall the skill + global package and clear caches | — |
|
|
60
200
|
|
|
61
|
-
|
|
201
|
+
Global flags: `--legacy-output` (legacy JSON shape), `--verbose`, `--quiet`.
|
|
62
202
|
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
-
|
|
203
|
+
**Usage-based pricing constraints** (enforced by `sb invoke` client-side preflight):
|
|
204
|
+
|
|
205
|
+
- `video`: must include `duration_seconds` (billed per second)
|
|
206
|
+
- `stt`: must include `duration_minutes` (billed per minute)
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Wallet & Pricing Model
|
|
66
211
|
|
|
67
|
-
|
|
212
|
+
- **Session key**: a locally generated private key (`~/.aigateway/config.json`, mode 0o600). All paid calls are signed by this key, and the private key never leaves your machine.
|
|
213
|
+
- **Main wallet**: your existing MetaMask / OKX / Trust wallet — only connected via the WalletConnect QR code, the main wallet's private key never touches the CLI.
|
|
214
|
+
- **First-call balance threshold**: wallet balance must be ≥ **1 USDT** before invocation (`LOW_BALANCE_THRESHOLD`).
|
|
215
|
+
- **Minimum top-up per session**: ≥ **5 USDT** (`MIN_TOPUP_USDT`), presets 5 / 10 / 20 / 50.
|
|
216
|
+
- **One-time approve**: `wallet-topup` broadcasts a single `ERC20.approve(facilitator, MaxUint256)` (consumes ~0.0003 BNB); all subsequent paid calls reuse the allowance — no further on-chain tx needed.
|
|
217
|
+
- **Gasless payments**: `sb invoke` is purely EIP-712 signing end-to-end; the server pays the gas for the on-chain USDT transfer.
|
|
218
|
+
- **Dynamic pricing**: the server computes `priceUnit × inputs usage` in real time:
|
|
219
|
+
- Image: `per_image × num_outputs`
|
|
220
|
+
- Video: `per_second × duration_seconds`
|
|
221
|
+
- TTS: `per_1k_chars × len(text)/1000`
|
|
222
|
+
- Transcription: `per_minute × duration_minutes`
|
|
223
|
+
- Embedding: `per_million_tokens × len(input)/4/1M`
|
|
224
|
+
- Others: `per_request × 1`
|
|
68
225
|
|
|
69
|
-
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Developer Integration
|
|
70
229
|
|
|
71
230
|
**Reference**
|
|
72
|
-
- [docs/output-schema.md](docs/output-schema.md) —
|
|
73
|
-
- [docs/exit-codes.md](docs/exit-codes.md) —
|
|
74
|
-
- [docs/env-vars.md](docs/env-vars.md) — `AIGATEWAY_SERVICE_URL
|
|
75
|
-
- [docs/troubleshooting.md](docs/troubleshooting.md) —
|
|
231
|
+
- [docs/output-schema.md](docs/output-schema.md) — Full envelope schema for every command
|
|
232
|
+
- [docs/exit-codes.md](docs/exit-codes.md) — Exit code categories + `error.code` index
|
|
233
|
+
- [docs/env-vars.md](docs/env-vars.md) — `AIGATEWAY_SERVICE_URL` / `EVM_PRIVATE_KEY` / config fallback rules
|
|
234
|
+
- [docs/troubleshooting.md](docs/troubleshooting.md) — Common issues
|
|
76
235
|
|
|
77
236
|
**Recipes**
|
|
78
|
-
- [docs/recipes/integrate-in-agent.md](docs/recipes/integrate-in-agent.md) —
|
|
79
|
-
- [docs/recipes/merchant-integration.md](docs/recipes/merchant-integration.md) —
|
|
80
|
-
- [docs/recipes/error-recovery.md](docs/recipes/error-recovery.md) —
|
|
81
|
-
- [docs/recipes/cron-issue-cards.md](docs/recipes/cron-issue-cards.md) — scheduled paid calls
|
|
237
|
+
- [docs/recipes/integrate-in-agent.md](docs/recipes/integrate-in-agent.md) — Node.js / Python subprocess wrapping
|
|
238
|
+
- [docs/recipes/merchant-integration.md](docs/recipes/merchant-integration.md) — Merchant onboarding (self-custody vs. managed wallet)
|
|
239
|
+
- [docs/recipes/error-recovery.md](docs/recipes/error-recovery.md) — Recovery strategies by error code
|
|
82
240
|
|
|
83
|
-
**Agent / IDE
|
|
84
|
-
- [docs/ide-setup.md](docs/ide-setup.md) —
|
|
241
|
+
**Agent / IDE integration**
|
|
242
|
+
- [docs/ide-setup.md](docs/ide-setup.md) — Manual install templates for various IDEs
|
|
85
243
|
|
|
86
|
-
**
|
|
87
|
-
- [docs/release-process.md](docs/release-process.md) —
|
|
88
|
-
- [CHANGELOG.md](CHANGELOG.md) —
|
|
244
|
+
**Release**
|
|
245
|
+
- [docs/release-process.md](docs/release-process.md) — Version sync, release, auto-upgrade
|
|
246
|
+
- [CHANGELOG.md](CHANGELOG.md) — Release history
|
|
89
247
|
|
|
90
|
-
Minimal Node.js example
|
|
248
|
+
### Minimal Node.js example
|
|
91
249
|
|
|
92
250
|
```js
|
|
93
251
|
import { spawn } from "node:child_process";
|
|
94
252
|
|
|
95
253
|
const child = spawn("aigateway", [
|
|
96
|
-
"--quiet",
|
|
254
|
+
"--quiet",
|
|
255
|
+
"sb", "invoke",
|
|
256
|
+
"--model", "<model_id>",
|
|
257
|
+
"--inputs", JSON.stringify({ prompt: "a cyberpunk fox" }),
|
|
258
|
+
"--app-id", "MY_AGENT_001",
|
|
97
259
|
]);
|
|
98
260
|
let stdout = "";
|
|
99
261
|
child.stdout.on("data", (b) => { stdout += b; });
|
|
100
|
-
child.on("close", (
|
|
262
|
+
child.on("close", () => {
|
|
101
263
|
const env = JSON.parse(stdout.trim().split("\n").pop());
|
|
102
|
-
if (env.ok)
|
|
103
|
-
|
|
264
|
+
if (env.ok) {
|
|
265
|
+
console.log("Image saved:", env.data.downloaded[0].localPath);
|
|
266
|
+
console.log("Tx:", env.data.transaction);
|
|
267
|
+
} else {
|
|
268
|
+
console.error(`[${env.error.code}] ${env.error.message}`);
|
|
269
|
+
}
|
|
104
270
|
});
|
|
105
271
|
```
|
|
106
272
|
|
|
273
|
+
---
|
|
274
|
+
|
|
107
275
|
## Configuration
|
|
108
276
|
|
|
109
|
-
Config lives at `~/.aigateway/config.json` (file mode 600). The default service URL (`https://ai-api.aeon.xyz`)
|
|
277
|
+
Config lives at `~/.aigateway/config.json` (file mode 600). The CLI ships with a default service URL (`https://ai-api.aeon.xyz`); for testing or a custom backend, override via environment variables:
|
|
278
|
+
|
|
279
|
+
- `AIGATEWAY_SERVICE_URL` — base URL of the x402 service
|
|
280
|
+
- `EVM_PRIVATE_KEY` — override the saved session key (development use)
|
|
110
281
|
|
|
111
|
-
|
|
112
|
-
- `EVM_PRIVATE_KEY` — override the saved session key (developer use)
|
|
282
|
+
---
|
|
113
283
|
|
|
114
284
|
## License
|
|
115
285
|
|
package/bin/cli.mjs
CHANGED
|
@@ -128,6 +128,7 @@ sb
|
|
|
128
128
|
sb
|
|
129
129
|
.command("tools")
|
|
130
130
|
.description("Fetch and display the AI tool catalog (with optional filters)")
|
|
131
|
+
.option("--app-id <id>", "Merchant app ID", DEFAULT_APP_ID)
|
|
131
132
|
.option("--model <id>", "Return only this model (+effectiveSchema)")
|
|
132
133
|
.option("--category <key>", "Return only this category (image / video / tts / etc.)")
|
|
133
134
|
.option("--tier <tier>", "Filter models by tier (price | quality | balanced)")
|
package/docs/env-vars.md
CHANGED
|
@@ -4,9 +4,8 @@ All environment variables that affect the `aigateway` CLI. Resolution priority f
|
|
|
4
4
|
|
|
5
5
|
| Variable | Used by | Default | Purpose |
|
|
6
6
|
| --- | --- | --- | --- |
|
|
7
|
-
| `AIGATEWAY_SERVICE_URL` | All
|
|
7
|
+
| `AIGATEWAY_SERVICE_URL` | All commands that talk to the gateway (`sb invoke`, `sb tools`, `wallet-init`, `wallet-topup`, `wallet-balance`) | `https://ai-api.aeon.xyz` | Override the x402 service base URL. Useful for staging / local backends. |
|
|
8
8
|
| `EVM_PRIVATE_KEY` | All commands needing a session key | (read from config file) | Override the saved session key. Required when running in custodial / containerised mode where you don't want a config file on disk. **Treat as a secret.** |
|
|
9
|
-
| `AICARD_LEGACY_NOOP` | — | — | Reserved. Not currently used. |
|
|
10
9
|
|
|
11
10
|
## Config file
|
|
12
11
|
|
|
@@ -26,22 +25,18 @@ All environment variables that affect the `aigateway` CLI. Resolution priority f
|
|
|
26
25
|
- `privateKey` / `address` / `mode` — written by `wallet-init` when auto-generating a session key.
|
|
27
26
|
- `mainWallet` — auto-recorded after a successful `wallet-topup` so `wallet-withdraw` can default to that address.
|
|
28
27
|
|
|
29
|
-
##
|
|
28
|
+
## Priority example
|
|
30
29
|
|
|
31
30
|
```bash
|
|
32
|
-
#
|
|
33
|
-
AIGATEWAY_SERVICE_URL=https://
|
|
34
|
-
aigateway
|
|
35
|
-
|
|
36
|
-
# Only env set
|
|
37
|
-
AIGATEWAY_SERVICE_URL=https://staging.example.com \
|
|
38
|
-
aigateway create-card --amount 5
|
|
31
|
+
# Env var wins over config file
|
|
32
|
+
AIGATEWAY_SERVICE_URL=https://staging-x402.aeon.xyz \
|
|
33
|
+
aigateway sb invoke --model <id> --inputs '<json>'
|
|
39
34
|
|
|
40
35
|
# Nothing set → built-in default https://ai-api.aeon.xyz
|
|
41
|
-
aigateway
|
|
36
|
+
aigateway sb invoke --model <id> --inputs '<json>'
|
|
42
37
|
```
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
There is no `--service-url` CLI flag — use the env var or edit the config file directly.
|
|
45
40
|
|
|
46
41
|
## Production hardening
|
|
47
42
|
|
|
@@ -60,11 +55,14 @@ aigateway wallet-init
|
|
|
60
55
|
|
|
61
56
|
# Custodial server (key from Vault, no config file)
|
|
62
57
|
EVM_PRIVATE_KEY=$(vault kv get -field=key merchants/acme-prod) \
|
|
63
|
-
aigateway
|
|
58
|
+
aigateway sb invoke \
|
|
59
|
+
--model replicate/black-forest-labs/flux-schnell \
|
|
60
|
+
--inputs '{"prompt":"a cyberpunk fox"}' \
|
|
61
|
+
--app-id MERCHANT_ACME_001
|
|
64
62
|
|
|
65
63
|
# Staging
|
|
66
64
|
AIGATEWAY_SERVICE_URL=https://staging-x402.aeon.xyz \
|
|
67
|
-
aigateway
|
|
65
|
+
aigateway sb tools --category image --app-id YOUR_TEST_APPID
|
|
68
66
|
|
|
69
67
|
# Both
|
|
70
68
|
AIGATEWAY_SERVICE_URL=https://staging-x402.aeon.xyz \
|
package/docs/exit-codes.md
CHANGED
|
@@ -6,13 +6,13 @@ The `aigateway` CLI returns a stable exit code that maps to the category of outc
|
|
|
6
6
|
| ---: | -------- | ------- |
|
|
7
7
|
| `0` | Success | Command completed and produced an `ok: true` envelope. |
|
|
8
8
|
| `1` | User error | Validation, configuration, balance, or user-side rejection. Caller should fix input and retry. |
|
|
9
|
-
| `2` | Timeout | Polling, WalletConnect, signature, or on-chain wait exceeded its limit. The underlying operation may still complete asynchronously
|
|
9
|
+
| `2` | Timeout | Polling, WalletConnect, signature, or on-chain wait exceeded its limit. The underlying operation may still complete asynchronously. |
|
|
10
10
|
| `3` | Service / network | Upstream service unavailable, network error, on-chain revert. Generally retryable after backoff. |
|
|
11
11
|
| `4` | Internal | Unexpected internal error in the CLI. Please file an issue if reproducible. |
|
|
12
12
|
|
|
13
13
|
## Error Code Reference
|
|
14
14
|
|
|
15
|
-
The full set of `error.code` values
|
|
15
|
+
The full set of `error.code` values is defined in [`src/error-codes.mjs`](../src/error-codes.mjs); the table below mirrors that file.
|
|
16
16
|
|
|
17
17
|
### Exit 1 — User Error
|
|
18
18
|
|
|
@@ -20,17 +20,25 @@ The full set of `error.code` values, grouped by exit code, is defined in [`src/e
|
|
|
20
20
|
| ---- | ---- |
|
|
21
21
|
| `WALLET_NOT_CONFIGURED` | No local wallet. Run `aigateway wallet-init`. |
|
|
22
22
|
| `SERVICE_URL_MISSING` | Service URL not configured. |
|
|
23
|
-
| `AMOUNT_INVALID` | Amount could not be parsed. |
|
|
24
|
-
| `
|
|
25
|
-
| `AMOUNT_EXCEEDS_BALANCE` | `withdraw --amount` exceeds available USDT. |
|
|
23
|
+
| `AMOUNT_INVALID` | Amount could not be parsed (e.g. `wallet-topup --amount`, `--topup-amount`). |
|
|
24
|
+
| `AMOUNT_EXCEEDS_BALANCE` | `wallet-withdraw --amount` exceeds available USDT. |
|
|
26
25
|
| `INSUFFICIENT_USDT` | USDT balance still insufficient after funding. |
|
|
27
26
|
| `INSUFFICIENT_BNB` | No BNB for approve / withdraw gas. |
|
|
28
|
-
| `NO_FUNDS` | Session wallet has zero USDT and zero BNB. |
|
|
27
|
+
| `NO_FUNDS` | Session wallet has zero USDT and zero BNB (withdraw context). |
|
|
29
28
|
| `NO_MAIN_WALLET` | `wallet-withdraw` invoked without `--to` and no `mainWallet` in config. |
|
|
30
|
-
| `
|
|
31
|
-
| `
|
|
32
|
-
| `
|
|
29
|
+
| `MISSING_MODEL` | `sb invoke` invoked without `--model`. |
|
|
30
|
+
| `MISSING_INPUTS` | `sb invoke --inputs` is missing, or required fields are absent. `error.errors[]` lists which. |
|
|
31
|
+
| `INVALID_INPUTS` | Inputs failed schema validation. `error.errors[].kind ∈ {enum, type, range}`. |
|
|
32
|
+
| `INVALID_INPUTS_JSON` | `--inputs` could not be parsed as JSON. |
|
|
33
|
+
| `INPUTS_FILE_NOT_FOUND` | `--inputs @path` file does not exist. |
|
|
34
|
+
| `INVALID_MODEL_ID` | Catalog or server rejected the model id. |
|
|
35
|
+
| `CATEGORY_NOT_FOUND` | `sb tools --category` argument not in the live catalog. |
|
|
36
|
+
| `MODEL_PRICING_NOT_CONFIGURED` | Catalog lists the model but the gateway has no price entry yet. |
|
|
37
|
+
| `INVALID_BODY` | Server rejected the request body shape. |
|
|
38
|
+
| `TOPUP_REQUIRED` | Non-TTY context, USDT below the per-call minimum. Choose from `error.presets` (filtered to ≥ `error.minTopup`) and rerun the failing command with `--topup-amount <n>` (or `wallet-topup --amount <n>`). |
|
|
39
|
+
| `TOPUP_AMOUNT_TOO_SMALL` | `--topup-amount` (or `topup --amount`) below `error.minTopup`. |
|
|
33
40
|
| `PAYMENT_REJECTED` | User rejected the transaction in their wallet. |
|
|
41
|
+
| `WALLET_ERROR` | Generic wallet operation failure (treated as user-resolvable). |
|
|
34
42
|
|
|
35
43
|
### Exit 2 — Timeout
|
|
36
44
|
|
|
@@ -38,9 +46,8 @@ The full set of `error.code` values, grouped by exit code, is defined in [`src/e
|
|
|
38
46
|
| ---- | ---- |
|
|
39
47
|
| `PAYMENT_TIMEOUT` | WalletConnect / signature request timed out (5 minutes). |
|
|
40
48
|
| `WC_SESSION_EXPIRED` | WalletConnect session dropped mid-flow. |
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
43
|
-
| `UPDATE_APPLIED` | The CLI just upgraded itself synchronously to a newer version. The previous command was not executed — the caller (or the agent) must rerun it on the new version. Envelope carries `error.from` / `error.to` showing the version transition. |
|
|
49
|
+
| `TX_TIMEOUT` | On-chain receipt wait exceeded its limit. |
|
|
50
|
+
| `UPDATE_APPLIED` | The CLI just upgraded itself synchronously to a newer version. The previous command was **not executed** — the caller (or the agent) must rerun it on the new version. Envelope carries `error.from` / `error.to` showing the version transition. |
|
|
44
51
|
|
|
45
52
|
### Exit 3 — Service / Network
|
|
46
53
|
|
|
@@ -48,13 +55,15 @@ The full set of `error.code` values, grouped by exit code, is defined in [`src/e
|
|
|
48
55
|
| ---- | ---- |
|
|
49
56
|
| `SERVICE_UNAVAILABLE` | Generic upstream / network failure. |
|
|
50
57
|
| `PAYMENT_FETCH_FAILED` | First 402 request to the service failed. |
|
|
58
|
+
| `CATALOG_FETCH_FAILED` | `sb tools` could not fetch the catalog from the server. |
|
|
51
59
|
| `BALANCE_CHECK_FAILED` | RPC query to BSC failed. |
|
|
52
60
|
| `ALLOWANCE_CHECK_FAILED` | RPC `allowance()` query failed. |
|
|
53
61
|
| `TX_REVERTED` | On-chain transaction reverted. |
|
|
54
62
|
| `WITHDRAW_FAILED` | Withdraw transaction failed (revert / RPC). |
|
|
55
|
-
| `APPROVE_FAILED` | `wallet-
|
|
63
|
+
| `APPROVE_FAILED` | `wallet-topup` could not broadcast or confirm the facilitator `approve()` tx. |
|
|
56
64
|
| `FUNDING_FAILED` | WalletConnect funding flow failed (non-timeout / non-reject path). |
|
|
57
|
-
| `IMAGE_DOWNLOAD_FAILED` | Generated image URL returned a non-200 / timed out. |
|
|
65
|
+
| `IMAGE_DOWNLOAD_FAILED` | Generated image URL returned a non-200 / timed out. (Legacy alias; `sb invoke` now also emits `DOWNLOAD_FAILED` for non-image artifacts.) |
|
|
66
|
+
| `DOWNLOAD_FAILED` | `sb invoke` could not save a binary artifact (image / video / audio) to disk. The upstream URL is still available in `data.downloaded[].url`. |
|
|
58
67
|
| `INVALID_PAYMENT_AMOUNT` | Service returned a 402 with `amount === 0`. |
|
|
59
68
|
| `PAYMENT_FAILED` | Service rejected the signed payment request. |
|
|
60
69
|
|
|
@@ -63,4 +72,5 @@ The full set of `error.code` values, grouped by exit code, is defined in [`src/e
|
|
|
63
72
|
| Code | When |
|
|
64
73
|
| ---- | ---- |
|
|
65
74
|
| `INTERNAL_ERROR` | Unexpected error inside the CLI. |
|
|
66
|
-
|
|
75
|
+
|
|
76
|
+
> Note: `WALLET_ERROR` is defined alongside the timeout block in `error-codes.mjs` but its exit code is `1` (user-resolvable), so it appears under Exit 1 above.
|
package/docs/ide-setup.md
CHANGED
|
@@ -55,6 +55,6 @@ For Claude Code, OpenClaw, Gemini CLI, GitHub Copilot, and 30+ others, the [skil
|
|
|
55
55
|
|
|
56
56
|
After installation, in your IDE chat say:
|
|
57
57
|
|
|
58
|
-
>
|
|
58
|
+
> Generate me an image of a cyberpunk fox.
|
|
59
59
|
|
|
60
|
-
The agent should propose running `aigateway wallet-init` (one-time, auto-creates a wallet)
|
|
60
|
+
The agent should propose running `aigateway wallet-init` (one-time, auto-creates a wallet), then `aigateway sb tools --category image` to pick a model, then `aigateway sb invoke --model <id> --inputs '{"prompt":"cyberpunk fox"}'`. If it doesn't, the rule file isn't being picked up — check that the file path matches what your IDE expects and that the IDE has been restarted.
|