@ai-sdk/xai 1.0.6 → 1.0.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 1.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 4e9032c: feat (provider/xai): Add grok-2 models, use openai-compatible base impl.
8
+
3
9
  ## 1.0.6
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,24 +1,36 @@
1
1
  import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { OpenAICompatibleChatSettings } from '@ai-sdk/openai-compatible';
4
+ import { z } from 'zod';
3
5
 
4
- type XaiChatModelId = 'grok-beta' | 'grok-vision-beta' | (string & {});
5
- interface XaiChatSettings {
6
- /**
7
- A unique identifier representing your end-user, which can help xAI to
8
- monitor and detect abuse.
9
- */
10
- user?: string;
6
+ type XaiChatModelId = 'grok-2-1212' | 'grok-2-vision-1212' | 'grok-beta' | 'grok-vision-beta' | (string & {});
7
+ interface XaiChatSettings extends OpenAICompatibleChatSettings {
11
8
  }
12
9
 
10
+ declare const xaiErrorSchema: z.ZodObject<{
11
+ code: z.ZodString;
12
+ error: z.ZodString;
13
+ }, "strip", z.ZodTypeAny, {
14
+ code: string;
15
+ error: string;
16
+ }, {
17
+ code: string;
18
+ error: string;
19
+ }>;
20
+ type XaiErrorData = z.infer<typeof xaiErrorSchema>;
13
21
  interface XaiProvider extends ProviderV1 {
14
22
  /**
15
- Creates a model for text generation.
16
- */
23
+ Creates an Xai chat model for text generation.
24
+ */
17
25
  (modelId: XaiChatModelId, settings?: XaiChatSettings): LanguageModelV1;
18
26
  /**
19
- Creates an Xai chat model for text generation.
27
+ Creates an Xai language model for text generation.
20
28
  */
21
29
  languageModel(modelId: XaiChatModelId, settings?: XaiChatSettings): LanguageModelV1;
30
+ /**
31
+ Creates an Xai chat model for text generation.
32
+ */
33
+ chat: (modelId: XaiChatModelId, settings?: XaiChatSettings) => LanguageModelV1;
22
34
  }
23
35
  interface XaiProviderSettings {
24
36
  /**
@@ -27,25 +39,19 @@ interface XaiProviderSettings {
27
39
  baseURL?: string;
28
40
  /**
29
41
  API key for authenticating requests.
30
- */
42
+ */
31
43
  apiKey?: string;
32
44
  /**
33
45
  Custom headers to include in the requests.
34
- */
46
+ */
35
47
  headers?: Record<string, string>;
36
48
  /**
37
49
  Custom fetch implementation. You can use it as a middleware to intercept requests,
38
50
  or to provide a custom fetch implementation for e.g. testing.
39
- */
51
+ */
40
52
  fetch?: FetchFunction;
41
53
  }
42
- /**
43
- Create an xAI provider instance.
44
- */
45
54
  declare function createXai(options?: XaiProviderSettings): XaiProvider;
46
- /**
47
- Default xAI provider instance.
48
- */
49
55
  declare const xai: XaiProvider;
50
56
 
51
- export { type XaiProvider, type XaiProviderSettings, createXai, xai };
57
+ export { type XaiErrorData, type XaiProvider, type XaiProviderSettings, createXai, xai };
package/dist/index.d.ts CHANGED
@@ -1,24 +1,36 @@
1
1
  import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { OpenAICompatibleChatSettings } from '@ai-sdk/openai-compatible';
4
+ import { z } from 'zod';
3
5
 
4
- type XaiChatModelId = 'grok-beta' | 'grok-vision-beta' | (string & {});
5
- interface XaiChatSettings {
6
- /**
7
- A unique identifier representing your end-user, which can help xAI to
8
- monitor and detect abuse.
9
- */
10
- user?: string;
6
+ type XaiChatModelId = 'grok-2-1212' | 'grok-2-vision-1212' | 'grok-beta' | 'grok-vision-beta' | (string & {});
7
+ interface XaiChatSettings extends OpenAICompatibleChatSettings {
11
8
  }
12
9
 
10
+ declare const xaiErrorSchema: z.ZodObject<{
11
+ code: z.ZodString;
12
+ error: z.ZodString;
13
+ }, "strip", z.ZodTypeAny, {
14
+ code: string;
15
+ error: string;
16
+ }, {
17
+ code: string;
18
+ error: string;
19
+ }>;
20
+ type XaiErrorData = z.infer<typeof xaiErrorSchema>;
13
21
  interface XaiProvider extends ProviderV1 {
14
22
  /**
15
- Creates a model for text generation.
16
- */
23
+ Creates an Xai chat model for text generation.
24
+ */
17
25
  (modelId: XaiChatModelId, settings?: XaiChatSettings): LanguageModelV1;
18
26
  /**
19
- Creates an Xai chat model for text generation.
27
+ Creates an Xai language model for text generation.
20
28
  */
21
29
  languageModel(modelId: XaiChatModelId, settings?: XaiChatSettings): LanguageModelV1;
30
+ /**
31
+ Creates an Xai chat model for text generation.
32
+ */
33
+ chat: (modelId: XaiChatModelId, settings?: XaiChatSettings) => LanguageModelV1;
22
34
  }
23
35
  interface XaiProviderSettings {
24
36
  /**
@@ -27,25 +39,19 @@ interface XaiProviderSettings {
27
39
  baseURL?: string;
28
40
  /**
29
41
  API key for authenticating requests.
30
- */
42
+ */
31
43
  apiKey?: string;
32
44
  /**
33
45
  Custom headers to include in the requests.
34
- */
46
+ */
35
47
  headers?: Record<string, string>;
36
48
  /**
37
49
  Custom fetch implementation. You can use it as a middleware to intercept requests,
38
50
  or to provide a custom fetch implementation for e.g. testing.
39
- */
51
+ */
40
52
  fetch?: FetchFunction;
41
53
  }
42
- /**
43
- Create an xAI provider instance.
44
- */
45
54
  declare function createXai(options?: XaiProviderSettings): XaiProvider;
46
- /**
47
- Default xAI provider instance.
48
- */
49
55
  declare const xai: XaiProvider;
50
56
 
51
- export { type XaiProvider, type XaiProviderSettings, createXai, xai };
57
+ export { type XaiErrorData, type XaiProvider, type XaiProviderSettings, createXai, xai };