@querais/sdk 0.2.0
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/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +48 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +108 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +143 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QueraIS contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# @querais/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript client + CLI for [QueraIS](https://github.com/ShavitR/querais) — a
|
|
4
|
+
decentralized AI inference marketplace where independent GPU nodes serve your
|
|
5
|
+
requests and settle on-chain.
|
|
6
|
+
|
|
7
|
+
> **Testnet only — no real value.** By using the network you accept the
|
|
8
|
+
> [Terms](https://github.com/ShavitR/querais/blob/main/docs/TERMS.md); read the
|
|
9
|
+
> [Privacy Notice](https://github.com/ShavitR/querais/blob/main/docs/PRIVACY.md)
|
|
10
|
+
> first (~5% of prompts are re-run for verification; prompts execute on
|
|
11
|
+
> independent operators' machines).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @querais/sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quickstart
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { QueraisClient } from '@querais/sdk';
|
|
23
|
+
|
|
24
|
+
const client = new QueraisClient({
|
|
25
|
+
baseUrl: 'https://querais-gateway.fly.dev',
|
|
26
|
+
apiKey: 'sk-querais-…', // issued by the gateway operator
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Buffered
|
|
30
|
+
const r = await client.chat([{ role: 'user', content: 'Explain Arbitrum in one sentence.' }], {
|
|
31
|
+
model: 'gemma3:4b',
|
|
32
|
+
});
|
|
33
|
+
console.log(r.content, r.usage);
|
|
34
|
+
|
|
35
|
+
// Streaming
|
|
36
|
+
for await (const delta of client.chatStream([{ role: 'user', content: 'Hi' }], {
|
|
37
|
+
model: 'gemma3:4b',
|
|
38
|
+
})) {
|
|
39
|
+
process.stdout.write(delta);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Already using the `openai` package?
|
|
44
|
+
|
|
45
|
+
The gateway is OpenAI-compatible — you don't need this SDK at all:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import OpenAI from 'openai';
|
|
49
|
+
const client = new OpenAI({ baseURL: 'https://querais-gateway.fly.dev/v1', apiKey: 'sk-…' });
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This SDK adds the QueraIS-specific surface on top: marketplace routing options
|
|
53
|
+
(`maxPricePer1kTokens`, `minReputation`), node/stats introspection, and
|
|
54
|
+
batched-settlement sessions.
|
|
55
|
+
|
|
56
|
+
## Marketplace helpers
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
await client.models(); // model ids available on the network
|
|
60
|
+
await client.nodes(); // active nodes: wallet, reputation, models, prices
|
|
61
|
+
await client.stats(); // network totals
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Batched settlement (pay once, run thousands of jobs)
|
|
65
|
+
|
|
66
|
+
Deposit $QAIS into the CreditAccount contract once, sign **one** EIP-712
|
|
67
|
+
spending cap off-chain (zero gas), then fire unlimited jobs — the gateway
|
|
68
|
+
settles them in batches. The cap bounds the most it can ever spend.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const client = new QueraisClient({
|
|
72
|
+
baseUrl: 'https://querais-gateway.fly.dev',
|
|
73
|
+
apiKey: 'sk-…',
|
|
74
|
+
privateKey: '0x…', // requester wallet — used ONCE, off-chain, to sign the cap
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
await client.openSession({
|
|
78
|
+
maxSpendWei: 10n ** 21n, // 1000 QAIS ceiling for this session
|
|
79
|
+
nonce: 1n,
|
|
80
|
+
deadline: BigInt(Math.floor(Date.now() / 1000) + 3600),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
await client.chat([{ role: 'user', content: 'Hi' }], { model: 'gemma3:4b' });
|
|
84
|
+
await client.sessionStatus(); // cap, spend, credit balance, headroom
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## CLI
|
|
88
|
+
|
|
89
|
+
The package ships a `querais` binary:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
export QUERAIS_BASE_URL=https://querais-gateway.fly.dev
|
|
93
|
+
export QUERAIS_API_KEY=sk-…
|
|
94
|
+
export QUERAIS_MODEL=gemma3:4b
|
|
95
|
+
|
|
96
|
+
querais chat "Hello" # streams a completion
|
|
97
|
+
querais models # models available on the network
|
|
98
|
+
querais nodes # active nodes + reputation
|
|
99
|
+
querais stats # network stats
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Requirements
|
|
103
|
+
|
|
104
|
+
Node ≥ 22.13 (uses the global `fetch`).
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT — see the [repository](https://github.com/ShavitR/querais).
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { QueraisClient } from './client.js';
|
|
3
|
+
const baseUrl = process.env.QUERAIS_BASE_URL ?? 'http://127.0.0.1:8787';
|
|
4
|
+
const apiKey = process.env.QUERAIS_API_KEY ?? 'sk-querais-dev';
|
|
5
|
+
const model = process.env.QUERAIS_MODEL ?? 'gemma3:4b';
|
|
6
|
+
function usage() {
|
|
7
|
+
console.log('querais <command>');
|
|
8
|
+
console.log(' chat <prompt...> stream a chat completion');
|
|
9
|
+
console.log(' models list available models');
|
|
10
|
+
console.log(' nodes list active nodes');
|
|
11
|
+
console.log(' stats network stats');
|
|
12
|
+
console.log(' env: QUERAIS_BASE_URL, QUERAIS_API_KEY, QUERAIS_MODEL');
|
|
13
|
+
}
|
|
14
|
+
async function main() {
|
|
15
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
16
|
+
const client = new QueraisClient({ baseUrl, apiKey });
|
|
17
|
+
switch (cmd) {
|
|
18
|
+
case 'chat': {
|
|
19
|
+
const prompt = rest.join(' ');
|
|
20
|
+
if (!prompt) {
|
|
21
|
+
console.error('usage: querais chat <prompt>');
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
const messages = [{ role: 'user', content: prompt }];
|
|
25
|
+
for await (const delta of client.chatStream(messages, { model })) {
|
|
26
|
+
process.stdout.write(delta);
|
|
27
|
+
}
|
|
28
|
+
process.stdout.write('\n');
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case 'models':
|
|
32
|
+
console.log((await client.models()).join('\n') || '(none)');
|
|
33
|
+
break;
|
|
34
|
+
case 'nodes':
|
|
35
|
+
console.log(JSON.stringify(await client.nodes(), null, 2));
|
|
36
|
+
break;
|
|
37
|
+
case 'stats':
|
|
38
|
+
console.log(JSON.stringify(await client.stats(), null, 2));
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
usage();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
main().catch((e) => {
|
|
45
|
+
console.error(e instanceof Error ? e.message : e);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,uBAAuB,CAAC;AACxE,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,gBAAgB,CAAC;AAC/D,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,WAAW,CAAC;AAEvD,SAAS,KAAK;IACZ,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;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AC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,CAAC;YAC5D,MAAM;QACR,KAAK,OAAO;YACV,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3D,MAAM;QACR,KAAK,OAAO;YACV,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3D,MAAM;QACR;YACE,KAAK,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE;IAC1B,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { type ChatMessage } from '@querais/shared';
|
|
2
|
+
export interface QueraisClientOptions {
|
|
3
|
+
/** Gateway base URL, e.g. http://127.0.0.1:8787 */
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
/** Bearer API key. */
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** Optional requester private key — only needed to open a batched-settlement session. */
|
|
8
|
+
privateKey?: `0x${string}`;
|
|
9
|
+
}
|
|
10
|
+
/** What the gateway needs you to know to sign a spending cap (`GET /v1/credit/info`). */
|
|
11
|
+
export interface CreditInfo {
|
|
12
|
+
chainId: number;
|
|
13
|
+
creditAccount: `0x${string}`;
|
|
14
|
+
token: `0x${string}`;
|
|
15
|
+
settler: `0x${string}`;
|
|
16
|
+
}
|
|
17
|
+
export interface OpenSessionOptions {
|
|
18
|
+
/** Cumulative ceiling the gateway may settle against this session (wei). */
|
|
19
|
+
maxSpendWei: bigint;
|
|
20
|
+
/** Session nonce (namespaces independent caps for the same requester). */
|
|
21
|
+
nonce: bigint;
|
|
22
|
+
/** Unix-seconds expiry; the gateway/contract reject the cap after this. */
|
|
23
|
+
deadline: bigint;
|
|
24
|
+
}
|
|
25
|
+
/** GET /v1/sessions — live session/credit/headroom view. Wei as decimal strings. */
|
|
26
|
+
export interface SessionStatus {
|
|
27
|
+
requester: `0x${string}`;
|
|
28
|
+
settler: `0x${string}`;
|
|
29
|
+
session: {
|
|
30
|
+
nonce: string;
|
|
31
|
+
maxSpendWei: string;
|
|
32
|
+
deadline: string;
|
|
33
|
+
spentAgainstWei: string;
|
|
34
|
+
capRemainingWei: string;
|
|
35
|
+
} | null;
|
|
36
|
+
credit: {
|
|
37
|
+
balanceWei: string;
|
|
38
|
+
};
|
|
39
|
+
pendingDebits: {
|
|
40
|
+
count: number;
|
|
41
|
+
totalWei: string;
|
|
42
|
+
};
|
|
43
|
+
headroomWei: string | null;
|
|
44
|
+
}
|
|
45
|
+
export interface ChatOptions {
|
|
46
|
+
model: string;
|
|
47
|
+
maxTokens?: number;
|
|
48
|
+
temperature?: number;
|
|
49
|
+
/** QueraIS routing extensions. */
|
|
50
|
+
maxPricePer1kTokens?: number;
|
|
51
|
+
minReputation?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface ChatResult {
|
|
54
|
+
content: string;
|
|
55
|
+
usage: {
|
|
56
|
+
prompt_tokens: number;
|
|
57
|
+
completion_tokens: number;
|
|
58
|
+
total_tokens: number;
|
|
59
|
+
};
|
|
60
|
+
jobId: string | null;
|
|
61
|
+
}
|
|
62
|
+
export interface NodeInfo {
|
|
63
|
+
wallet: string;
|
|
64
|
+
nodeId: string;
|
|
65
|
+
reputation: number;
|
|
66
|
+
models: Array<{
|
|
67
|
+
model: string;
|
|
68
|
+
pricePerTokenWei: string;
|
|
69
|
+
tokensPerSecond: number;
|
|
70
|
+
}>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A tiny OpenAI-shaped client for the QueraIS gateway. The gateway is itself
|
|
74
|
+
* OpenAI-compatible, so this is convenience sugar (plus QueraIS-specific helpers
|
|
75
|
+
* like nodes()/stats()); the official `openai` SDK also works against the gateway.
|
|
76
|
+
*/
|
|
77
|
+
export declare class QueraisClient {
|
|
78
|
+
private readonly opts;
|
|
79
|
+
constructor(opts: QueraisClientOptions);
|
|
80
|
+
private headers;
|
|
81
|
+
private body;
|
|
82
|
+
/** Buffered chat completion. */
|
|
83
|
+
chat(messages: ChatMessage[], opts: ChatOptions): Promise<ChatResult>;
|
|
84
|
+
/** Streaming chat completion — yields content deltas as they arrive. */
|
|
85
|
+
chatStream(messages: ChatMessage[], opts: ChatOptions): AsyncGenerator<string>;
|
|
86
|
+
models(): Promise<string[]>;
|
|
87
|
+
nodes(): Promise<NodeInfo[]>;
|
|
88
|
+
stats(): Promise<unknown>;
|
|
89
|
+
/** Fetch the data needed to build + sign a spending cap (chainId, contract, settler). */
|
|
90
|
+
creditInfo(): Promise<CreditInfo>;
|
|
91
|
+
/**
|
|
92
|
+
* Open a batched-settlement session: sign an EIP-712 spending cap with the client's
|
|
93
|
+
* private key (signed once, off-chain, zero gas) and register it with the gateway. After
|
|
94
|
+
* this, jobs from this key settle in batches — no per-call wallet tx. Requires `privateKey`
|
|
95
|
+
* in the client options and a CreditAccount deposit already in place.
|
|
96
|
+
*/
|
|
97
|
+
openSession(opts: OpenSessionOptions): Promise<{
|
|
98
|
+
ok: boolean;
|
|
99
|
+
nonce: string;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* The requester's live session status: active cap (if any), on-chain spend against it,
|
|
103
|
+
* credit balance, unflushed debits, and `headroomWei` — the largest worst-case job cost
|
|
104
|
+
* the gateway would still accept right now (null without an active session).
|
|
105
|
+
*/
|
|
106
|
+
sessionStatus(): Promise<SessionStatus>;
|
|
107
|
+
}
|
|
108
|
+
//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,CAAC;IAK/B,yFAAyF;IACnF,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC;IAMvC;;;;;OAKG;IACG,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAsBpF;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;CAO9C"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { buildSignedSession } from '@querais/shared';
|
|
2
|
+
/**
|
|
3
|
+
* A tiny OpenAI-shaped client for the QueraIS gateway. The gateway is itself
|
|
4
|
+
* OpenAI-compatible, so this is convenience sugar (plus QueraIS-specific helpers
|
|
5
|
+
* like nodes()/stats()); the official `openai` SDK also works against the gateway.
|
|
6
|
+
*/
|
|
7
|
+
export class QueraisClient {
|
|
8
|
+
opts;
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
this.opts = opts;
|
|
11
|
+
}
|
|
12
|
+
headers() {
|
|
13
|
+
return { 'content-type': 'application/json', authorization: `Bearer ${this.opts.apiKey}` };
|
|
14
|
+
}
|
|
15
|
+
body(messages, opts, stream) {
|
|
16
|
+
return JSON.stringify({
|
|
17
|
+
model: opts.model,
|
|
18
|
+
messages,
|
|
19
|
+
stream,
|
|
20
|
+
...(opts.maxTokens !== undefined ? { max_tokens: opts.maxTokens } : {}),
|
|
21
|
+
...(opts.temperature !== undefined ? { temperature: opts.temperature } : {}),
|
|
22
|
+
...(opts.maxPricePer1kTokens !== undefined
|
|
23
|
+
? { max_price_per_1k_tokens: opts.maxPricePer1kTokens }
|
|
24
|
+
: {}),
|
|
25
|
+
...(opts.minReputation !== undefined ? { min_reputation: opts.minReputation } : {}),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Buffered chat completion. */
|
|
29
|
+
async chat(messages, opts) {
|
|
30
|
+
const res = await fetch(`${this.opts.baseUrl}/v1/chat/completions`, {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: this.headers(),
|
|
33
|
+
body: this.body(messages, opts, false),
|
|
34
|
+
});
|
|
35
|
+
if (!res.ok)
|
|
36
|
+
throw new Error(`QueraIS chat failed: HTTP ${res.status} ${await res.text()}`);
|
|
37
|
+
const json = (await res.json());
|
|
38
|
+
return {
|
|
39
|
+
content: json.choices[0]?.message.content ?? '',
|
|
40
|
+
usage: json.usage,
|
|
41
|
+
jobId: res.headers.get('x-querais-job-id'),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Streaming chat completion — yields content deltas as they arrive. */
|
|
45
|
+
async *chatStream(messages, opts) {
|
|
46
|
+
const res = await fetch(`${this.opts.baseUrl}/v1/chat/completions`, {
|
|
47
|
+
method: 'POST',
|
|
48
|
+
headers: this.headers(),
|
|
49
|
+
body: this.body(messages, opts, true),
|
|
50
|
+
});
|
|
51
|
+
if (!res.ok || !res.body) {
|
|
52
|
+
throw new Error(`QueraIS chat stream failed: HTTP ${res.status} ${await res.text()}`);
|
|
53
|
+
}
|
|
54
|
+
const reader = res.body.getReader();
|
|
55
|
+
const dec = new TextDecoder();
|
|
56
|
+
let buf = '';
|
|
57
|
+
for (;;) {
|
|
58
|
+
const { value, done } = await reader.read();
|
|
59
|
+
if (done)
|
|
60
|
+
break;
|
|
61
|
+
buf += dec.decode(value, { stream: true });
|
|
62
|
+
let i;
|
|
63
|
+
while ((i = buf.indexOf('\n\n')) !== -1) {
|
|
64
|
+
const frame = buf.slice(0, i);
|
|
65
|
+
buf = buf.slice(i + 2);
|
|
66
|
+
const data = frame.replace(/^data: /, '').trim();
|
|
67
|
+
if (!data || data === '[DONE]')
|
|
68
|
+
continue;
|
|
69
|
+
try {
|
|
70
|
+
const j = JSON.parse(data);
|
|
71
|
+
const delta = j.choices?.[0]?.delta?.content;
|
|
72
|
+
if (delta)
|
|
73
|
+
yield delta;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
/* ignore keep-alives / non-JSON frames */
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async models() {
|
|
82
|
+
const res = await fetch(`${this.opts.baseUrl}/v1/models`, { headers: this.headers() });
|
|
83
|
+
const json = (await res.json());
|
|
84
|
+
return json.data.map((m) => m.id);
|
|
85
|
+
}
|
|
86
|
+
async nodes() {
|
|
87
|
+
const res = await fetch(`${this.opts.baseUrl}/v1/nodes`, { headers: this.headers() });
|
|
88
|
+
const json = (await res.json());
|
|
89
|
+
return json.data;
|
|
90
|
+
}
|
|
91
|
+
async stats() {
|
|
92
|
+
const res = await fetch(`${this.opts.baseUrl}/v1/stats`, { headers: this.headers() });
|
|
93
|
+
return res.json();
|
|
94
|
+
}
|
|
95
|
+
/** Fetch the data needed to build + sign a spending cap (chainId, contract, settler). */
|
|
96
|
+
async creditInfo() {
|
|
97
|
+
const res = await fetch(`${this.opts.baseUrl}/v1/credit/info`, { headers: this.headers() });
|
|
98
|
+
if (!res.ok)
|
|
99
|
+
throw new Error(`QueraIS credit info failed: HTTP ${res.status}`);
|
|
100
|
+
return (await res.json());
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Open a batched-settlement session: sign an EIP-712 spending cap with the client's
|
|
104
|
+
* private key (signed once, off-chain, zero gas) and register it with the gateway. After
|
|
105
|
+
* this, jobs from this key settle in batches — no per-call wallet tx. Requires `privateKey`
|
|
106
|
+
* in the client options and a CreditAccount deposit already in place.
|
|
107
|
+
*/
|
|
108
|
+
async openSession(opts) {
|
|
109
|
+
if (!this.opts.privateKey)
|
|
110
|
+
throw new Error('openSession requires a privateKey in client opts');
|
|
111
|
+
const info = await this.creditInfo();
|
|
112
|
+
const wire = await buildSignedSession(this.opts.privateKey, {
|
|
113
|
+
maxSpendWei: opts.maxSpendWei,
|
|
114
|
+
nonce: opts.nonce,
|
|
115
|
+
deadline: opts.deadline,
|
|
116
|
+
settler: info.settler,
|
|
117
|
+
chainId: info.chainId,
|
|
118
|
+
verifyingContract: info.creditAccount,
|
|
119
|
+
});
|
|
120
|
+
const res = await fetch(`${this.opts.baseUrl}/v1/sessions`, {
|
|
121
|
+
method: 'POST',
|
|
122
|
+
headers: this.headers(),
|
|
123
|
+
body: JSON.stringify(wire),
|
|
124
|
+
});
|
|
125
|
+
if (!res.ok) {
|
|
126
|
+
throw new Error(`QueraIS openSession failed: HTTP ${res.status} ${await res.text()}`);
|
|
127
|
+
}
|
|
128
|
+
return (await res.json());
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The requester's live session status: active cap (if any), on-chain spend against it,
|
|
132
|
+
* credit balance, unflushed debits, and `headroomWei` — the largest worst-case job cost
|
|
133
|
+
* the gateway would still accept right now (null without an active session).
|
|
134
|
+
*/
|
|
135
|
+
async sessionStatus() {
|
|
136
|
+
const res = await fetch(`${this.opts.baseUrl}/v1/sessions`, { headers: this.headers() });
|
|
137
|
+
if (!res.ok) {
|
|
138
|
+
throw new Error(`QueraIS sessionStatus failed: HTTP ${res.status} ${await res.text()}`);
|
|
139
|
+
}
|
|
140
|
+
return (await res.json());
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAoB,MAAM,iBAAiB,CAAC;AAkEvE;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,IAA0B;QAA1B,SAAI,GAAJ,IAAI,CAAsB;IAAG,CAAC;IAEnD,OAAO;QACb,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,UAAU,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IAC7F,CAAC;IAEO,IAAI,CAAC,QAAuB,EAAE,IAAiB,EAAE,MAAe;QACtE,OAAO,IAAI,CAAC,S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AK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,cAAc,EAAE;YAC1D,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;YACvB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,CAAC,MAAM,IAAI,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACxF,CAAC;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAmC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,aAAa;QACjB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,cAAc,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACzF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,sCAAsC,GAAG,CAAC,MAAM,IAAI,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAkB,CAAC;IAC7C,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @querais/sdk — a tiny OpenAI-shaped TypeScript client + `querais` CLI.
|
|
3
|
+
*
|
|
4
|
+
* The QueraIS gateway is OpenAI-compatible, so the official `openai` SDK works
|
|
5
|
+
* against it directly (see the e2e parity test). This client adds convenience plus
|
|
6
|
+
* QueraIS-specific helpers (nodes(), stats()).
|
|
7
|
+
*/
|
|
8
|
+
export declare const SDK_VERSION = "0.2.0";
|
|
9
|
+
export { QueraisClient, type QueraisClientOptions, type ChatOptions, type ChatResult, type NodeInfo, type SessionStatus, } from './client.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @querais/sdk — a tiny OpenAI-shaped TypeScript client + `querais` CLI.
|
|
3
|
+
*
|
|
4
|
+
* The QueraIS gateway is OpenAI-compatible, so the official `openai` SDK works
|
|
5
|
+
* against it directly (see the e2e parity test). This client adds convenience plus
|
|
6
|
+
* QueraIS-specific helpers (nodes(), stats()).
|
|
7
|
+
*/
|
|
8
|
+
export const SDK_VERSION = '0.2.0';
|
|
9
|
+
export { QueraisClient, } from './client.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC,OAAO,EACL,aAAa,GAMd,MAAM,aAAa,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@querais/sdk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "TypeScript client + CLI for QueraIS, the decentralized AI inference marketplace. OpenAI-shaped chat/streaming plus QueraIS extras: nodes, stats, batched-settlement sessions.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"querais",
|
|
8
|
+
"ai",
|
|
9
|
+
"llm",
|
|
10
|
+
"inference",
|
|
11
|
+
"openai-compatible",
|
|
12
|
+
"decentralized",
|
|
13
|
+
"arbitrum",
|
|
14
|
+
"web3"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/ShavitR/querais/tree/main/packages/sdk#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/ShavitR/querais.git",
|
|
20
|
+
"directory": "packages/sdk"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/ShavitR/querais/issues"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"bin": {
|
|
29
|
+
"querais": "./dist/cli.js"
|
|
30
|
+
},
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"!dist/**/*.test.*",
|
|
40
|
+
"!dist/.tsbuildinfo",
|
|
41
|
+
"README.md"
|
|
42
|
+
],
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=22.13"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@querais/shared": "0.2.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc -b",
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"test": "node --import tsx --test \"src/**/*.test.ts\""
|
|
56
|
+
}
|
|
57
|
+
}
|