xapi-to 0.1.20 → 0.1.22
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 +164 -1
- package/dist/{chunk-TYY6JR6O.js → chunk-2YRWNREY.js} +75 -23
- package/dist/index.js +1245 -55
- package/dist/openai-sandbox-client.js +1 -1
- package/examples/openai-gpt-live-text.mjs +128 -0
- package/examples/provider/openapi.json +34 -0
- package/package.json +1 -1
- package/skills/xapi/SKILL.md +43 -195
- package/skills/xapi/guides/binance_web3.md +210 -0
- package/skills/xapi/guides/blockpi.md +112 -0
- package/skills/xapi/guides/domains.md +189 -0
- package/skills/xapi/guides/provider.md +228 -0
- package/skills/xapi/guides/sandbox.md +100 -46
- package/skills/xapi/guides/ws_gateway.md +64 -4
- package/src/client.ts +62 -7
- package/src/sandbox-client.ts +36 -16
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Minimal GPT Live control-path example through xAPI. It uses managed Responses
|
|
4
|
+
// delegation and text input so the session lifecycle is visible without audio
|
|
5
|
+
// capture. Install the transport in your application first: npm install ws
|
|
6
|
+
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
|
|
9
|
+
const apiKey = process.env.XAPI_KEY || process.env.XAPI_API_KEY;
|
|
10
|
+
if (!apiKey) {
|
|
11
|
+
throw new Error('Set XAPI_KEY or XAPI_API_KEY in the process environment');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let WebSocket;
|
|
15
|
+
try {
|
|
16
|
+
({ default: WebSocket } = await import('ws'));
|
|
17
|
+
} catch {
|
|
18
|
+
throw new Error('This example requires the ws package: npm install ws');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const prompt = process.argv.slice(2).join(' ').trim() || 'Say hello in one short sentence.';
|
|
22
|
+
const prefix = randomUUID();
|
|
23
|
+
const url = 'wss://openai-live.p.xapi.to/v1/live/sessions';
|
|
24
|
+
const socket = new WebSocket(url, {
|
|
25
|
+
headers: { 'XAPI-Key': apiKey },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const timeout = setTimeout(() => {
|
|
29
|
+
console.error('GPT Live example timed out');
|
|
30
|
+
socket.terminate();
|
|
31
|
+
process.exitCode = 1;
|
|
32
|
+
}, 60_000);
|
|
33
|
+
|
|
34
|
+
let closeRequested = false;
|
|
35
|
+
let sessionClosedConfirmed = false;
|
|
36
|
+
|
|
37
|
+
function send(event) {
|
|
38
|
+
socket.send(JSON.stringify(event));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function finish(error) {
|
|
42
|
+
clearTimeout(timeout);
|
|
43
|
+
if (error) {
|
|
44
|
+
console.error(error.message || error);
|
|
45
|
+
process.exitCode = 1;
|
|
46
|
+
}
|
|
47
|
+
if (socket.readyState === WebSocket.OPEN) socket.close();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
socket.on('open', () => {
|
|
51
|
+
send({
|
|
52
|
+
type: 'session.start',
|
|
53
|
+
event_id: `${prefix}-start`,
|
|
54
|
+
session: {
|
|
55
|
+
model: 'gpt-live-1',
|
|
56
|
+
instructions: 'Respond concisely.',
|
|
57
|
+
delegation: { type: 'responses' },
|
|
58
|
+
store: false,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
socket.on('message', (raw, isBinary) => {
|
|
64
|
+
if (isBinary) return finish(new Error('Unexpected binary GPT Live frame'));
|
|
65
|
+
|
|
66
|
+
let event;
|
|
67
|
+
try {
|
|
68
|
+
event = JSON.parse(raw.toString());
|
|
69
|
+
} catch {
|
|
70
|
+
return finish(new Error('GPT Live returned invalid JSON'));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (event.type === 'session.started') {
|
|
74
|
+
send({
|
|
75
|
+
type: 'response.item.create',
|
|
76
|
+
event_id: `${prefix}-input`,
|
|
77
|
+
item: {
|
|
78
|
+
type: 'message',
|
|
79
|
+
role: 'user',
|
|
80
|
+
content: [{ type: 'input_text', text: prompt }],
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
send({ type: 'response.create', event_id: `${prefix}-response` });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (event.type === 'response.event') {
|
|
88
|
+
const nested = event.event || {};
|
|
89
|
+
if (nested.type === 'response.output_text.delta' && typeof nested.delta === 'string') {
|
|
90
|
+
process.stdout.write(nested.delta);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (nested.type === 'response.refusal.delta' && typeof nested.delta === 'string') {
|
|
94
|
+
process.stdout.write(nested.delta);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (nested.type === 'response.completed') {
|
|
98
|
+
process.stdout.write('\n');
|
|
99
|
+
closeRequested = true;
|
|
100
|
+
send({ type: 'session.close', event_id: `${prefix}-close` });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (nested.type === 'response.failed' || nested.type === 'response.incomplete') {
|
|
104
|
+
return finish(new Error(`Delegated response ended with ${nested.type}`));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (event.type === 'error') {
|
|
109
|
+
return finish(new Error(event.error?.message || 'GPT Live session error'));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (event.type === 'session.closed') {
|
|
113
|
+
if (!closeRequested || event.reason !== 'close_requested') {
|
|
114
|
+
return finish(new Error(`Unexpected session close: ${event.reason || 'unknown'}`));
|
|
115
|
+
}
|
|
116
|
+
sessionClosedConfirmed = true;
|
|
117
|
+
finish();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
socket.on('error', (error) => finish(new Error(`WebSocket error: ${error.message}`)));
|
|
122
|
+
socket.on('close', () => {
|
|
123
|
+
clearTimeout(timeout);
|
|
124
|
+
if (!sessionClosedConfirmed && process.exitCode !== 1) {
|
|
125
|
+
console.error('WebSocket closed before session.closed confirmation');
|
|
126
|
+
process.exitCode = 1;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.3",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Example Provider API",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "Replace this example with your own upstream API contract.",
|
|
7
|
+
"x-xapi-category": "Public-Utils",
|
|
8
|
+
"x-xapi-host": "example-provider-api"
|
|
9
|
+
},
|
|
10
|
+
"servers": [{ "url": "https://upstream.example.com" }],
|
|
11
|
+
"paths": {
|
|
12
|
+
"/status": {
|
|
13
|
+
"get": {
|
|
14
|
+
"summary": "Get status",
|
|
15
|
+
"description": "Return the upstream service status.",
|
|
16
|
+
"x-xapi-billing": { "type": "PER_CALL", "costPerCall": 0.001 },
|
|
17
|
+
"responses": {
|
|
18
|
+
"200": {
|
|
19
|
+
"description": "Service status",
|
|
20
|
+
"content": {
|
|
21
|
+
"application/json": {
|
|
22
|
+
"schema": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"properties": { "status": { "type": "string" } }
|
|
25
|
+
},
|
|
26
|
+
"example": { "status": "ok" }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/package.json
CHANGED
package/skills/xapi/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: xapi
|
|
3
|
-
description: Access real-time external data and managed cloud sandboxes via the xapi CLI — Twitter/X, social platforms, crypto, web/news search, AI generation, SMS verification, and auditable ephemeral compute. Configure the xAPI AI or WebSocket Gateways, or use sandbox run for automatic quote/create/execute/cleanup. Use when the user mentions xapi, external services, or sandbox compute.
|
|
3
|
+
description: Access real-time external data and managed cloud sandboxes via the xapi CLI — Twitter/X, social platforms, domain purchase and DNS, normalized crypto, BlockPI RPC, Binance Web3 API, web/news search, AI generation, SMS verification, and auditable ephemeral compute. Configure the xAPI AI or WebSocket Gateways, or use sandbox run for automatic quote/create/execute/cleanup. Use when the user mentions xapi, external services, or sandbox compute.
|
|
4
4
|
metadata: {"openclaw":{"emoji":"x","requires":{"anyBins":["npx"]},"primaryEnv":"XAPI_KEY"}}
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -57,7 +57,7 @@ Use these flags where the command documents them:
|
|
|
57
57
|
|
|
58
58
|
xapi offers two types of APIs under a unified interface:
|
|
59
59
|
|
|
60
|
-
1. **Capabilities** (`--source capability`) — Built-in APIs with known IDs (Twitter, crypto, AI, web search, news)
|
|
60
|
+
1. **Capabilities** (`--source capability`) — Built-in APIs with known IDs (Twitter, domains/DNS, crypto, AI, web search, news)
|
|
61
61
|
2. **Third-party APIs** (`--source api`) — Proxied services, discovered via `list`, `search`, or `services`
|
|
62
62
|
|
|
63
63
|
Both types use the same discovery and call workflow. Use `--source capability` or `--source api` on commands that expose source filtering.
|
|
@@ -155,211 +155,60 @@ npx xapi-to call x-official.2_tweets --method POST --input '{"body":{"text":"Hel
|
|
|
155
155
|
|
|
156
156
|
Always use `--input` with JSON for passing parameters.
|
|
157
157
|
|
|
158
|
-
###
|
|
158
|
+
### Capability routing
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
npx xapi-to call twitter.user_tweets --input '{"user_id":"44196397"}'
|
|
166
|
-
|
|
167
|
-
# Get user's tweets and replies (timeline includes replies)
|
|
168
|
-
npx xapi-to call twitter.user_tweets_and_replies --input '{"user_id":"44196397"}'
|
|
169
|
-
|
|
170
|
-
# Get tweet details and replies; video media include the highest-bitrate MP4 in video_url
|
|
171
|
-
npx xapi-to call twitter.tweet_detail --input '{"tweet_id":"1234567890"}'
|
|
172
|
-
|
|
173
|
-
# Get user's media posts
|
|
174
|
-
npx xapi-to call twitter.user_media --input '{"user_id":"44196397"}'
|
|
175
|
-
|
|
176
|
-
# Get followers / following
|
|
177
|
-
npx xapi-to call twitter.followers --input '{"user_id":"44196397"}'
|
|
178
|
-
npx xapi-to call twitter.following --input '{"user_id":"44196397"}'
|
|
179
|
-
|
|
180
|
-
# Search tweets
|
|
181
|
-
npx xapi-to call twitter.search --input '{"raw_query":"bitcoin","count":20}'
|
|
182
|
-
|
|
183
|
-
# Advanced search filters (provider x)
|
|
184
|
-
npx xapi-to call twitter.search --input '{"raw_query":"AI","from":"OpenAI","since":"2026-08-01","min_likes":100,"count":20}'
|
|
185
|
-
|
|
186
|
-
# Get retweeters of a tweet
|
|
187
|
-
npx xapi-to call twitter.retweeters --input '{"tweet_id":"1234567890"}'
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
Note: Twitter user_id is a numeric ID. To get it, first call `twitter.user_by_screen_name` with the username, then extract `rest_id` from the response.
|
|
191
|
-
|
|
192
|
-
Note: All `twitter.*` capabilities accept an optional `provider` — `"x"` (fapi.uk, default) or `"twitter"` (legacy upstream). Responses are normalized to an identical structure across providers, so you normally don't need to set it; pass `"provider":"twitter"` only to force the legacy upstream.
|
|
193
|
-
|
|
194
|
-
Note: Timeline, reply, media, follower/following, retweeter, and search responses expose pagination cursors. Pass the previous response's bottom cursor back as `cursor`; see `guides/twitter.md` for the exact response field used by each endpoint.
|
|
195
|
-
|
|
196
|
-
Note: For long-form **X Articles**, `twitter.tweet_detail` automatically returns the full article in `tweet.article`, including `text`, `markdown`, cover image, links, and timestamps. No raw GraphQL call is needed.
|
|
197
|
-
|
|
198
|
-
Note: To download tweet videos, use the bundled `scripts/download_tweet_videos.sh` workflow documented in `guides/twitter.md`. It consumes `twitter.tweet_detail`'s normalized `media[].video_url`, handles multiple and nested quoted/retweeted videos, preserves automatic `x` → `twitter` failover, validates MP4 content, and publishes downloads atomically. Do not treat `media[].url` or `preview_url` as video files; they are preview images.
|
|
199
|
-
|
|
200
|
-
### Crypto (17 registered APIs; 16 recommended)
|
|
201
|
-
|
|
202
|
-
Two addressing models:
|
|
203
|
-
|
|
204
|
-
- **On-chain by contract address** (`crypto.token.*`, `crypto.wallet.*`, `crypto.tx.*`, `crypto.dex.*`) — the `token`/`address`/`pair` field is a **contract/wallet address**, plus a `chain`. Supported chains: `eth`, `bsc` (default), `solana`, `base`, `arbitrum`, `polygon`, `optimism`, `avalanche`.
|
|
205
|
-
- **By symbol** (`crypto.cex.*`) — for coins without a contract address (e.g. "how much is BTC?"), use the CEX endpoints with a `symbol`.
|
|
206
|
-
|
|
207
|
-
```bash
|
|
208
|
-
# --- Token by contract address ---
|
|
209
|
-
|
|
210
|
-
# Price + 24h market data (aggregates multiple providers with fallback)
|
|
211
|
-
npx xapi-to call crypto.token.price --input '{"token":"0x55d398326f99059ff775485246999027b3197955","chain":"bsc"}'
|
|
212
|
-
|
|
213
|
-
# Full overview: metadata + price + market in one call (preferred over metadata)
|
|
214
|
-
npx xapi-to call crypto.token.overview --input '{"token":"0x55d398326f99059ff775485246999027b3197955","chain":"bsc"}'
|
|
215
|
-
|
|
216
|
-
# OHLCV candles (interval: 1m/5m/1h/1d…, default 1d)
|
|
217
|
-
npx xapi-to call crypto.token.ohlcv --input '{"token":"0x...","chain":"bsc","interval":"1h","limit":100}'
|
|
218
|
-
|
|
219
|
-
# Top holders / top traders / security (honeypot, tax, etc.)
|
|
220
|
-
npx xapi-to call crypto.token.holders --input '{"token":"0x...","chain":"bsc"}'
|
|
221
|
-
npx xapi-to call crypto.token.holders --input '{"token":"0x...","chain":"bsc","cursor":"<next_cursor>"}'
|
|
222
|
-
npx xapi-to call crypto.token.top_traders --input '{"token":"0x...","chain":"bsc"}'
|
|
223
|
-
npx xapi-to call crypto.token.security --input '{"token":"0x...","chain":"bsc"}'
|
|
224
|
-
|
|
225
|
-
# Trending tokens on a chain
|
|
226
|
-
npx xapi-to call crypto.token.trending --input '{"chain":"bsc","limit":20}'
|
|
227
|
-
|
|
228
|
-
# Search tokens by name / symbol / address
|
|
229
|
-
npx xapi-to call crypto.token.search --input '{"query":"PEPE"}'
|
|
230
|
-
|
|
231
|
-
# --- Wallet / transaction / DEX pair ---
|
|
232
|
-
npx xapi-to call crypto.wallet.balance --input '{"address":"0x...","chain":"bsc"}'
|
|
233
|
-
npx xapi-to call crypto.wallet.pnl --input '{"address":"0x...","chain":"bsc"}'
|
|
234
|
-
npx xapi-to call crypto.wallet.history --input '{"address":"0x...","chain":"bsc","limit":50}'
|
|
235
|
-
npx xapi-to call crypto.tx.detail --input '{"txHash":"0x...","chain":"bsc"}'
|
|
236
|
-
npx xapi-to call crypto.dex.pair --input '{"pair":"0x...","chain":"bsc"}'
|
|
237
|
-
|
|
238
|
-
# --- CEX by symbol (no contract address needed) ---
|
|
239
|
-
|
|
240
|
-
# Spot price of a coin by symbol
|
|
241
|
-
npx xapi-to call crypto.cex.price --input '{"symbol":"BTC"}'
|
|
242
|
-
|
|
243
|
-
# CEX OHLCV candles
|
|
244
|
-
npx xapi-to call crypto.cex.ohlcv --input '{"symbol":"BTC","interval":"1d","limit":100}'
|
|
245
|
-
|
|
246
|
-
# --- News ---
|
|
247
|
-
npx xapi-to call crypto.news --input '{"symbol":"BTC","limit":20}'
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
Note: `crypto.token.metadata` is **deprecated** — use `crypto.token.overview` instead (it returns metadata + price + market in one call).
|
|
251
|
-
Note: All `crypto.token.*`/`crypto.wallet.*`/etc. accept an optional `provider` to pin a specific upstream and disable automatic fallback.
|
|
252
|
-
Note: `crypto.token.holders`, `crypto.wallet.balance`, and `crypto.wallet.history` return an opaque `next_cursor` when another page is available. Pass it back unchanged as `cursor`; it pins pagination to the provider that issued it.
|
|
160
|
+
- Twitter/X reads and writes → `guides/twitter.md`; use the specialized social guide when applicable.
|
|
161
|
+
- Domain search, purchase, and DNS management → `guides/domains.md` before any purchase or write.
|
|
162
|
+
- Normalized token, wallet, DEX, CEX, and crypto-news data → `guides/crypto.md`.
|
|
163
|
+
- General/news/image/video/scholar/maps/places/shopping search → `guides/google_search.md`.
|
|
164
|
+
- AI text, embeddings, image/video/audio generation, and transcription → `guides/ai.md`.
|
|
253
165
|
|
|
254
|
-
|
|
166
|
+
Common read-only examples:
|
|
255
167
|
|
|
256
168
|
```bash
|
|
257
|
-
|
|
169
|
+
npx xapi-to call twitter.user_by_screen_name --input '{"screen_name":"OpenAI"}'
|
|
258
170
|
npx xapi-to call web.search --input '{"q":"latest AI news"}'
|
|
259
|
-
|
|
260
|
-
# Realtime web search with time filter
|
|
261
|
-
npx xapi-to call web.search.realtime --input '{"q":"breaking news","timeRange":"day"}'
|
|
262
|
-
|
|
263
|
-
# News search
|
|
264
|
-
npx xapi-to call web.search.news --input '{"q":"crypto regulation"}'
|
|
265
|
-
|
|
266
|
-
# Image search
|
|
267
|
-
npx xapi-to call web.search.image --input '{"q":"aurora borealis"}'
|
|
268
|
-
|
|
269
|
-
# Video search
|
|
270
|
-
npx xapi-to call web.search.video --input '{"q":"machine learning tutorial"}'
|
|
271
|
-
|
|
272
|
-
# Academic / scholar search
|
|
273
|
-
npx xapi-to call web.search.scholar --input '{"q":"transformer architecture"}'
|
|
274
|
-
|
|
275
|
-
# Maps search
|
|
276
|
-
npx xapi-to call web.search.maps --input '{"q":"coffee shop near Times Square"}'
|
|
277
|
-
|
|
278
|
-
# Places search (businesses with details)
|
|
279
|
-
npx xapi-to call web.search.places --input '{"q":"best ramen in Tokyo"}'
|
|
280
|
-
|
|
281
|
-
# Shopping search
|
|
282
|
-
npx xapi-to call web.search.shopping --input '{"q":"mechanical keyboard"}'
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
### AI Text Processing (6 APIs)
|
|
286
|
-
|
|
287
|
-
```bash
|
|
288
|
-
# Fast chat completion
|
|
289
|
-
npx xapi-to call ai.text.chat.fast --input '{"messages":[{"role":"user","content":"Explain quantum computing in one sentence"}]}'
|
|
290
|
-
|
|
291
|
-
# Reasoning chat (more thorough)
|
|
292
|
-
npx xapi-to call ai.text.chat.reasoning --input '{"messages":[{"role":"user","content":"Analyze the pros and cons of microservices"}]}'
|
|
293
|
-
|
|
294
|
-
# Auto chat — pass a model explicitly, gateway auto-routes to the best upstream with fallback
|
|
295
|
-
npx xapi-to call ai.text.chat.auto --input '{"model":"deepseek-v4-pro","messages":[{"role":"user","content":"Hello"}]}'
|
|
296
|
-
|
|
297
|
-
# Summarize text
|
|
298
|
-
npx xapi-to call ai.text.summarize --input '{"text":"<long text here>"}'
|
|
299
|
-
|
|
300
|
-
# Rewrite text
|
|
301
|
-
npx xapi-to call ai.text.rewrite --input '{"text":"<text>","mode":"formalize"}'
|
|
302
|
-
|
|
303
|
-
# Generate embeddings
|
|
304
|
-
npx xapi-to call ai.embedding.generate --input '{"input":"hello world"}'
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
### AI Image & Video Generation (2 APIs — asynchronous)
|
|
308
|
-
|
|
309
|
-
```bash
|
|
310
|
-
# Submit image generation (returns an async task)
|
|
311
|
-
npx xapi-to call ai.image.generate --input '{"prompt":"A serene mountain landscape at sunset, digital art","model":"gpt-image-2"}'
|
|
312
|
-
|
|
313
|
-
# Submit video generation through OpenRouter (+ optional reference image)
|
|
314
|
-
npx xapi-to call ai.video.generate --input '{"prompt":"A cat playing piano in a jazz bar, cinematic"}'
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
Both capabilities return `{ "task_id": "...", "status": "pending", "poll_url": "..." }`. Wait for the result with `xapi-to task wait` (see below). Video generation uses provider `openrouter` and defaults to model `bytedance/seedance-2.0-fast`.
|
|
318
|
-
|
|
319
|
-
### AI Speech Generation & Transcription (2 APIs)
|
|
320
|
-
|
|
321
|
-
```bash
|
|
322
|
-
# Text to speech (synchronous; returns a base64-encoded binary envelope)
|
|
323
|
-
npx xapi-to call ai.audio.generate --input '{"text":"Hello world","model":"hexgrad/kokoro-82m","voice":"af_bella","format":"mp3"}'
|
|
324
|
-
|
|
325
|
-
# Speech to text (audio.data is raw base64 without a data URI prefix)
|
|
326
|
-
npx xapi-to call ai.audio.transcribe --input '{"audio":{"data":"<base64-audio>","format":"wav"},"model":"openai/whisper-large-v3"}'
|
|
171
|
+
npx xapi-to call crypto.cex.price --input '{"symbol":"BTC"}'
|
|
327
172
|
```
|
|
328
173
|
|
|
329
|
-
###
|
|
330
|
-
|
|
331
|
-
Use CLI capabilities for one-off agent calls. Use the public AI Gateway when configuring Claude Code, Anthropic/OpenAI SDKs, or applications that expect standard AI API protocols:
|
|
332
|
-
|
|
333
|
-
- Anthropic base URL: `https://ai.xapi.to/<strategy>`
|
|
334
|
-
- OpenAI base URL: `https://ai.xapi.to/<strategy>/v1`
|
|
335
|
-
- Strategies: `default`, `cost`, `speed`, `quality`
|
|
336
|
-
- Authentication: use the xAPI key as `x-api-key`, `Authorization: Bearer`, or `XAPI-Key`
|
|
174
|
+
### Crypto and Web3 selection
|
|
337
175
|
|
|
338
|
-
|
|
176
|
+
Use built-in `crypto.*` for normalized multi-provider market, token, wallet,
|
|
177
|
+
DEX, CEX, and news data. Use a specialized service instead when the user asks
|
|
178
|
+
for its provider-native behavior:
|
|
339
179
|
|
|
340
|
-
|
|
180
|
+
- BlockPI network RPC or an arbitrary EVM JSON-RPC method → `guides/blockpi.md`.
|
|
181
|
+
- Binance-native chain IDs, address analytics, RWA, aggregation, transaction,
|
|
182
|
+
wallet, or DeFi data → `guides/binance_web3.md`.
|
|
341
183
|
|
|
342
|
-
|
|
184
|
+
Do not redirect an explicit BlockPI or Binance Web3 request to `crypto.*` merely
|
|
185
|
+
because both are in the Crypto category.
|
|
343
186
|
|
|
344
|
-
|
|
345
|
-
- Current paths include `/v1/realtime`, `/v1/asr`, `/v1/tts`, `/v1/ast`, and `/v1/podcast`
|
|
346
|
-
- Service-specific form: `wss://<service-slug>.p.xapi.to/<endpoint-path>`
|
|
347
|
-
- Server authentication: `XAPI-Key`, `Authorization: Bearer`, or `x-api-key`
|
|
187
|
+
### Search selection
|
|
348
188
|
|
|
349
|
-
|
|
189
|
+
Use normalized `web.search.*` capabilities for ordinary web, realtime, news,
|
|
190
|
+
image, video, scholar, maps, places, or shopping results; read
|
|
191
|
+
`guides/google_search.md`. Use direct `serper.*` actions only for provider-native
|
|
192
|
+
fields, mini-batches, Lens, Reviews, or other Serper-specific behavior; read
|
|
193
|
+
`guides/serper.md`.
|
|
350
194
|
|
|
351
|
-
###
|
|
195
|
+
### AI, async tasks, and gateways
|
|
352
196
|
|
|
353
|
-
|
|
197
|
+
Read `guides/ai.md` for text, embeddings, synchronous/SSE calls, speech,
|
|
198
|
+
transcription, and asynchronous image/video generation. Use `task wait` for an
|
|
199
|
+
async capability's returned task ID:
|
|
354
200
|
|
|
355
201
|
```bash
|
|
202
|
+
npx xapi-to call ai.text.chat.fast \
|
|
203
|
+
--input '{"messages":[{"role":"user","content":"Hello"}]}'
|
|
356
204
|
npx xapi-to task wait <task_id> --interval 2s --timeout 10m
|
|
357
|
-
|
|
358
|
-
# Poll exactly once when the caller manages scheduling itself
|
|
359
|
-
npx xapi-to task poll <task_id>
|
|
360
205
|
```
|
|
361
206
|
|
|
362
|
-
|
|
207
|
+
For application integrations, read `guides/ai_gateway.md` before configuring an
|
|
208
|
+
Anthropic/OpenAI-compatible client. Read `guides/ws_gateway.md` before opening a
|
|
209
|
+
persistent GPT Live, Realtime, ASR, TTS, interpretation, or podcast WebSocket
|
|
210
|
+
session. GPT Live uses `/v1/live/sessions` and is not the Realtime protocol at
|
|
211
|
+
`/v1/realtime`.
|
|
363
212
|
|
|
364
213
|
## Input Format
|
|
365
214
|
|
|
@@ -452,10 +301,11 @@ Beyond built-in capabilities, xapi proxies **dozens** of third-party API service
|
|
|
452
301
|
- **5SIM SMS** (`5sim-sms`) — SMS verification (virtual numbers, activation codes)
|
|
453
302
|
- **Serper API** (`serper`) — 12 provider-native Google Search actions including web, images, news, maps, places, video, shopping, scholar, patents, autocomplete, Lens, and reviews. Eleven support mini-batch; Reviews does not. Read `guides/serper.md` before calling them
|
|
454
303
|
- **OpenRouter API** (`openrouter`) — Multi-model AI gateway (chat, embeddings, audio transcription/speech, video)
|
|
304
|
+
- **Web3 infrastructure** — BlockPI RPC (`rpc`, 13 actions) and Binance Web3 API (`binance-web3-api`, 58 actions); read `guides/blockpi.md` or `guides/binance_web3.md` before calling them
|
|
455
305
|
|
|
456
306
|
The full catalog also spans many other categories — crypto/on-chain data, CEX market data, stocks & macro, social platforms, news, weather, and more. Discover them with `search` / `services`.
|
|
457
307
|
|
|
458
|
-
> For crypto data, prefer
|
|
308
|
+
> For ordinary normalized crypto data, prefer built-in `crypto.*`. For an explicit BlockPI, Binance Web3, raw RPC, provider-native, transaction-building, or DeFi request, use the matching specialized guide and service.
|
|
459
309
|
|
|
460
310
|
## Error Handling
|
|
461
311
|
|
|
@@ -464,11 +314,7 @@ The full catalog also spans many other categories — crypto/on-chain data, CEX
|
|
|
464
314
|
- **Insufficient balance** → Run `npx xapi-to topup --method stripe --amount 10`
|
|
465
315
|
- **Unknown API ID** → Use `search` or `list` to find the correct ID, then `get` to check parameters
|
|
466
316
|
|
|
467
|
-
The CLI retries idempotent metadata reads and `task poll` for transient timeouts, network failures, `408`, `429`, and `502`–`504`. It does not automatically retry arbitrary `call` actions because the upstream may already have completed a write; confirm the result before manually retrying posts, payments, or other mutations. Ordinary JSON execution has a 60-second request ceiling. HTTP SSE streams and raw downloads instead use a 60-second no-data timeout, reset whenever a chunk arrives; override it with `XAPI_TRANSFER_IDLE_TIMEOUT_MS` when an upstream legitimately pauses longer.
|
|
468
|
-
|
|
469
|
-
## Tips
|
|
470
|
-
|
|
471
|
-
- Use `--page` and `--page-size` for pagination on `list`, `search`, and `services`.
|
|
317
|
+
The CLI retries idempotent metadata reads and `task poll` for transient timeouts, network failures, `408`, `429`, and `502`–`504`. It does not automatically retry arbitrary `call` actions because the upstream may already have completed a write; confirm the result before manually retrying posts, payments, or other mutations. Ordinary JSON execution has a 60-second request ceiling. HTTP SSE streams and raw downloads instead use a 60-second no-data timeout, reset whenever a chunk arrives; override it with `XAPI_TRANSFER_IDLE_TIMEOUT_MS` when an upstream legitimately pauses longer. Use `--page` and `--page-size` for pagination on `list`, `search`, and `services`.
|
|
472
318
|
|
|
473
319
|
## Specialized Guides
|
|
474
320
|
|
|
@@ -484,11 +330,13 @@ When the user's task involves these workflows, read the corresponding guide file
|
|
|
484
330
|
- **`guides/google_search.md`** — Google Search: web, realtime, news, image, video, scholar, maps, places, shopping
|
|
485
331
|
- **`guides/serper.md`** — direct Serper v7 API: 12 provider-native actions, object-or-array mini-batches, Reviews pagination and batch exception, Lens, dynamic per-credit billing, and the current Webpage service boundary
|
|
486
332
|
- **`guides/crypto.md`** — Crypto (加密货币): on-chain token price/overview/holders/security/OHLCV, wallet analytics, DEX pairs, CEX spot prices by symbol, news — covers contract-address vs symbol addressing and multi-chain
|
|
333
|
+
- **`guides/domains.md`**, **`guides/blockpi.md`**, **`guides/binance_web3.md`** — domain purchase and DNS writes, BlockPI EVM JSON-RPC, and the official Binance Web3 API catalog; read the matching guide before any purchase, mutation, transaction build, signing, or broadcast
|
|
487
334
|
- **`guides/ai.md`** — AI (人工智能): synchronous or SSE-streamed text, embeddings, asynchronous image/video generation with `task wait`, text-to-speech, and speech-to-text
|
|
488
335
|
- **`guides/ai_gateway.md`** — xAPI AI Gateway: Claude Code and Anthropic/OpenAI SDK setup, model discovery, routing strategies, streaming, fallback, routing/billing headers, direct media endpoints, and known limitations
|
|
489
|
-
- **`guides/ws_gateway.md`** — xAPI WebSocket Gateway: OpenAI Realtime, streaming ASR/TTS, simultaneous interpretation, podcast generation, service/path routing, browser authentication, native
|
|
336
|
+
- **`guides/ws_gateway.md`** — xAPI WebSocket Gateway: GPT Live, OpenAI Realtime, streaming ASR/TTS, simultaneous interpretation, podcast generation, service/path routing, browser authentication, native protocols, limits, billing, close codes, and reconnects
|
|
490
337
|
- **`guides/sandbox.md`** — managed Sandbox compute: AI tool selection, one-shot and multi-step lifecycles, provider pinning, files, Cloudflare Web previews, suspension, GPU jobs, parallel agents, cleanup recovery, audit/history, and billing verification
|
|
491
338
|
- **`guides/sms.md`** — SMS verification: buy virtual phone numbers, receive verification codes, finish/cancel orders (5SIM)
|
|
339
|
+
- **`guides/provider.md`** — Provider management: create/update services, About/changelog, version lifecycle, metrics/events and request receipts, Skill upload/linking, rollback/delete, earnings transfer
|
|
492
340
|
|
|
493
341
|
## Security
|
|
494
342
|
|