@ottocode/sdk 0.1.263 → 0.1.265

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.
@@ -9,6 +9,7 @@ const ENV_VARS: Record<BuiltInProviderId, string> = {
9
9
  opencode: 'OPENCODE_API_KEY',
10
10
  copilot: 'GITHUB_TOKEN',
11
11
  ottorouter: 'OTTOROUTER_PRIVATE_KEY',
12
+ xai: 'XAI_API_KEY',
12
13
  zai: 'ZAI_API_KEY',
13
14
  'zai-coding': 'ZAI_CODING_API_KEY',
14
15
  moonshot: 'MOONSHOT_API_KEY',
@@ -103,6 +103,8 @@ export {
103
103
  export type { AnthropicOAuthConfig } from './anthropic-oauth-client.ts';
104
104
  export { createGoogleModel } from './google-client.ts';
105
105
  export type { GoogleProviderConfig } from './google-client.ts';
106
+ export { createXaiModel } from './xai-client.ts';
107
+ export type { XaiProviderConfig } from './xai-client.ts';
106
108
  export { createZaiModel, createZaiCodingModel } from './zai-client.ts';
107
109
  export type { ZaiProviderConfig } from './zai-client.ts';
108
110
  export {
@@ -82,6 +82,9 @@ const pricingTable: Record<ProviderName, PricingEntry[]> = {
82
82
  ottorouter: [
83
83
  // Pricing from catalog entries; leave empty here
84
84
  ],
85
+ xai: [
86
+ // Pricing from catalog entries; leave empty here
87
+ ],
85
88
  zai: [
86
89
  // Pricing from catalog entries; leave empty here
87
90
  ],
@@ -35,6 +35,7 @@ const BUILTIN_COMPATIBILITY: Record<BuiltInProviderId, ProviderCompatibility> =
35
35
  opencode: 'openai-compatible',
36
36
  copilot: 'openai',
37
37
  ottorouter: 'openrouter',
38
+ xai: 'openai',
38
39
  zai: 'openai-compatible',
39
40
  'zai-coding': 'openai-compatible',
40
41
  moonshot: 'openai-compatible',
@@ -50,6 +51,7 @@ const BUILTIN_FAMILY: Record<BuiltInProviderId, ProviderPromptFamily> = {
50
51
  opencode: 'openai-compatible',
51
52
  copilot: 'openai',
52
53
  ottorouter: 'openai-compatible',
54
+ xai: 'openai',
53
55
  zai: 'glm',
54
56
  'zai-coding': 'glm',
55
57
  moonshot: 'moonshot',
@@ -41,6 +41,7 @@ const PREFERRED_FAST_MODELS: Partial<Record<ProviderId, string[]>> = {
41
41
  openrouter: ['anthropic/claude-3.5-haiku'],
42
42
  opencode: ['claude-3-5-haiku'],
43
43
  ottorouter: ['kimi-k2.5'],
44
+ xai: ['grok-code-fast-1', 'grok-4-fast'],
44
45
  zai: ['glm-4.5-flash'],
45
46
  copilot: ['gpt-4.1-mini'],
46
47
  };
@@ -152,6 +153,7 @@ const DIRECT_PROVIDER_FAMILY: Partial<
152
153
  moonshot: 'moonshot',
153
154
  minimax: 'minimax',
154
155
  copilot: 'openai',
156
+ xai: 'openai',
155
157
  zai: 'glm',
156
158
  'zai-coding': 'glm',
157
159
  };
@@ -177,6 +179,7 @@ function inferFromModelId(model: string): UnderlyingProviderKey {
177
179
  )
178
180
  return 'openai';
179
181
  if (lower.includes('gemini') || lower.startsWith('google/')) return 'google';
182
+ if (lower.includes('grok') || lower.startsWith('xai/')) return 'openai';
180
183
  if (lower.includes('kimi') || lower.startsWith('moonshotai/'))
181
184
  return 'moonshot';
182
185
  if (
@@ -0,0 +1,15 @@
1
+ import { createXai } from '@ai-sdk/xai';
2
+ import { catalog } from './catalog-merged.ts';
3
+
4
+ export type XaiProviderConfig = {
5
+ apiKey?: string;
6
+ baseURL?: string;
7
+ };
8
+
9
+ export function createXaiModel(model: string, config?: XaiProviderConfig) {
10
+ const entry = catalog.xai;
11
+ const apiKey = config?.apiKey || process.env.XAI_API_KEY || '';
12
+ const baseURL = config?.baseURL || entry?.api;
13
+ const instance = createXai({ apiKey, baseURL });
14
+ return instance(model);
15
+ }
@@ -10,6 +10,7 @@ export type BuiltInProviderId =
10
10
  | 'opencode'
11
11
  | 'copilot'
12
12
  | 'ottorouter'
13
+ | 'xai'
13
14
  | 'zai'
14
15
  | 'zai-coding'
15
16
  | 'moonshot'