@standardagents/xai 0.0.1-dev.ffffff → 0.13.2

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.
Files changed (3) hide show
  1. package/LICENSE.txt +48 -0
  2. package/README.md +130 -3
  3. package/package.json +12 -12
package/LICENSE.txt ADDED
@@ -0,0 +1,48 @@
1
+ PROPRIETARY SOFTWARE LICENSE
2
+
3
+ Copyright (c) 2024-2025 FormKit Inc. All Rights Reserved.
4
+
5
+ UNLICENSED - DO NOT USE
6
+
7
+ This software and associated documentation files (the "Software") are the sole
8
+ and exclusive property of FormKit Inc. ("FormKit").
9
+
10
+ USE RESTRICTIONS
11
+
12
+ The Software is UNLICENSED and proprietary. NO PERMISSION is granted to use,
13
+ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14
+ the Software, or to permit persons to whom the Software is furnished to do so,
15
+ under any circumstances, without prior written authorization from FormKit Inc.
16
+
17
+ UNAUTHORIZED USE PROHIBITED
18
+
19
+ Any use of this Software without a valid, written license agreement signed by
20
+ authorized officers of FormKit Inc. is strictly prohibited and constitutes
21
+ unauthorized use and infringement of FormKit's intellectual property rights.
22
+
23
+ LICENSING INQUIRIES
24
+
25
+ Organizations interested in licensing this Software should contact:
26
+ enterprise@formkit.com
27
+
28
+ A written license agreement must be executed before any use of this Software
29
+ is authorized.
30
+
31
+ NO WARRANTY
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
36
+ FORMKIT INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
37
+ AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
38
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39
+
40
+ GOVERNING LAW
41
+
42
+ This license shall be governed by and construed in accordance with the laws
43
+ of the jurisdiction in which FormKit Inc. is incorporated, without regard to
44
+ its conflict of law provisions.
45
+
46
+ FormKit Inc.
47
+ https://formkit.com
48
+ enterprise@formkit.com
package/README.md CHANGED
@@ -1,7 +1,134 @@
1
1
  # @standardagents/xai
2
2
 
3
- Stub prerelease package for Standard Agents xAI provider publishing setup.
3
+ xAI provider for Standard Agents.
4
4
 
5
- Current bootstrap version: `0.0.1-dev.ffffff`
5
+ This package integrates xAI chat and image models through the Standard Agents provider interface. It uses the official `@ai-sdk/xai` integration under the hood and handles:
6
6
 
7
- This package will be wired into the normal monorepo release flow after trusted publishing is configured.
7
+ - text generation and streaming
8
+ - multimodal chat requests with image inputs
9
+ - local function tools on supported Grok models
10
+ - xAI reasoning controls where supported
11
+ - image generation and edit-style requests
12
+ - usage and cost extraction from xAI API responses
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install @standardagents/xai @standardagents/spec
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```ts
23
+ import { xai } from '@standardagents/xai';
24
+
25
+ const provider = xai({
26
+ apiKey: process.env.XAI_API_KEY!,
27
+ });
28
+
29
+ const result = await provider.generate({
30
+ model: 'grok-4-0709',
31
+ messages: [
32
+ { role: 'user', content: 'Write a short tagline for a robotics startup.' },
33
+ ],
34
+ });
35
+
36
+ console.log(result.content);
37
+ console.log(result.usage?.cost);
38
+ ```
39
+
40
+ ## Factory
41
+
42
+ The package exports:
43
+
44
+ - `xai(config)` - provider factory
45
+ - `XAIProvider` - provider class
46
+ - `xaiProviderOptions` - Zod schema for provider-specific options
47
+
48
+ Factory config:
49
+
50
+ ```ts
51
+ type ProviderFactoryConfig = {
52
+ apiKey: string;
53
+ baseUrl?: string;
54
+ timeout?: number;
55
+ };
56
+ ```
57
+
58
+ ## Supported Features
59
+
60
+ Depending on the model, the provider supports:
61
+
62
+ - streaming chat
63
+ - images in chat input
64
+ - local function tool calling
65
+ - JSON mode
66
+ - reasoning controls
67
+ - image generation output
68
+
69
+ The package includes a curated static catalog for current xAI text and image models, including Grok aliases.
70
+
71
+ ```ts
72
+ const models = await provider.getModels?.();
73
+ const capabilities = await provider.getModelCapabilities?.('grok-4.20-0309-reasoning');
74
+ ```
75
+
76
+ ## Provider Options
77
+
78
+ Common xAI-specific provider options:
79
+
80
+ - `reasoningEffort`
81
+ - `logprobs`
82
+ - `topLogprobs`
83
+ - `parallel_function_calling`
84
+ - `searchParameters`
85
+ - `aspect_ratio`
86
+ - `output_format`
87
+ - `sync_mode`
88
+ - `resolution`
89
+ - `quality`
90
+ - `numberOfImages`
91
+
92
+ Example:
93
+
94
+ ```ts
95
+ const result = await provider.generate({
96
+ model: 'grok-4-0709',
97
+ messages: [{ role: 'user', content: 'Search the web and summarize today in one paragraph.' }],
98
+ providerOptions: {
99
+ reasoningEffort: 'high',
100
+ searchParameters: {
101
+ mode: 'auto',
102
+ returnCitations: true,
103
+ sources: [{ type: 'web', safeSearch: true }],
104
+ },
105
+ },
106
+ });
107
+ ```
108
+
109
+ ## Images
110
+
111
+ For chat models, the provider translates Standard Agents image parts and image attachments into xAI image inputs. For xAI image generation models, it routes image requests through the image generation path and returns generated image attachments in the Standard Agents response format.
112
+
113
+ ## Cost Data
114
+
115
+ When xAI returns `cost_in_usd_ticks`, this package converts it to USD and attaches the monetary value to `usage.cost`. That means xAI responses can log actual API-reported cost instead of relying only on token-price fallback tables.
116
+
117
+ ## Debugging
118
+
119
+ Use `inspectRequest()` to view the xAI-native request body that will be sent to the provider:
120
+
121
+ ```ts
122
+ const inspected = await provider.inspectRequest?.({
123
+ model: 'grok-4.20-0309-non-reasoning',
124
+ messages: [{ role: 'user', content: 'hello' }],
125
+ });
126
+
127
+ console.log(inspected?.body);
128
+ ```
129
+
130
+ ## Notes
131
+
132
+ - xAI tool choice translation is normalized to the shapes expected by the xAI SDK.
133
+ - Non-image generic file parts are not supported in xAI chat requests; image parts are supported.
134
+ - Some moving aliases such as `grok-4` and `grok-4-latest` are resolved to the current snapshot IDs internally.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@standardagents/xai",
3
- "version": "0.0.1-dev.ffffff",
3
+ "version": "0.13.2",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "restricted",
@@ -20,13 +20,6 @@
20
20
  "dist",
21
21
  "README.md"
22
22
  ],
23
- "scripts": {
24
- "build": "tsup",
25
- "dev": "tsup --watch",
26
- "typecheck": "tsc --noEmit",
27
- "test": "cd ../.. && vitest --dir packages/xai",
28
- "test:run": "cd ../.. && vitest run --dir packages/xai"
29
- },
30
23
  "dependencies": {
31
24
  "@ai-sdk/xai": "^3.0.75",
32
25
  "ai": "^6.0.142",
@@ -36,9 +29,9 @@
36
29
  "@standardagents/spec": "^0.10.0"
37
30
  },
38
31
  "devDependencies": {
39
- "@standardagents/spec": "workspace:*",
40
32
  "tsup": "^8.3.5",
41
- "typescript": "^5.9.0"
33
+ "typescript": "^5.9.0",
34
+ "@standardagents/spec": "0.13.2"
42
35
  },
43
36
  "keywords": [
44
37
  "standardagents",
@@ -49,5 +42,12 @@
49
42
  "llm"
50
43
  ],
51
44
  "author": "FormKit Inc.",
52
- "license": "UNLICENSED"
53
- }
45
+ "license": "UNLICENSED",
46
+ "scripts": {
47
+ "build": "tsup",
48
+ "dev": "tsup --watch",
49
+ "typecheck": "tsc --noEmit",
50
+ "test": "cd ../.. && vitest --dir packages/xai",
51
+ "test:run": "cd ../.. && vitest run --dir packages/xai"
52
+ }
53
+ }