@opencode-ai/ai 0.0.0-next-16529 → 0.0.0-next-16535
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/dist/providers/xai.d.ts +22 -19
- package/dist/providers/xai.js +23 -5
- package/package.json +3 -3
package/dist/providers/xai.d.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { type ProviderAuthOption } from "../route/auth-options";
|
|
2
|
-
import type
|
|
3
|
-
import { type ModelID } from "../schema";
|
|
4
|
-
import type {
|
|
2
|
+
import { Route, type RouteDefaultsInput } from "../route/client";
|
|
3
|
+
import { type ModelID, type ProviderOptions } from "../schema";
|
|
4
|
+
import type { OpenAIOptionsInput } from "./openai-options";
|
|
5
5
|
import type { ProviderPackage } from "../provider-package";
|
|
6
6
|
export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
7
|
+
export type XAIProviderOptionsInput = ProviderOptions & {
|
|
8
|
+
readonly xai?: OpenAIOptionsInput;
|
|
9
|
+
};
|
|
7
10
|
export type ModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
8
11
|
readonly baseURL?: string;
|
|
9
|
-
readonly providerOptions?:
|
|
12
|
+
readonly providerOptions?: XAIProviderOptionsInput;
|
|
10
13
|
};
|
|
11
14
|
export interface Settings extends ProviderPackage.Settings {
|
|
12
15
|
readonly apiKey?: string;
|
|
13
16
|
readonly baseURL?: string;
|
|
14
|
-
readonly providerOptions?:
|
|
17
|
+
readonly providerOptions?: XAIProviderOptionsInput;
|
|
15
18
|
}
|
|
16
19
|
export type { XAIImageOptions } from "../protocols/xai-images";
|
|
17
|
-
export declare const routes: (
|
|
20
|
+
export declare const routes: (Route<{
|
|
18
21
|
readonly model: string;
|
|
19
22
|
readonly messages: readonly ({
|
|
20
23
|
readonly role: "system";
|
|
@@ -80,7 +83,7 @@ export declare const routes: (import("../route").Route<{
|
|
|
80
83
|
readonly top_p?: number | undefined;
|
|
81
84
|
readonly store?: boolean | undefined;
|
|
82
85
|
readonly reasoning_effort?: string | undefined;
|
|
83
|
-
}, import("../route/transport/http").HttpPrepared<string>> |
|
|
86
|
+
}, import("../route/transport/http").HttpPrepared<string>> | Route<{
|
|
84
87
|
readonly input: readonly ({
|
|
85
88
|
readonly type: "reasoning";
|
|
86
89
|
readonly summary: readonly {
|
|
@@ -189,28 +192,28 @@ export declare const routes: (import("../route").Route<{
|
|
|
189
192
|
}, import("../route/transport/http").HttpPrepared<string>>)[];
|
|
190
193
|
export declare const configure: (input?: ModelOptions) => {
|
|
191
194
|
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
192
|
-
model: (modelID: string | ModelID) => import("..").Model<
|
|
193
|
-
responses: (modelID: string | ModelID) => import("..").Model<
|
|
194
|
-
chat: (modelID: string | ModelID) => import("..").Model<
|
|
195
|
+
model: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
196
|
+
responses: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
197
|
+
chat: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
195
198
|
image: (modelID: string | ModelID) => import("..").ImageModel<import("./xai").XAIImageOptions>;
|
|
196
199
|
configure: (input?: ModelOptions) => /*elided*/ any;
|
|
197
200
|
};
|
|
198
201
|
export declare const provider: {
|
|
199
202
|
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
200
|
-
model: (modelID: string | ModelID) => import("..").Model<
|
|
201
|
-
responses: (modelID: string | ModelID) => import("..").Model<
|
|
202
|
-
chat: (modelID: string | ModelID) => import("..").Model<
|
|
203
|
+
model: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
204
|
+
responses: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
205
|
+
chat: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
203
206
|
image: (modelID: string | ModelID) => import("..").ImageModel<import("./xai").XAIImageOptions>;
|
|
204
207
|
configure: (input?: ModelOptions) => {
|
|
205
208
|
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
206
|
-
model: (modelID: string | ModelID) => import("..").Model<
|
|
207
|
-
responses: (modelID: string | ModelID) => import("..").Model<
|
|
208
|
-
chat: (modelID: string | ModelID) => import("..").Model<
|
|
209
|
+
model: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
210
|
+
responses: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
211
|
+
chat: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
209
212
|
image: (modelID: string | ModelID) => import("..").ImageModel<import("./xai").XAIImageOptions>;
|
|
210
213
|
configure: /*elided*/ any;
|
|
211
214
|
};
|
|
212
215
|
};
|
|
213
|
-
export declare const model: ProviderPackage.Definition<Settings,
|
|
214
|
-
export declare const responses: (modelID: string | ModelID) => import("..").Model<
|
|
215
|
-
export declare const chat: (modelID: string | ModelID) => import("..").Model<
|
|
216
|
+
export declare const model: ProviderPackage.Definition<Settings, XAIProviderOptionsInput>["model"];
|
|
217
|
+
export declare const responses: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
218
|
+
export declare const chat: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>;
|
|
216
219
|
export declare const image: (modelID: string | ModelID) => import("..").ImageModel<import("./xai").XAIImageOptions>;
|
package/dist/providers/xai.js
CHANGED
|
@@ -1,26 +1,44 @@
|
|
|
1
1
|
import { AuthOptions } from "../route/auth-options";
|
|
2
|
+
import { Route } from "../route/client";
|
|
3
|
+
import { Endpoint } from "../route/endpoint";
|
|
2
4
|
import { HttpOptions, ProviderID } from "../schema";
|
|
3
5
|
import * as OpenAICompatibleProfiles from "./openai-compatible-profile";
|
|
4
6
|
import * as OpenAICompatibleChat from "../protocols/openai-compatible-chat";
|
|
7
|
+
import * as OpenAIChat from "../protocols/openai-chat";
|
|
5
8
|
import * as OpenAIResponses from "../protocols/openai-responses";
|
|
6
9
|
import { XAIImages } from "../protocols/xai-images";
|
|
7
10
|
export const id = ProviderID.make("xai");
|
|
8
|
-
|
|
11
|
+
const responsesRoute = Route.make({
|
|
12
|
+
id: "openai-responses",
|
|
13
|
+
provider: id,
|
|
14
|
+
providerMetadataKey: "xai",
|
|
15
|
+
protocol: OpenAIResponses.protocol,
|
|
16
|
+
endpoint: Endpoint.path("/responses", { baseURL: OpenAICompatibleProfiles.profiles.xai.baseURL }),
|
|
17
|
+
transport: OpenAIResponses.httpTransport,
|
|
18
|
+
defaults: { providerOptions: { xai: { store: false } } },
|
|
19
|
+
});
|
|
20
|
+
const chatRoute = Route.make({
|
|
21
|
+
id: "openai-compatible-chat",
|
|
22
|
+
provider: id,
|
|
23
|
+
providerMetadataKey: "xai",
|
|
24
|
+
protocol: OpenAIChat.protocol,
|
|
25
|
+
endpoint: Endpoint.path("/chat/completions", { baseURL: OpenAICompatibleProfiles.profiles.xai.baseURL }),
|
|
26
|
+
transport: OpenAICompatibleChat.route.transport,
|
|
27
|
+
});
|
|
28
|
+
export const routes = [responsesRoute, chatRoute];
|
|
9
29
|
const auth = (options) => AuthOptions.bearer(options, "XAI_API_KEY");
|
|
10
30
|
const configuredResponsesRoute = (input) => {
|
|
11
31
|
const { apiKey: _, auth: _auth, baseURL, ...rest } = input;
|
|
12
|
-
return
|
|
32
|
+
return responsesRoute.with({
|
|
13
33
|
...rest,
|
|
14
|
-
provider: id,
|
|
15
34
|
endpoint: { baseURL: baseURL ?? OpenAICompatibleProfiles.profiles.xai.baseURL },
|
|
16
35
|
auth: auth(input),
|
|
17
36
|
});
|
|
18
37
|
};
|
|
19
38
|
const configuredChatRoute = (input) => {
|
|
20
39
|
const { apiKey: _, auth: _auth, baseURL, ...rest } = input;
|
|
21
|
-
return
|
|
40
|
+
return chatRoute.with({
|
|
22
41
|
...rest,
|
|
23
|
-
provider: id,
|
|
24
42
|
endpoint: { baseURL: baseURL ?? OpenAICompatibleProfiles.profiles.xai.baseURL },
|
|
25
43
|
auth: auth(input),
|
|
26
44
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-16535",
|
|
4
4
|
"name": "@opencode-ai/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
32
32
|
"@effect/platform-node": "4.0.0-beta.101",
|
|
33
|
-
"@opencode-ai/http-recorder": "0.0.0-next-
|
|
33
|
+
"@opencode-ai/http-recorder": "0.0.0-next-16535",
|
|
34
34
|
"@tsconfig/bun": "1.0.9",
|
|
35
35
|
"@types/bun": "1.3.13",
|
|
36
36
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@smithy/eventstream-codec": "4.2.14",
|
|
41
41
|
"@smithy/util-utf8": "4.2.2",
|
|
42
|
-
"@opencode-ai/schema": "0.0.0-next-
|
|
42
|
+
"@opencode-ai/schema": "0.0.0-next-16535",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-beta.101",
|
|
45
45
|
"google-auth-library": "10.5.0"
|