@gullabs/xai 0.9.0 → 0.16.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/NOTICE +6 -0
- package/README.md +294 -60
- package/dist/index.cjs +1927 -447
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +250 -51
- package/dist/index.d.ts +250 -51
- package/dist/index.js +1925 -449
- package/dist/index.js.map +1 -1
- package/package.json +16 -8
package/dist/index.d.cts
CHANGED
|
@@ -90,15 +90,13 @@ interface XaiInputImagePart {
|
|
|
90
90
|
image_url: string;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
* A file attachment content item within an xAI Responses API input message
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* xAI's `attachment_search` agentic tool.
|
|
93
|
+
* A file attachment content item within an xAI Responses API input message:
|
|
94
|
+
* a private upload made through {@link XaiFileStore}. Attaching one implicitly
|
|
95
|
+
* enables xAI's `attachment_search` agentic tool.
|
|
97
96
|
*/
|
|
98
97
|
interface XaiInputFilePart {
|
|
99
98
|
type: 'input_file';
|
|
100
|
-
file_id
|
|
101
|
-
file_url?: string;
|
|
99
|
+
file_id: string;
|
|
102
100
|
}
|
|
103
101
|
/** Union of content-part shapes an input message may carry. */
|
|
104
102
|
type XaiInputContentPart = XaiInputTextPart | XaiInputImagePart | XaiInputFilePart;
|
|
@@ -121,10 +119,15 @@ interface XaiFunctionCallOutputInputItem {
|
|
|
121
119
|
output: string;
|
|
122
120
|
}
|
|
123
121
|
type XaiRequestInputItem = XaiInputItem | XaiFunctionCallInputItem | XaiFunctionCallOutputInputItem | XaiOutputItem;
|
|
124
|
-
/**
|
|
122
|
+
/**
|
|
123
|
+
* Full wire history for stateless continuation (`continuation: 'state'`),
|
|
124
|
+
* scoped under the provider key and bound to the requested model string.
|
|
125
|
+
*/
|
|
125
126
|
interface XaiReplayState {
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
xai: {
|
|
128
|
+
model: string;
|
|
129
|
+
input: XaiRequestInputItem[];
|
|
130
|
+
};
|
|
128
131
|
}
|
|
129
132
|
/**
|
|
130
133
|
* Structured-output text-format request shape.
|
|
@@ -133,18 +136,16 @@ interface XaiReplayState {
|
|
|
133
136
|
* conventions even though the live fixture's request-echo does not surface
|
|
134
137
|
* them (only the schema is echoed back).
|
|
135
138
|
*/
|
|
136
|
-
|
|
139
|
+
interface XaiTextFormat {
|
|
137
140
|
type: 'json_schema';
|
|
138
141
|
name: string;
|
|
139
142
|
schema: unknown;
|
|
140
143
|
strict: boolean;
|
|
141
|
-
}
|
|
142
|
-
type: 'text';
|
|
143
|
-
};
|
|
144
|
+
}
|
|
144
145
|
/**
|
|
145
146
|
* Parameters for `client.responses.create`.
|
|
146
147
|
* Structurally modeled from live-captured xAI Responses API fixtures
|
|
147
|
-
* (see docs/provider-plugins-and-xai-grok-4-5-plan.md §3.1), not from the
|
|
148
|
+
* (see docs/archive/provider-plugins-and-xai-grok-4-5-plan.md §3.1), not from the
|
|
148
149
|
* `openai` npm package's TS types — xAI's actual endpoint shape differs.
|
|
149
150
|
*/
|
|
150
151
|
interface XaiResponseCreateParams {
|
|
@@ -200,13 +201,24 @@ interface XaiOutputTextPart {
|
|
|
200
201
|
logprobs?: unknown[];
|
|
201
202
|
annotations?: unknown[];
|
|
202
203
|
}
|
|
203
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* A refusal content segment of a `type: 'message'` output item (the OpenAI
|
|
206
|
+
* Responses grammar xAI mirrors; not yet captured from xAI).
|
|
207
|
+
*/
|
|
208
|
+
interface XaiRefusalPart {
|
|
209
|
+
type: 'refusal';
|
|
210
|
+
refusal: string;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* A `type: 'message'` item in `output`. A part of any other type may arrive at
|
|
214
|
+
* runtime; the adapter ignores it with a warning.
|
|
215
|
+
*/
|
|
204
216
|
interface XaiMessageOutputItem {
|
|
205
217
|
type: 'message';
|
|
206
218
|
id?: string;
|
|
207
219
|
role?: string;
|
|
208
220
|
status?: string;
|
|
209
|
-
content: XaiOutputTextPart
|
|
221
|
+
content: Array<XaiOutputTextPart | XaiRefusalPart>;
|
|
210
222
|
}
|
|
211
223
|
/** Server-tool or function-call output items we do not collapse as messages. */
|
|
212
224
|
interface XaiOtherOutputItem {
|
|
@@ -243,13 +255,22 @@ interface XaiResponseShape {
|
|
|
243
255
|
id: string;
|
|
244
256
|
model: string;
|
|
245
257
|
/**
|
|
246
|
-
* Real field: `status`. Observed values: "completed", "incomplete"
|
|
247
|
-
*
|
|
258
|
+
* Real field: `status`. Observed values: "completed", "incomplete"; the API
|
|
259
|
+
* also documents "failed" and "cancelled" (never captured). Kept as a plain
|
|
260
|
+
* `string` since xAI may add further status values over time.
|
|
248
261
|
*/
|
|
249
262
|
status: string;
|
|
250
263
|
incomplete_details?: {
|
|
251
264
|
reason?: string;
|
|
252
265
|
} | null;
|
|
266
|
+
/**
|
|
267
|
+
* Error object the Responses API puts on a response that failed after the
|
|
268
|
+
* HTTP 200 (documented shape, never captured).
|
|
269
|
+
*/
|
|
270
|
+
error?: {
|
|
271
|
+
code?: string;
|
|
272
|
+
message?: string;
|
|
273
|
+
} | null;
|
|
253
274
|
output: XaiOutputItem[];
|
|
254
275
|
usage: XaiUsageShape;
|
|
255
276
|
reasoning?: {
|
|
@@ -288,11 +309,101 @@ interface XaiResponseShape {
|
|
|
288
309
|
*/
|
|
289
310
|
interface XaiClientLike {
|
|
290
311
|
responses: {
|
|
291
|
-
create(params: XaiResponseCreateParams, options?:
|
|
292
|
-
signal?: AbortSignal;
|
|
293
|
-
}): Promise<XaiResponseShape>;
|
|
312
|
+
create(params: XaiResponseCreateParams, options?: XaiRequestOptions): Promise<XaiResponseShape>;
|
|
294
313
|
};
|
|
295
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* What the HTTP response of a successful `responses.create` says outside its
|
|
317
|
+
* body: xAI's request id (quote it in a support ticket) and the remaining-quota
|
|
318
|
+
* headers.
|
|
319
|
+
*/
|
|
320
|
+
interface XaiResponseMeta {
|
|
321
|
+
/** The `x-request-id` response header. Absent when xAI sent none. */
|
|
322
|
+
requestId?: string;
|
|
323
|
+
/**
|
|
324
|
+
* Response headers that state remaining quota (`x-ratelimit-remaining-*`, the names xAI sent in
|
|
325
|
+
* every captured response), lower-cased name to the verbatim value. Absent when
|
|
326
|
+
* the response carried none.
|
|
327
|
+
*/
|
|
328
|
+
rateLimitRemaining?: Record<string, string>;
|
|
329
|
+
/**
|
|
330
|
+
* What reconciling the streamed events with the final response object did
|
|
331
|
+
* (ADR-040): items the final object lacked and the stream completed, fields
|
|
332
|
+
* taken from the stream, fields that differed. Absent when they agreed. The
|
|
333
|
+
* adapter reports each as a warning.
|
|
334
|
+
*/
|
|
335
|
+
streamNotes?: string[];
|
|
336
|
+
/**
|
|
337
|
+
* True when output events arrived before the response's terminal event. A
|
|
338
|
+
* `response.failed` after output began is not retried (the run already spent
|
|
339
|
+
* tokens). Set by the real client; absent from a fake one.
|
|
340
|
+
*/
|
|
341
|
+
streamProgressed?: boolean;
|
|
342
|
+
}
|
|
343
|
+
/** Per-request options the adapter passes to `responses.create`. */
|
|
344
|
+
interface XaiRequestOptions {
|
|
345
|
+
signal?: AbortSignal;
|
|
346
|
+
/**
|
|
347
|
+
* The request's whole-call deadline in milliseconds. The real client sends
|
|
348
|
+
* the request as a stream (ADR-040) and applies it twice: as the SDK's
|
|
349
|
+
* `timeout`, which for a stream covers only the wait for response headers,
|
|
350
|
+
* and as its own timer over the remaining stream, so the deadline bounds the
|
|
351
|
+
* whole call. It does not move Node's header and body timers; see
|
|
352
|
+
* {@link XaiTransport}.
|
|
353
|
+
*/
|
|
354
|
+
timeout?: number;
|
|
355
|
+
/**
|
|
356
|
+
* Called with the response's {@link XaiResponseMeta} once the response
|
|
357
|
+
* is complete, before `create` resolves. Only the real client calls it; a
|
|
358
|
+
* fake client may ignore it.
|
|
359
|
+
*/
|
|
360
|
+
onResponse?: (meta: XaiResponseMeta) => void;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Host-supplied HTTP transport for every `responses.create` call.
|
|
364
|
+
*
|
|
365
|
+
* Node's `fetch` enforces its own 300 s header and body timers, independent of
|
|
366
|
+
* the SDK `timeout`. A call whose response headers take longer than that (a
|
|
367
|
+
* tool-using call that streams nothing for minutes) is killed unless the host
|
|
368
|
+
* passes a `fetch` whose dispatcher raises those timers (for example undici's
|
|
369
|
+
* `fetch` with `new Agent({ headersTimeout, bodyTimeout })` in
|
|
370
|
+
* `fetchOptions.dispatcher`). See ADR-032 and the package README.
|
|
371
|
+
*
|
|
372
|
+
* `fetch` must return the request's own `text/event-stream` response: the call
|
|
373
|
+
* always streams (ADR-040), and a `fetch` that buffers the answer into a JSON
|
|
374
|
+
* body (a record/replay or caching wrapper) fails every call with a non-retryable
|
|
375
|
+
* error naming the cause.
|
|
376
|
+
*/
|
|
377
|
+
interface XaiTransport {
|
|
378
|
+
fetch: typeof fetch;
|
|
379
|
+
/**
|
|
380
|
+
* Extra `fetch` init (for example `{ dispatcher }`). `headers`, `signal`,
|
|
381
|
+
* `body` and `method` belong to the request and are rejected.
|
|
382
|
+
*/
|
|
383
|
+
fetchOptions?: Omit<RequestInit, 'headers' | 'signal' | 'body' | 'method'>;
|
|
384
|
+
/**
|
|
385
|
+
* Ends a stream that sends no bytes at all (heartbeat comments included) for
|
|
386
|
+
* this many milliseconds, as a non-retryable `timeout` with
|
|
387
|
+
* `reason: 'transport_timeout'`. Off by default. The request deadline bounds
|
|
388
|
+
* the whole call; this bounds a half-open connection (a NAT drop with no
|
|
389
|
+
* reset) that the deadline would hold for up to an hour. Integer, at least 1.
|
|
390
|
+
* Set it above the longest quiet gap you expect: live reasoning runs showed a
|
|
391
|
+
* longest gap of 15 s.
|
|
392
|
+
*/
|
|
393
|
+
idleTimeoutMs?: number;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* SDK deadline for a request with no `timeoutMs`: one hour. xAI reasoning and
|
|
397
|
+
* agentic calls can run for many minutes; the SDK default (10 minutes) would
|
|
398
|
+
* cut them off.
|
|
399
|
+
*/
|
|
400
|
+
declare const XAI_DEFAULT_TIMEOUT_MS = 3600000;
|
|
401
|
+
/**
|
|
402
|
+
* Added to `timeoutMs` for the SDK deadline, so the engine's own deadline
|
|
403
|
+
* (armed at exactly `timeoutMs`) always fires first and the caller sees the
|
|
404
|
+
* engine's clean timeout rather than a raw SDK error.
|
|
405
|
+
*/
|
|
406
|
+
declare const XAI_TIMEOUT_BUFFER_MS = 5000;
|
|
296
407
|
/**
|
|
297
408
|
* Build a real `openai`-SDK-backed client from AuthMaterial, pointed at
|
|
298
409
|
* xAI's Responses API endpoint.
|
|
@@ -300,8 +411,10 @@ interface XaiClientLike {
|
|
|
300
411
|
* Only API-key authentication is supported.
|
|
301
412
|
*
|
|
302
413
|
* @param auth - API key credentials ({ apiKey }).
|
|
414
|
+
* @param transport - Optional host-supplied `fetch` and `fetchOptions` passed to
|
|
415
|
+
* the SDK client unchanged.
|
|
303
416
|
*/
|
|
304
|
-
declare function buildXaiClient(auth: AuthMaterial): Promise<XaiClientLike>;
|
|
417
|
+
declare function buildXaiClient(auth: AuthMaterial, transport?: XaiTransport): Promise<XaiClientLike>;
|
|
305
418
|
|
|
306
419
|
/**
|
|
307
420
|
* xaiAdapter — @gullabs/xai xAI Grok provider adapter.
|
|
@@ -312,6 +425,17 @@ declare function buildXaiClient(auth: AuthMaterial): Promise<XaiClientLike>;
|
|
|
312
425
|
* @module
|
|
313
426
|
*/
|
|
314
427
|
|
|
428
|
+
/**
|
|
429
|
+
* What the adapter knows about the SDK deadline of the call that failed: the
|
|
430
|
+
* `timeout` it handed the SDK and how long the call ran. Without it an
|
|
431
|
+
* `APIConnectionTimeoutError` is never taken for the SDK's own deadline.
|
|
432
|
+
*/
|
|
433
|
+
interface XaiSdkDeadline {
|
|
434
|
+
/** The per-request `timeout` the adapter passed to the SDK, in ms. */
|
|
435
|
+
timeoutMs: number;
|
|
436
|
+
/** Wall-clock ms between the SDK call starting and the error. */
|
|
437
|
+
elapsedMs: number;
|
|
438
|
+
}
|
|
315
439
|
/**
|
|
316
440
|
* Classify a raw error thrown from the xAI Responses API call into a typed
|
|
317
441
|
* {@link LlmError}.
|
|
@@ -329,12 +453,31 @@ declare function buildXaiClient(auth: AuthMaterial): Promise<XaiClientLike>;
|
|
|
329
453
|
* `"Content violates usage guidelines"` (fixture 15; `SAFETY_CHECK_TYPE_*`
|
|
330
454
|
* suffixes vary) → `content_filter`. A bare 403 without that body stays
|
|
331
455
|
* the core default, `invalid_auth`.
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
456
|
+
* 3b. HTTP 429 or 403 whose structured body is the credits-exhausted /
|
|
457
|
+
* spending-limit sentence (doc-derived, see `XAI_CREDITS_EXHAUSTED_BODY`) →
|
|
458
|
+
* `rate_limited`, `retryable: false`, `reason: 'credits_exhausted'`.
|
|
459
|
+
* 4. A transport deadline (undici header or body timer, or the SDK's own
|
|
460
|
+
* deadline, which needs the `deadline` argument to be recognised; see
|
|
461
|
+
* {@link xaiTransportTimeoutKind}) → `timeout`,
|
|
462
|
+
* `retryable: false`, `reason: 'transport_timeout'`.
|
|
463
|
+
* 5. A transport failure (core's `classifyError` already makes it a retryable
|
|
464
|
+
* `server` error; an `openai` SDK connection error that core left `unknown`
|
|
465
|
+
* is made one here). A connection that never reached xAI is not the
|
|
466
|
+
* caller's fault.
|
|
467
|
+
* 6. Else rebuild the core classification tagged `provider: 'xai'`.
|
|
468
|
+
*
|
|
469
|
+
* A streamed call that failed mid-stream arrives as an `XaiStreamError`; see
|
|
470
|
+
* {@link classifyStreamError} (`estimatedInputTokens` is the request's input
|
|
471
|
+
* estimate, used only for a failure after output began; `requestTimeoutMs` is
|
|
472
|
+
* the timeout the caller configured, quoted by the client-deadline message).
|
|
473
|
+
*/
|
|
474
|
+
declare function classifyXaiError(rawErr: unknown, deadline?: XaiSdkDeadline, estimatedInputTokens?: number, requestTimeoutMs?: number): LlmError;
|
|
475
|
+
/**
|
|
476
|
+
* Default deadline of one `countTokens` call (`POST /v1/tokenize-text`), in
|
|
477
|
+
* milliseconds: 60 s. The call is a small text-only request; the engine's
|
|
478
|
+
* `countTokens` `timeoutMs` and the call's own signal still apply first.
|
|
336
479
|
*/
|
|
337
|
-
declare
|
|
480
|
+
declare const XAI_COUNT_TOKENS_TIMEOUT_MS = 60000;
|
|
338
481
|
interface XaiAdapterOptions {
|
|
339
482
|
/**
|
|
340
483
|
* Inject a pre-built client (real or fake).
|
|
@@ -344,24 +487,31 @@ interface XaiAdapterOptions {
|
|
|
344
487
|
*/
|
|
345
488
|
client?: XaiClientLike;
|
|
346
489
|
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
490
|
+
* HTTP transport (`fetch`, `fetchOptions`, `idleTimeoutMs`) for the SDK client
|
|
491
|
+
* the adapter builds: a proxy, mTLS or egress policy, or an undici `fetch` with
|
|
492
|
+
* an `Agent({ headersTimeout, bodyTimeout })` dispatcher. Calls stream
|
|
493
|
+
* internally (ADR-040), so a reasoning call no longer needs it to run past
|
|
494
|
+
* 300 s; a tool-using call expected to run past 300 s without any streamed
|
|
495
|
+
* event still does (untested, see the package README). `idleTimeoutMs` ends a
|
|
496
|
+
* stream that sends no bytes for that long (off by default). `fetch` must return
|
|
497
|
+
* the request's `text/event-stream` response unchanged. `fetch` and
|
|
498
|
+
* `fetchOptions` also carry `countTokens` (`POST /v1/tokenize-text`). Validated
|
|
499
|
+
* and copied when the adapter is created. Cannot be combined with `client` (an injected client owns its own
|
|
500
|
+
* transport).
|
|
352
501
|
*/
|
|
353
|
-
|
|
502
|
+
transport?: XaiTransport;
|
|
354
503
|
/**
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
504
|
+
* Deadline of one `countTokens` call in milliseconds (an integer from 1 to
|
|
505
|
+
* {@link XAI_MAX_TIMEOUT_MS}); default {@link XAI_COUNT_TOKENS_TIMEOUT_MS}. A
|
|
506
|
+
* call still open then fails with a retryable `timeout` error.
|
|
358
507
|
*/
|
|
359
|
-
|
|
508
|
+
countTokensTimeoutMs?: number;
|
|
360
509
|
}
|
|
361
510
|
/**
|
|
362
511
|
* Create an xAI Grok provider adapter (Responses API).
|
|
363
512
|
*
|
|
364
513
|
* @param opts.client - Optional pre-built client (e.g. for testing).
|
|
514
|
+
* @param opts.transport - Optional `fetch` + `fetchOptions` for the built client.
|
|
365
515
|
*/
|
|
366
516
|
declare function xaiAdapter(opts?: XaiAdapterOptions): ProviderAdapter;
|
|
367
517
|
|
|
@@ -386,6 +536,12 @@ declare const XAI_FILE_TTL_MAX_SECONDS = 2592000;
|
|
|
386
536
|
declare const XAI_FILE_MAX_BYTES: number;
|
|
387
537
|
/** Default Files API base (includes `/v1`). */
|
|
388
538
|
declare const XAI_FILES_DEFAULT_BASE_URL = "https://api.x.ai/v1";
|
|
539
|
+
/**
|
|
540
|
+
* Default deadline of one Files API call (headers and body), in milliseconds:
|
|
541
|
+
* 60 s. A store with an `AbortSignal` of its own still honours it; a very large
|
|
542
|
+
* upload on a slow link needs a larger `timeoutMs` in {@link XaiFileStoreOptions}.
|
|
543
|
+
*/
|
|
544
|
+
declare const XAI_FILES_DEFAULT_TIMEOUT_MS = 60000;
|
|
389
545
|
/** A handle to a file stored in the xAI Files API. */
|
|
390
546
|
interface XaiFileHandle {
|
|
391
547
|
/** File id, e.g. `"file_a128090d-…"`. Use as `FileRefPart.fileId`. */
|
|
@@ -446,6 +602,12 @@ interface XaiFileStoreOptions {
|
|
|
446
602
|
baseUrl?: string;
|
|
447
603
|
/** Injectable fetch for tests. Default: global `fetch`. */
|
|
448
604
|
fetch?: typeof fetch;
|
|
605
|
+
/**
|
|
606
|
+
* Deadline of each call (response headers and body) in milliseconds. A call
|
|
607
|
+
* that is still open then fails with a retryable `timeout` error. An integer
|
|
608
|
+
* from 1 to {@link XAI_MAX_TIMEOUT_MS}; default {@link XAI_FILES_DEFAULT_TIMEOUT_MS}.
|
|
609
|
+
*/
|
|
610
|
+
timeoutMs?: number;
|
|
449
611
|
/**
|
|
450
612
|
* Delete failures that are NOT already-gone (404).
|
|
451
613
|
* Default: `logger.error` or `console.error` with a redacted message.
|
|
@@ -465,6 +627,7 @@ declare class XaiFileStore {
|
|
|
465
627
|
private readonly apiKey;
|
|
466
628
|
private readonly baseUrl;
|
|
467
629
|
private readonly fetchImpl;
|
|
630
|
+
private readonly timeoutMs;
|
|
468
631
|
private readonly onDeleteError;
|
|
469
632
|
private readonly logger;
|
|
470
633
|
constructor(opts: XaiFileStoreOptions);
|
|
@@ -472,6 +635,12 @@ declare class XaiFileStore {
|
|
|
472
635
|
private filesUrl;
|
|
473
636
|
/** Build RequestInit without writing `signal: undefined` (exactOptionalPropertyTypes). */
|
|
474
637
|
private requestInit;
|
|
638
|
+
/**
|
|
639
|
+
* Runs one call under the store's deadline: `run` gets a signal that aborts
|
|
640
|
+
* when the caller's does or when `timeoutMs` passes (headers and body read
|
|
641
|
+
* both count), and the timer is cleared however the call ends.
|
|
642
|
+
*/
|
|
643
|
+
private bounded;
|
|
475
644
|
/**
|
|
476
645
|
* Upload bytes to xAI Files. Returns immediately with metadata (no poll).
|
|
477
646
|
*
|
|
@@ -642,6 +811,13 @@ declare const Grok45ConfigSchema: z.ZodObject<{
|
|
|
642
811
|
none: "none";
|
|
643
812
|
}>>;
|
|
644
813
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
814
|
+
searchBudget: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
815
|
+
maxWebSearchCalls: z.ZodNumber;
|
|
816
|
+
maxXItems: z.ZodOptional<z.ZodNumber>;
|
|
817
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
818
|
+
maxWebSearchCalls: z.ZodOptional<z.ZodNumber>;
|
|
819
|
+
maxXItems: z.ZodNumber;
|
|
820
|
+
}, z.core.$strict>]>>;
|
|
645
821
|
}, z.core.$strict>>;
|
|
646
822
|
}, z.core.$strict>>;
|
|
647
823
|
}, z.core.$strict>;
|
|
@@ -785,6 +961,13 @@ declare const Grok46ConfigSchema: z.ZodObject<{
|
|
|
785
961
|
none: "none";
|
|
786
962
|
}>>;
|
|
787
963
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
964
|
+
searchBudget: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
965
|
+
maxWebSearchCalls: z.ZodNumber;
|
|
966
|
+
maxXItems: z.ZodOptional<z.ZodNumber>;
|
|
967
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
968
|
+
maxWebSearchCalls: z.ZodOptional<z.ZodNumber>;
|
|
969
|
+
maxXItems: z.ZodNumber;
|
|
970
|
+
}, z.core.$strict>]>>;
|
|
788
971
|
}, z.core.$strict>>;
|
|
789
972
|
}, z.core.$strict>>;
|
|
790
973
|
}, z.core.$strict>;
|
|
@@ -795,8 +978,8 @@ declare const Grok46ConfigSchema: z.ZodObject<{
|
|
|
795
978
|
* Same Responses-API surface as grok-4.6: `reasoning.effort` of
|
|
796
979
|
* `'low' | 'medium' | 'high' | 'xhigh'` and `serviceTier: 'priority'`.
|
|
797
980
|
* Shaped from the grok-4.6 contract. The 2026-09-25 priority success and
|
|
798
|
-
* effort-none rejection and
|
|
799
|
-
* fixture-backed. `'none'` stays rejected.
|
|
981
|
+
* effort-none rejection, and the encrypted-reasoning multi-turn replay captured
|
|
982
|
+
* live on 2026-09-26, are fixture-backed. `'none'` stays rejected.
|
|
800
983
|
* Unknown tiers (`flex`, `standard`, `batch`) are rejected.
|
|
801
984
|
*
|
|
802
985
|
* @module
|
|
@@ -929,6 +1112,13 @@ declare const Grok47ConfigSchema: z.ZodObject<{
|
|
|
929
1112
|
none: "none";
|
|
930
1113
|
}>>;
|
|
931
1114
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
1115
|
+
searchBudget: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1116
|
+
maxWebSearchCalls: z.ZodNumber;
|
|
1117
|
+
maxXItems: z.ZodOptional<z.ZodNumber>;
|
|
1118
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1119
|
+
maxWebSearchCalls: z.ZodOptional<z.ZodNumber>;
|
|
1120
|
+
maxXItems: z.ZodNumber;
|
|
1121
|
+
}, z.core.$strict>]>>;
|
|
932
1122
|
}, z.core.$strict>>;
|
|
933
1123
|
}, z.core.$strict>>;
|
|
934
1124
|
}, z.core.$strict>;
|
|
@@ -1003,7 +1193,7 @@ declare const xaiPricingVersion: "xai-2026-09-25";
|
|
|
1003
1193
|
* - `x_users_fetched`: $10 / 1,000 profiles (per item, since 2026-09-21).
|
|
1004
1194
|
*
|
|
1005
1195
|
* The per-call `x_search_calls` rate is gone. Attachment search stays
|
|
1006
|
-
* unpriced until a live probe pins the counter name (
|
|
1196
|
+
* unpriced until a live probe pins the counter name (blocked, see BACKLOG.md); a file-ref call
|
|
1007
1197
|
* is estimated, not billed at an invented counter.
|
|
1008
1198
|
*/
|
|
1009
1199
|
declare const XAI_TOOL_RATE_MICRO_USD: {
|
|
@@ -1032,9 +1222,11 @@ interface XaiModelRates {
|
|
|
1032
1222
|
/**
|
|
1033
1223
|
* Multiplier for Responses `service_tier: "priority"`. Absent = this
|
|
1034
1224
|
* model does not admit priority (unpriced). Uncached standard-list 2×
|
|
1035
|
-
* is confirmed by fixture `12-grok-4-6-xhigh-priority.json` ticks;
|
|
1036
|
-
* cached
|
|
1037
|
-
*
|
|
1225
|
+
* is confirmed by fixture `12-grok-4-6-xhigh-priority.json` ticks; the
|
|
1226
|
+
* cached leg (2× its standard rate) by fixture `35-priority-warm-cache.json`
|
|
1227
|
+
* (warm-cache priority calls on all three models). The `gt200k` leg follows
|
|
1228
|
+
* the official 2×-after-cache-discount docs rule: no priority capture reaches
|
|
1229
|
+
* 200k input tokens.
|
|
1038
1230
|
*/
|
|
1039
1231
|
priorityFactor?: number;
|
|
1040
1232
|
}
|
|
@@ -1065,12 +1257,19 @@ declare const XAI_PRICING: Readonly<Record<string, XaiModelRates>>;
|
|
|
1065
1257
|
* nearest integer micro-USD.
|
|
1066
1258
|
* 6. `microUsd` is the sum of the four components — guarantees
|
|
1067
1259
|
* `details.input + details.cached + details.output + details.tools === microUsd`.
|
|
1068
|
-
* 7.
|
|
1260
|
+
* 7. `cost_in_usd_ticks` (1 tick = 1e-10 USD) is converted to µUSD with the same
|
|
1261
|
+
* rounding and reported as `Cost.providerReported`; `microUsd` stays this
|
|
1262
|
+
* snapshot's price. The engine warns when the two totals drift.
|
|
1263
|
+
* 8. A non-zero server-tool counter that xAI bills per use (or that is unknown)
|
|
1264
|
+
* and this snapshot has no rate for ({@link unpricedXaiToolCounters}, driven
|
|
1265
|
+
* by {@link XAI_SERVER_TOOL_COUNTERS}) makes the call `'estimated'`. Token-only
|
|
1266
|
+
* tools (`mcp_calls`) do not.
|
|
1267
|
+
* 9. Tool lanes: `web_search_calls` per call; x_search is
|
|
1069
1268
|
* `x_posts_fetched` × $5/1k + `x_users_fetched` × $10/1k. A missing
|
|
1070
1269
|
* item counter leaves the call unpriced; the provider's billed ticks remain
|
|
1071
|
-
* in `usage.details`
|
|
1270
|
+
* in `usage.details` and, as `Cost.providerReported`, on the returned cost.
|
|
1072
1271
|
* File-ref still sets `attachment_search_unpinned` and the call is
|
|
1073
|
-
* estimated — the counter name is not pinned
|
|
1272
|
+
* estimated — the counter name is not pinned.
|
|
1074
1273
|
*/
|
|
1075
1274
|
declare function computeXaiCost(model: string, usage: Usage, tier?: string): Cost;
|
|
1076
1275
|
/**
|
|
@@ -1090,8 +1289,8 @@ declare function xaiPricingSource(): PricingSource;
|
|
|
1090
1289
|
/**
|
|
1091
1290
|
* `xaiProvider` — {@link ProviderPlugin} factory for @gullabs/xai.
|
|
1092
1291
|
*
|
|
1093
|
-
* Bundles the xAI Grok adapter, the `grok-4.5` / `grok-4.6`
|
|
1094
|
-
* descriptors, and the xai pricing source into a single plugin for
|
|
1292
|
+
* Bundles the xAI Grok adapter, the `grok-4.5` / `grok-4.6` / `grok-4.7`
|
|
1293
|
+
* model descriptors, and the xai pricing source into a single plugin for
|
|
1095
1294
|
* {@link composeProviders}.
|
|
1096
1295
|
*
|
|
1097
1296
|
* @module
|
|
@@ -1101,8 +1300,8 @@ declare function xaiPricingSource(): PricingSource;
|
|
|
1101
1300
|
* Create a {@link ProviderPlugin} for the xAI Grok provider.
|
|
1102
1301
|
*
|
|
1103
1302
|
* @param opts - Forwarded to {@link xaiAdapter}.
|
|
1104
|
-
* @returns A plugin bundling the xAI adapter, the `grok-4.5` / `grok-4.6`
|
|
1105
|
-
* model descriptors, and the built-in xai pricing source.
|
|
1303
|
+
* @returns A plugin bundling the xAI adapter, the `grok-4.5` / `grok-4.6` /
|
|
1304
|
+
* `grok-4.7` model descriptors, and the built-in xai pricing source.
|
|
1106
1305
|
*
|
|
1107
1306
|
* @example
|
|
1108
1307
|
* ```ts
|
|
@@ -1116,4 +1315,4 @@ declare function xaiPricingSource(): PricingSource;
|
|
|
1116
1315
|
*/
|
|
1117
1316
|
declare function xaiProvider(opts?: XaiAdapterOptions): ProviderPlugin;
|
|
1118
1317
|
|
|
1119
|
-
export { type FileDeleteOptions, Grok45ConfigSchema, Grok46ConfigSchema, Grok47ConfigSchema, XAI_FILES_DEFAULT_BASE_URL, XAI_FILE_MAX_BYTES, XAI_FILE_TTL_MAX_SECONDS, XAI_FILE_TTL_MIN_SECONDS, XAI_PRICING, XAI_TOOL_RATE_MICRO_USD, type XaiAdapterOptions, type XaiClientLike, type XaiFileHandle, type XaiFileListOptions, type XaiFileListResult, XaiFileStore, type XaiFileStoreOptions, type XaiFileUploadInput, type XaiInputContentPart, type XaiInputFilePart, type XaiInputImagePart, type XaiInputItem, type XaiInputTextPart, type XaiMessageOutputItem, type XaiModelRates, type XaiOutputItem, type XaiOutputTextPart, type XaiProviderOptions, type XaiReasoningOutputItem, type XaiReasoningSummaryPart, type XaiReplayState, type XaiRequestInputItem, type XaiResponseCreateParams, type XaiResponseShape, type XaiTextFormat, type XaiUsageShape, type XaiWebSearchTool, type XaiXSearchTool, buildXaiClient, classifyXaiError, computeXaiCost, grok45ModelDescriptor, grok46ModelDescriptor, grok47ModelDescriptor, requireApiKey, xaiAdapter, xaiModelDescriptors, xaiPricingSource, xaiPricingVersion, xaiProvider, xaiRegistry };
|
|
1318
|
+
export { type FileDeleteOptions, Grok45ConfigSchema, Grok46ConfigSchema, Grok47ConfigSchema, XAI_COUNT_TOKENS_TIMEOUT_MS, XAI_DEFAULT_TIMEOUT_MS, XAI_FILES_DEFAULT_BASE_URL, XAI_FILES_DEFAULT_TIMEOUT_MS, XAI_FILE_MAX_BYTES, XAI_FILE_TTL_MAX_SECONDS, XAI_FILE_TTL_MIN_SECONDS, XAI_PRICING, XAI_TIMEOUT_BUFFER_MS, XAI_TOOL_RATE_MICRO_USD, type XaiAdapterOptions, type XaiClientLike, type XaiFileHandle, type XaiFileListOptions, type XaiFileListResult, XaiFileStore, type XaiFileStoreOptions, type XaiFileUploadInput, type XaiInputContentPart, type XaiInputFilePart, type XaiInputImagePart, type XaiInputItem, type XaiInputTextPart, type XaiMessageOutputItem, type XaiModelRates, type XaiOutputItem, type XaiOutputTextPart, type XaiProviderOptions, type XaiReasoningOutputItem, type XaiReasoningSummaryPart, type XaiRefusalPart, type XaiReplayState, type XaiRequestInputItem, type XaiRequestOptions, type XaiResponseCreateParams, type XaiResponseMeta, type XaiResponseShape, type XaiSdkDeadline, type XaiTextFormat, type XaiTransport, type XaiUsageShape, type XaiWebSearchTool, type XaiXSearchTool, buildXaiClient, classifyXaiError, computeXaiCost, grok45ModelDescriptor, grok46ModelDescriptor, grok47ModelDescriptor, requireApiKey, xaiAdapter, xaiModelDescriptors, xaiPricingSource, xaiPricingVersion, xaiProvider, xaiRegistry };
|