@ai-sdk/xai 1.0.0-canary.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ # @ai-sdk/xai
2
+
3
+ ## 1.0.0-canary.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 75d0065: feat (providers/xai): Initial xAI provider.
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # AI SDK - xAI Grok Provider
2
+
3
+ The **[xAI Grok provider](https://sdk.vercel.ai/providers/ai-sdk-providers/xai)** for the [AI SDK](https://sdk.vercel.ai/docs)
4
+ contains language model support for the xAI chat and completion APIs.
5
+
6
+ ## Setup
7
+
8
+ The xAI Grok provider is available in the `@ai-sdk/xai` module. You can install it with
9
+
10
+ ```bash
11
+ npm i @ai-sdk/xai
12
+ ```
13
+
14
+ ## Provider Instance
15
+
16
+ You can import the default provider instance `xai` from `@ai-sdk/xai`:
17
+
18
+ ```ts
19
+ import { xai } from '@ai-sdk/xai';
20
+ ```
21
+
22
+ ## Example
23
+
24
+ ```ts
25
+ import { xai } from '@ai-sdk/xai';
26
+ import { generateText } from 'ai';
27
+
28
+ const { text } = await generateText({
29
+ model: xai('grok-beta'),
30
+ prompt: 'Write a vegetarian lasagna recipe for 4 people.',
31
+ });
32
+ ```
33
+
34
+ ## Documentation
35
+
36
+ Please check out the **[xAI Grok provider documentation](https://sdk.vercel.ai/providers/ai-sdk-providers/xai)** for more information.
@@ -0,0 +1,51 @@
1
+ import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+
4
+ type XaiChatModelId = 'grok-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;
11
+ }
12
+
13
+ interface XaiProvider extends ProviderV1 {
14
+ /**
15
+ Creates a model for text generation.
16
+ */
17
+ (modelId: XaiChatModelId, settings?: XaiChatSettings): LanguageModelV1;
18
+ /**
19
+ Creates an Xai chat model for text generation.
20
+ */
21
+ languageModel(modelId: XaiChatModelId, settings?: XaiChatSettings): LanguageModelV1;
22
+ }
23
+ interface XaiProviderSettings {
24
+ /**
25
+ Base URL for the xAI API calls.
26
+ */
27
+ baseURL?: string;
28
+ /**
29
+ API key for authenticating requests.
30
+ */
31
+ apiKey?: string;
32
+ /**
33
+ Custom headers to include in the requests.
34
+ */
35
+ headers?: Record<string, string>;
36
+ /**
37
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
38
+ or to provide a custom fetch implementation for e.g. testing.
39
+ */
40
+ fetch?: FetchFunction;
41
+ }
42
+ /**
43
+ Create an xAI provider instance.
44
+ */
45
+ declare function createXai(options?: XaiProviderSettings): XaiProvider;
46
+ /**
47
+ Default xAI provider instance.
48
+ */
49
+ declare const xai: XaiProvider;
50
+
51
+ export { type XaiProvider, type XaiProviderSettings, createXai, xai };
@@ -0,0 +1,51 @@
1
+ import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
2
+ import { FetchFunction } from '@ai-sdk/provider-utils';
3
+
4
+ type XaiChatModelId = 'grok-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;
11
+ }
12
+
13
+ interface XaiProvider extends ProviderV1 {
14
+ /**
15
+ Creates a model for text generation.
16
+ */
17
+ (modelId: XaiChatModelId, settings?: XaiChatSettings): LanguageModelV1;
18
+ /**
19
+ Creates an Xai chat model for text generation.
20
+ */
21
+ languageModel(modelId: XaiChatModelId, settings?: XaiChatSettings): LanguageModelV1;
22
+ }
23
+ interface XaiProviderSettings {
24
+ /**
25
+ Base URL for the xAI API calls.
26
+ */
27
+ baseURL?: string;
28
+ /**
29
+ API key for authenticating requests.
30
+ */
31
+ apiKey?: string;
32
+ /**
33
+ Custom headers to include in the requests.
34
+ */
35
+ headers?: Record<string, string>;
36
+ /**
37
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
38
+ or to provide a custom fetch implementation for e.g. testing.
39
+ */
40
+ fetch?: FetchFunction;
41
+ }
42
+ /**
43
+ Create an xAI provider instance.
44
+ */
45
+ declare function createXai(options?: XaiProviderSettings): XaiProvider;
46
+ /**
47
+ Default xAI provider instance.
48
+ */
49
+ declare const xai: XaiProvider;
50
+
51
+ export { type XaiProvider, type XaiProviderSettings, createXai, xai };