@gullabs/xai 0.7.1 → 0.9.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/README.md +100 -43
- package/dist/index.cjs +884 -551
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +233 -42
- package/dist/index.d.ts +233 -42
- package/dist/index.js +884 -553
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -35,6 +35,20 @@ type XaiProviderOptions = {
|
|
|
35
35
|
tools?: Array<XaiWebSearchTool | XaiXSearchTool>;
|
|
36
36
|
/** xAI-only; Gemini has no parallel-tool knob. */
|
|
37
37
|
parallelToolCalls?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Responses API `tool_choice` for the server-side search tools; `required`
|
|
40
|
+
* forces at least one search. Requires `tools`, and cannot be combined
|
|
41
|
+
* with the request-level `toolChoice`.
|
|
42
|
+
*/
|
|
43
|
+
toolChoice?: 'auto' | 'required' | 'none';
|
|
44
|
+
/**
|
|
45
|
+
* Responses API `max_turns`: the cap on agentic tool-calling turns for the
|
|
46
|
+
* server-side search tools. A turn can run several searches, so this is
|
|
47
|
+
* not a search count. Requires `tools`. As of 2026-10-02 xAI did not
|
|
48
|
+
* enforce it on grok-4.5 / 4.6 / 4.7; assert on
|
|
49
|
+
* `usage.details.web_search_calls` rather than trusting the cap.
|
|
50
|
+
*/
|
|
51
|
+
maxTurns?: number;
|
|
38
52
|
};
|
|
39
53
|
declare module '@gullabs/core' {
|
|
40
54
|
interface ProviderOptionsMap {
|
|
@@ -106,7 +120,12 @@ interface XaiFunctionCallOutputInputItem {
|
|
|
106
120
|
call_id: string;
|
|
107
121
|
output: string;
|
|
108
122
|
}
|
|
109
|
-
type XaiRequestInputItem = XaiInputItem | XaiFunctionCallInputItem | XaiFunctionCallOutputInputItem;
|
|
123
|
+
type XaiRequestInputItem = XaiInputItem | XaiFunctionCallInputItem | XaiFunctionCallOutputInputItem | XaiOutputItem;
|
|
124
|
+
/** Full wire history for stateless continuation. */
|
|
125
|
+
interface XaiReplayState {
|
|
126
|
+
model: string;
|
|
127
|
+
input: XaiRequestInputItem[];
|
|
128
|
+
}
|
|
110
129
|
/**
|
|
111
130
|
* Structured-output text-format request shape.
|
|
112
131
|
* Real xAI field: `text.format`, NOT `response_format`.
|
|
@@ -159,6 +178,7 @@ interface XaiResponseCreateParams {
|
|
|
159
178
|
type: 'function';
|
|
160
179
|
name: string;
|
|
161
180
|
};
|
|
181
|
+
max_turns?: number;
|
|
162
182
|
parallel_tool_calls?: boolean;
|
|
163
183
|
}
|
|
164
184
|
/** A single summary-text segment of a `type: 'reasoning'` output item. */
|
|
@@ -507,6 +527,7 @@ declare const Grok45ConfigSchema: z.ZodObject<{
|
|
|
507
527
|
high: "high";
|
|
508
528
|
}>;
|
|
509
529
|
}, z.core.$strict>>;
|
|
530
|
+
serviceTier: z.ZodOptional<z.ZodLiteral<"priority">>;
|
|
510
531
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
511
532
|
providerOptions: z.ZodOptional<z.ZodObject<{
|
|
512
533
|
xai: z.ZodOptional<z.ZodObject<{
|
|
@@ -615,6 +636,12 @@ declare const Grok45ConfigSchema: z.ZodObject<{
|
|
|
615
636
|
type: z.ZodLiteral<"web_search">;
|
|
616
637
|
}, z.core.$strict>]>], null>]>>;
|
|
617
638
|
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
639
|
+
toolChoice: z.ZodOptional<z.ZodEnum<{
|
|
640
|
+
auto: "auto";
|
|
641
|
+
required: "required";
|
|
642
|
+
none: "none";
|
|
643
|
+
}>>;
|
|
644
|
+
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
618
645
|
}, z.core.$strict>>;
|
|
619
646
|
}, z.core.$strict>>;
|
|
620
647
|
}, z.core.$strict>;
|
|
@@ -752,6 +779,156 @@ declare const Grok46ConfigSchema: z.ZodObject<{
|
|
|
752
779
|
type: z.ZodLiteral<"web_search">;
|
|
753
780
|
}, z.core.$strict>]>], null>]>>;
|
|
754
781
|
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
782
|
+
toolChoice: z.ZodOptional<z.ZodEnum<{
|
|
783
|
+
auto: "auto";
|
|
784
|
+
required: "required";
|
|
785
|
+
none: "none";
|
|
786
|
+
}>>;
|
|
787
|
+
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
788
|
+
}, z.core.$strict>>;
|
|
789
|
+
}, z.core.$strict>>;
|
|
790
|
+
}, z.core.$strict>;
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Strict Zod config schema for xAI's `grok-4.7` model.
|
|
794
|
+
*
|
|
795
|
+
* Same Responses-API surface as grok-4.6: `reasoning.effort` of
|
|
796
|
+
* `'low' | 'medium' | 'high' | 'xhigh'` and `serviceTier: 'priority'`.
|
|
797
|
+
* Shaped from the grok-4.6 contract. The 2026-09-25 priority success and
|
|
798
|
+
* effort-none rejection and P-X3 encrypted-reasoning multi-turn replay are
|
|
799
|
+
* fixture-backed. `'none'` stays rejected.
|
|
800
|
+
* Unknown tiers (`flex`, `standard`, `batch`) are rejected.
|
|
801
|
+
*
|
|
802
|
+
* @module
|
|
803
|
+
*/
|
|
804
|
+
|
|
805
|
+
declare const Grok47ConfigSchema: z.ZodObject<{
|
|
806
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
807
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
808
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
809
|
+
reasoning: z.ZodOptional<z.ZodObject<{
|
|
810
|
+
effort: z.ZodEnum<{
|
|
811
|
+
low: "low";
|
|
812
|
+
medium: "medium";
|
|
813
|
+
high: "high";
|
|
814
|
+
xhigh: "xhigh";
|
|
815
|
+
}>;
|
|
816
|
+
}, z.core.$strict>>;
|
|
817
|
+
serviceTier: z.ZodOptional<z.ZodLiteral<"priority">>;
|
|
818
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
819
|
+
providerOptions: z.ZodOptional<z.ZodObject<{
|
|
820
|
+
xai: z.ZodOptional<z.ZodObject<{
|
|
821
|
+
promptCacheKey: z.ZodOptional<z.ZodString>;
|
|
822
|
+
tools: z.ZodOptional<z.ZodUnion<readonly [z.ZodTuple<[z.ZodUnion<readonly [z.ZodObject<{
|
|
823
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
824
|
+
enableImageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
825
|
+
type: z.ZodLiteral<"web_search">;
|
|
826
|
+
allowedDomains: z.ZodArray<z.ZodString>;
|
|
827
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
828
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
829
|
+
enableImageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
830
|
+
type: z.ZodLiteral<"web_search">;
|
|
831
|
+
excludedDomains: z.ZodArray<z.ZodString>;
|
|
832
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
833
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
834
|
+
enableImageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
835
|
+
type: z.ZodLiteral<"web_search">;
|
|
836
|
+
}, z.core.$strict>]>], null>, z.ZodTuple<[z.ZodUnion<readonly [z.ZodObject<{
|
|
837
|
+
fromDate: z.ZodOptional<z.ZodISODate>;
|
|
838
|
+
toDate: z.ZodOptional<z.ZodISODate>;
|
|
839
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
840
|
+
enableVideoUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
841
|
+
type: z.ZodLiteral<"x_search">;
|
|
842
|
+
allowedXHandles: z.ZodArray<z.ZodString>;
|
|
843
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
844
|
+
fromDate: z.ZodOptional<z.ZodISODate>;
|
|
845
|
+
toDate: z.ZodOptional<z.ZodISODate>;
|
|
846
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
847
|
+
enableVideoUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
848
|
+
type: z.ZodLiteral<"x_search">;
|
|
849
|
+
excludedXHandles: z.ZodArray<z.ZodString>;
|
|
850
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
851
|
+
fromDate: z.ZodOptional<z.ZodISODate>;
|
|
852
|
+
toDate: z.ZodOptional<z.ZodISODate>;
|
|
853
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
854
|
+
enableVideoUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
855
|
+
type: z.ZodLiteral<"x_search">;
|
|
856
|
+
}, z.core.$strict>]>], null>, z.ZodTuple<[z.ZodUnion<readonly [z.ZodObject<{
|
|
857
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
858
|
+
enableImageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
859
|
+
type: z.ZodLiteral<"web_search">;
|
|
860
|
+
allowedDomains: z.ZodArray<z.ZodString>;
|
|
861
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
862
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
863
|
+
enableImageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
864
|
+
type: z.ZodLiteral<"web_search">;
|
|
865
|
+
excludedDomains: z.ZodArray<z.ZodString>;
|
|
866
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
867
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
868
|
+
enableImageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
869
|
+
type: z.ZodLiteral<"web_search">;
|
|
870
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodObject<{
|
|
871
|
+
fromDate: z.ZodOptional<z.ZodISODate>;
|
|
872
|
+
toDate: z.ZodOptional<z.ZodISODate>;
|
|
873
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
874
|
+
enableVideoUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
875
|
+
type: z.ZodLiteral<"x_search">;
|
|
876
|
+
allowedXHandles: z.ZodArray<z.ZodString>;
|
|
877
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
878
|
+
fromDate: z.ZodOptional<z.ZodISODate>;
|
|
879
|
+
toDate: z.ZodOptional<z.ZodISODate>;
|
|
880
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
881
|
+
enableVideoUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
882
|
+
type: z.ZodLiteral<"x_search">;
|
|
883
|
+
excludedXHandles: z.ZodArray<z.ZodString>;
|
|
884
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
885
|
+
fromDate: z.ZodOptional<z.ZodISODate>;
|
|
886
|
+
toDate: z.ZodOptional<z.ZodISODate>;
|
|
887
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
888
|
+
enableVideoUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
889
|
+
type: z.ZodLiteral<"x_search">;
|
|
890
|
+
}, z.core.$strict>]>], null>, z.ZodTuple<[z.ZodUnion<readonly [z.ZodObject<{
|
|
891
|
+
fromDate: z.ZodOptional<z.ZodISODate>;
|
|
892
|
+
toDate: z.ZodOptional<z.ZodISODate>;
|
|
893
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
894
|
+
enableVideoUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
895
|
+
type: z.ZodLiteral<"x_search">;
|
|
896
|
+
allowedXHandles: z.ZodArray<z.ZodString>;
|
|
897
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
898
|
+
fromDate: z.ZodOptional<z.ZodISODate>;
|
|
899
|
+
toDate: z.ZodOptional<z.ZodISODate>;
|
|
900
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
901
|
+
enableVideoUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
902
|
+
type: z.ZodLiteral<"x_search">;
|
|
903
|
+
excludedXHandles: z.ZodArray<z.ZodString>;
|
|
904
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
905
|
+
fromDate: z.ZodOptional<z.ZodISODate>;
|
|
906
|
+
toDate: z.ZodOptional<z.ZodISODate>;
|
|
907
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
908
|
+
enableVideoUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
909
|
+
type: z.ZodLiteral<"x_search">;
|
|
910
|
+
}, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodObject<{
|
|
911
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
912
|
+
enableImageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
913
|
+
type: z.ZodLiteral<"web_search">;
|
|
914
|
+
allowedDomains: z.ZodArray<z.ZodString>;
|
|
915
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
916
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
917
|
+
enableImageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
918
|
+
type: z.ZodLiteral<"web_search">;
|
|
919
|
+
excludedDomains: z.ZodArray<z.ZodString>;
|
|
920
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
921
|
+
enableImageUnderstanding: z.ZodOptional<z.ZodBoolean>;
|
|
922
|
+
enableImageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
923
|
+
type: z.ZodLiteral<"web_search">;
|
|
924
|
+
}, z.core.$strict>]>], null>]>>;
|
|
925
|
+
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
926
|
+
toolChoice: z.ZodOptional<z.ZodEnum<{
|
|
927
|
+
auto: "auto";
|
|
928
|
+
required: "required";
|
|
929
|
+
none: "none";
|
|
930
|
+
}>>;
|
|
931
|
+
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
755
932
|
}, z.core.$strict>>;
|
|
756
933
|
}, z.core.$strict>>;
|
|
757
934
|
}, z.core.$strict>;
|
|
@@ -759,7 +936,7 @@ declare const Grok46ConfigSchema: z.ZodObject<{
|
|
|
759
936
|
/**
|
|
760
937
|
* Model descriptor + registry for @gullabs/xai.
|
|
761
938
|
*
|
|
762
|
-
* Ships
|
|
939
|
+
* Ships `grok-4.5`, `grok-4.6`, and `grok-4.7`. xAI aliases
|
|
763
940
|
* (`grok-4.5-latest`, `grok-build-latest`) visible in `/v1/models` are
|
|
764
941
|
* intentionally NOT registered (reject-don't-map). `grok-4.6` has no
|
|
765
942
|
* aliases as of the 2026-08-12 `/v1/models` listing.
|
|
@@ -769,6 +946,7 @@ declare const Grok46ConfigSchema: z.ZodObject<{
|
|
|
769
946
|
|
|
770
947
|
declare const grok45ModelDescriptor: ModelDescriptor;
|
|
771
948
|
declare const grok46ModelDescriptor: ModelDescriptor;
|
|
949
|
+
declare const grok47ModelDescriptor: ModelDescriptor;
|
|
772
950
|
/** Every model descriptor `@gullabs/xai` contributes. */
|
|
773
951
|
declare const xaiModelDescriptors: ModelDescriptor[];
|
|
774
952
|
declare const xaiRegistry: ModelRegistry;
|
|
@@ -780,30 +958,35 @@ declare const xaiRegistry: ModelRegistry;
|
|
|
780
958
|
* `@gullabs/core`'s `ModelRates` convention exactly: `cost_µUSD = N *
|
|
781
959
|
* ratePerM / 1_000_000`.
|
|
782
960
|
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
*
|
|
961
|
+
* Token arithmetic goes through core's `computeCost`. The xAI lookup resolves
|
|
962
|
+
* the concrete per-tier rates (including the `priority` multiplier) before
|
|
963
|
+
* that call, so core never sees an xAI tier name. Tool lanes stay here:
|
|
964
|
+
* `computeCost` prices tokens only. `PricingSource` is provider-scoped by
|
|
965
|
+
* contract (see `packages/core/src/ports.ts`).
|
|
787
966
|
*
|
|
788
|
-
* **Long-context tier.** grok-4.5 / grok-4.6 charge a premium when the GROSS
|
|
789
|
-
* input token count
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
967
|
+
* **Long-context tier.** grok-4.5 / grok-4.6 / grok-4.7 charge a premium when the GROSS
|
|
968
|
+
* input token count is at or above 200,000. xAI's current pricing page
|
|
969
|
+
* (https://docs.x.ai/developers/pricing) explicitly labels the band
|
|
970
|
+
* "Long context ≥ 200k tokens"; the live listing returns 200000. Selected by
|
|
971
|
+
* `inputTokens` (incl. cached), not by billable input. Core's selector is
|
|
972
|
+
* strictly greater than 200,000; this module owns the `>=` predicate.
|
|
793
973
|
*
|
|
794
|
-
* **Service tiers.** grok-4.5
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
* priority is served) and `undefined` (no tier requested)
|
|
799
|
-
* standard list. Any other defined tier is unpriced
|
|
974
|
+
* **Service tiers.** grok-4.5, grok-4.6, and grok-4.7 admit `'priority'` at 2×
|
|
975
|
+
* on every token type, cached included. The 4.5 tier was live-verified
|
|
976
|
+
* 2026-09-25; the 4.6 tier is pinned by fixture 12. `'fast'` is an alias and
|
|
977
|
+
* is not admitted. `'default'` (the value
|
|
978
|
+
* xAI echoes when no priority is served) and `undefined` (no tier requested)
|
|
979
|
+
* price at the standard list. Any other defined tier is unpriced
|
|
980
|
+
* (reject-don't-map).
|
|
800
981
|
*
|
|
801
982
|
* **Conversion factor.** xAI's `/v1/models` raw `*_token_price` fields are
|
|
802
|
-
* in hundred-thousandths of a dollar per token
|
|
803
|
-
* by 10,000 to get USD per million tokens): e.g.
|
|
804
|
-
* `prompt_text_token_price: 20000` ÷ 10,000 = $2.00/M.
|
|
983
|
+
* in hundred-thousandths of a dollar per token — cents per 100M tokens
|
|
984
|
+
* (divide the raw integer by 10,000 to get USD per million tokens): e.g.
|
|
985
|
+
* `grok-4.6`'s raw `prompt_text_token_price: 20000` ÷ 10,000 = $2.00/M.
|
|
805
986
|
*
|
|
806
|
-
*
|
|
987
|
+
* Grok 4.5/4.6 rates were verified against `/v1/models` on 2026-08-12.
|
|
988
|
+
* Grok 4.7 rates are published in xAI's 2026-09-21 release notes:
|
|
989
|
+
* https://docs.x.ai/developers/release-notes. Prior snapshot
|
|
807
990
|
* `xai-2026-07-09` priced grok-4.5 cached input at $0.50 / $1.00; the live
|
|
808
991
|
* listing now reports $0.30 / $0.60.
|
|
809
992
|
*
|
|
@@ -811,20 +994,27 @@ declare const xaiRegistry: ModelRegistry;
|
|
|
811
994
|
*/
|
|
812
995
|
|
|
813
996
|
/** Identifies this pricing snapshot — bump the date when rates change. */
|
|
814
|
-
declare const xaiPricingVersion: "xai-2026-
|
|
997
|
+
declare const xaiPricingVersion: "xai-2026-09-25";
|
|
815
998
|
/**
|
|
816
|
-
*
|
|
817
|
-
*
|
|
818
|
-
* $5 / 1,000
|
|
999
|
+
* Tool rates in µUSD per unit.
|
|
1000
|
+
*
|
|
1001
|
+
* - `web_search_calls`: $5 / 1,000 calls (per invocation).
|
|
1002
|
+
* - `x_posts_fetched`: $5 / 1,000 posts (per item, since 2026-09-21).
|
|
1003
|
+
* - `x_users_fetched`: $10 / 1,000 profiles (per item, since 2026-09-21).
|
|
1004
|
+
*
|
|
1005
|
+
* The per-call `x_search_calls` rate is gone. Attachment search stays
|
|
1006
|
+
* unpriced until a live probe pins the counter name (P-X2); a file-ref call
|
|
1007
|
+
* is estimated, not billed at an invented counter.
|
|
819
1008
|
*/
|
|
820
1009
|
declare const XAI_TOOL_RATE_MICRO_USD: {
|
|
821
1010
|
readonly web_search_calls: 5000;
|
|
822
|
-
readonly
|
|
1011
|
+
readonly x_posts_fetched: 5000;
|
|
1012
|
+
readonly x_users_fetched: 10000;
|
|
823
1013
|
};
|
|
824
1014
|
/**
|
|
825
1015
|
* Per-model rate entry (all values in µUSD per million tokens).
|
|
826
1016
|
*
|
|
827
|
-
* `gt200k` (when present) applies when GROSS input tokens
|
|
1017
|
+
* `gt200k` (when present) applies when GROSS input tokens >= 200,000.
|
|
828
1018
|
*/
|
|
829
1019
|
interface XaiModelRates {
|
|
830
1020
|
/** µUSD per million input tokens (billable = gross − cached). */
|
|
@@ -833,7 +1023,7 @@ interface XaiModelRates {
|
|
|
833
1023
|
cachedPerM: number;
|
|
834
1024
|
/** µUSD per million output tokens (reasoning tokens are folded in). */
|
|
835
1025
|
outputPerM: number;
|
|
836
|
-
/** Optional high-tier rates for long-context (GROSS input
|
|
1026
|
+
/** Optional high-tier rates for long-context (GROSS input >= 200_000). */
|
|
837
1027
|
gt200k?: {
|
|
838
1028
|
inputPerM: number;
|
|
839
1029
|
cachedPerM: number;
|
|
@@ -862,24 +1052,25 @@ declare const XAI_PRICING: Readonly<Record<string, XaiModelRates>>;
|
|
|
862
1052
|
*
|
|
863
1053
|
* Pure function — no side effects, always returns a well-formed {@link Cost}.
|
|
864
1054
|
*
|
|
865
|
-
* **Algorithm
|
|
866
|
-
* 1.
|
|
867
|
-
*
|
|
868
|
-
*
|
|
869
|
-
* `'priority'`
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
1055
|
+
* **Algorithm:**
|
|
1056
|
+
* 1. `lookupConcreteRates` resolves the model and tier. `undefined` or
|
|
1057
|
+
* `'default'` is the standard list. `'priority'` returns rates scaled by
|
|
1058
|
+
* `priorityFactor` when the model admits it. An unknown model, any other
|
|
1059
|
+
* defined tier, or `'priority'` on a model without `priorityFactor` is
|
|
1060
|
+
* unpriced (reject-don't-map) — `computeCost` returns `microUsd: null`.
|
|
1061
|
+
* 2. `selectXaiRates` applies long-context rates when GROSS input is
|
|
1062
|
+
* `>= 200_000` (xAI's inclusive threshold; core's selector stays `>`).
|
|
873
1063
|
* 4. Billable input = `inputTokens − (cachedInputTokens ?? 0)`, clamped to 0.
|
|
874
1064
|
* 5. Round each component (input, cached, output) independently to the
|
|
875
1065
|
* nearest integer micro-USD.
|
|
876
1066
|
* 6. `microUsd` is the sum of the four components — guarantees
|
|
877
1067
|
* `details.input + details.cached + details.output + details.tools === microUsd`.
|
|
878
|
-
* 7. Tool lanes:
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
* `
|
|
882
|
-
*
|
|
1068
|
+
* 7. Tool lanes: `web_search_calls` per call; x_search is
|
|
1069
|
+
* `x_posts_fetched` × $5/1k + `x_users_fetched` × $10/1k. A missing
|
|
1070
|
+
* item counter leaves the call unpriced; the provider's billed ticks remain
|
|
1071
|
+
* in `usage.details` for reconciliation outside this rate snapshot.
|
|
1072
|
+
* File-ref still sets `attachment_search_unpinned` and the call is
|
|
1073
|
+
* estimated — the counter name is not pinned (P-X2).
|
|
883
1074
|
*/
|
|
884
1075
|
declare function computeXaiCost(model: string, usage: Usage, tier?: string): Cost;
|
|
885
1076
|
/**
|
|
@@ -925,4 +1116,4 @@ declare function xaiPricingSource(): PricingSource;
|
|
|
925
1116
|
*/
|
|
926
1117
|
declare function xaiProvider(opts?: XaiAdapterOptions): ProviderPlugin;
|
|
927
1118
|
|
|
928
|
-
export { type FileDeleteOptions, Grok45ConfigSchema, Grok46ConfigSchema, 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 XaiResponseCreateParams, type XaiResponseShape, type XaiTextFormat, type XaiUsageShape, type XaiWebSearchTool, type XaiXSearchTool, buildXaiClient, classifyXaiError, computeXaiCost, grok45ModelDescriptor, grok46ModelDescriptor, requireApiKey, xaiAdapter, xaiModelDescriptors, xaiPricingSource, xaiPricingVersion, xaiProvider, xaiRegistry };
|
|
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 };
|