@opencode/ai 2.2.6 → 2.2.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/README.md +96 -4
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/decision.d.ts +10 -0
- package/dist/decision.js +2 -0
- package/dist/effect.d.ts +6 -0
- package/dist/effect.js +4 -0
- package/dist/embedding-client.d.ts +21 -0
- package/dist/embedding-client.js +30 -0
- package/dist/embedding.d.ts +111 -0
- package/dist/embedding.js +75 -0
- package/dist/image.d.ts +0 -1
- package/dist/image.js +0 -3
- package/dist/index.d.ts +7 -2
- package/dist/index.js +5 -0
- package/dist/protocols/alibaba-chat.d.ts +4 -0
- package/dist/protocols/anthropic-messages.js +3 -3
- package/dist/protocols/google-embed-content.d.ts +34 -0
- package/dist/protocols/google-embed-content.js +110 -0
- package/dist/protocols/google-vertex-predict-embeddings.d.ts +18 -0
- package/dist/protocols/google-vertex-predict-embeddings.js +74 -0
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/open-responses.d.ts +1 -1
- package/dist/protocols/open-responses.js +31 -8
- package/dist/protocols/openai-chat.d.ts +24 -0
- package/dist/protocols/openai-chat.js +37 -11
- package/dist/protocols/openai-compatible-chat.d.ts +1 -0
- package/dist/protocols/openai-decisions.js +14 -1
- package/dist/protocols/openai-embeddings.d.ts +16 -0
- package/dist/protocols/openai-embeddings.js +76 -0
- package/dist/protocols/shared.d.ts +13 -3
- package/dist/protocols/shared.js +27 -4
- package/dist/protocols/system-one.js +8 -1
- package/dist/protocols/venice-chat.d.ts +4 -0
- package/dist/protocols/zai-chat.d.ts +4 -0
- package/dist/providers/alibaba/embeddings.d.ts +2 -0
- package/dist/providers/alibaba/embeddings.js +1 -0
- package/dist/providers/alibaba.d.ts +3 -0
- package/dist/providers/alibaba.js +14 -1
- package/dist/providers/amazon-bedrock-mantle.d.ts +1 -0
- package/dist/providers/azure/embeddings.d.ts +2 -0
- package/dist/providers/azure/embeddings.js +1 -0
- package/dist/providers/azure.d.ts +3 -0
- package/dist/providers/azure.js +15 -0
- package/dist/providers/baseten.d.ts +2 -0
- package/dist/providers/cerebras.d.ts +2 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +2 -0
- package/dist/providers/cohere/embeddings.d.ts +2 -0
- package/dist/providers/cohere/embeddings.js +1 -0
- package/dist/providers/cohere.d.ts +8 -0
- package/dist/providers/cohere.js +17 -1
- package/dist/providers/deepinfra/embeddings.d.ts +2 -0
- package/dist/providers/deepinfra/embeddings.js +1 -0
- package/dist/providers/deepinfra.d.ts +6 -1
- package/dist/providers/deepinfra.js +15 -1
- package/dist/providers/deepseek.d.ts +2 -0
- package/dist/providers/digitalocean/embeddings.d.ts +2 -0
- package/dist/providers/digitalocean/embeddings.js +1 -0
- package/dist/providers/digitalocean.d.ts +10 -0
- package/dist/providers/digitalocean.js +15 -0
- package/dist/providers/fireworks/embeddings.d.ts +2 -0
- package/dist/providers/fireworks/embeddings.js +1 -0
- package/dist/providers/fireworks.d.ts +6 -1
- package/dist/providers/fireworks.js +15 -1
- package/dist/providers/google/embeddings.d.ts +2 -0
- package/dist/providers/google/embeddings.js +1 -0
- package/dist/providers/google-vertex/embeddings.d.ts +2 -0
- package/dist/providers/google-vertex/embeddings.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +1 -0
- package/dist/providers/google-vertex.d.ts +7 -0
- package/dist/providers/google-vertex.js +52 -0
- package/dist/providers/google.d.ts +6 -0
- package/dist/providers/google.js +14 -0
- package/dist/providers/groq.d.ts +5 -0
- package/dist/providers/meta.d.ts +1 -0
- package/dist/providers/minimax.d.ts +1 -0
- package/dist/providers/moonshot.d.ts +1 -0
- package/dist/providers/openai/embeddings.d.ts +2 -0
- package/dist/providers/openai/embeddings.js +1 -0
- package/dist/providers/openai-compatible/embeddings.d.ts +2 -0
- package/dist/providers/openai-compatible/embeddings.js +1 -0
- package/dist/providers/openai-compatible.d.ts +4 -0
- package/dist/providers/openai-compatible.js +13 -0
- package/dist/providers/openai.d.ts +7 -0
- package/dist/providers/openai.js +14 -0
- package/dist/providers/openrouter/embeddings.d.ts +2 -0
- package/dist/providers/openrouter/embeddings.js +1 -0
- package/dist/providers/openrouter.d.ts +16 -0
- package/dist/providers/openrouter.js +15 -0
- package/dist/providers/togetherai.d.ts +2 -0
- package/dist/providers/venice.d.ts +1 -0
- package/dist/providers/vercel-ai-gateway/embeddings.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/embeddings.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +4 -0
- package/dist/providers/vercel-ai-gateway.js +15 -1
- package/dist/providers/xai.d.ts +1 -0
- package/dist/providers/zai-coding-plan.d.ts +1 -0
- package/dist/providers/zai.d.ts +1 -0
- package/dist/public.d.ts +2 -0
- package/dist/public.js +1 -0
- package/dist/route/embedding.d.ts +61 -0
- package/dist/route/embedding.js +88 -0
- package/package.json +305 -253
package/dist/providers/groq.d.ts
CHANGED
|
@@ -121,6 +121,7 @@ export declare const protocol: Protocol<{
|
|
|
121
121
|
readonly reasoning?: string | undefined;
|
|
122
122
|
readonly reasoning_text?: string | undefined;
|
|
123
123
|
readonly reasoning_details?: unknown;
|
|
124
|
+
readonly reasoning_opaque?: string | undefined;
|
|
124
125
|
})[];
|
|
125
126
|
readonly tools?: readonly ({
|
|
126
127
|
readonly type: "function";
|
|
@@ -209,6 +210,7 @@ export declare const protocol: Protocol<{
|
|
|
209
210
|
readonly reasoning?: string | null | undefined;
|
|
210
211
|
readonly reasoning_text?: string | null | undefined;
|
|
211
212
|
readonly reasoning_details?: unknown;
|
|
213
|
+
readonly reasoning_opaque?: string | null | undefined;
|
|
212
214
|
readonly tool_calls?: readonly {
|
|
213
215
|
readonly index?: number | null | undefined;
|
|
214
216
|
readonly id?: string | null | undefined;
|
|
@@ -234,6 +236,7 @@ export declare const protocol: Protocol<{
|
|
|
234
236
|
readonly prompt_cache_hit_tokens?: number | null | undefined;
|
|
235
237
|
readonly cache_read_input_tokens?: number | null | undefined;
|
|
236
238
|
readonly cache_created_input_tokens?: number | null | undefined;
|
|
239
|
+
readonly reasoning_tokens?: number | null | undefined;
|
|
237
240
|
readonly prompt_tokens_details?: {
|
|
238
241
|
readonly [x: string]: unknown;
|
|
239
242
|
readonly cached_tokens?: number | null | undefined;
|
|
@@ -256,6 +259,7 @@ export declare const protocol: Protocol<{
|
|
|
256
259
|
readonly prompt_cache_hit_tokens?: number | null | undefined;
|
|
257
260
|
readonly cache_read_input_tokens?: number | null | undefined;
|
|
258
261
|
readonly cache_created_input_tokens?: number | null | undefined;
|
|
262
|
+
readonly reasoning_tokens?: number | null | undefined;
|
|
259
263
|
readonly prompt_tokens_details?: {
|
|
260
264
|
readonly [x: string]: unknown;
|
|
261
265
|
readonly cached_tokens?: number | null | undefined;
|
|
@@ -374,6 +378,7 @@ export declare const route: Route<{
|
|
|
374
378
|
readonly reasoning?: string | undefined;
|
|
375
379
|
readonly reasoning_text?: string | undefined;
|
|
376
380
|
readonly reasoning_details?: unknown;
|
|
381
|
+
readonly reasoning_opaque?: string | undefined;
|
|
377
382
|
})[];
|
|
378
383
|
readonly tools?: readonly ({
|
|
379
384
|
readonly type: "function";
|
package/dist/providers/meta.d.ts
CHANGED
|
@@ -335,6 +335,7 @@ export declare const routes: (Route<{
|
|
|
335
335
|
readonly reasoning?: string | undefined;
|
|
336
336
|
readonly reasoning_text?: string | undefined;
|
|
337
337
|
readonly reasoning_details?: unknown;
|
|
338
|
+
readonly reasoning_opaque?: string | undefined;
|
|
338
339
|
})[];
|
|
339
340
|
readonly tools?: readonly ({
|
|
340
341
|
readonly type: "function";
|
|
@@ -639,6 +639,7 @@ export declare const routes: (Route<{
|
|
|
639
639
|
readonly reasoning?: string | undefined;
|
|
640
640
|
readonly reasoning_text?: string | undefined;
|
|
641
641
|
readonly reasoning_details?: unknown;
|
|
642
|
+
readonly reasoning_opaque?: string | undefined;
|
|
642
643
|
})[];
|
|
643
644
|
readonly tools?: readonly ({
|
|
644
645
|
readonly type: "function";
|
|
@@ -635,6 +635,7 @@ export declare const routes: (Route<{
|
|
|
635
635
|
readonly reasoning?: string | undefined;
|
|
636
636
|
readonly reasoning_text?: string | undefined;
|
|
637
637
|
readonly reasoning_details?: unknown;
|
|
638
|
+
readonly reasoning_opaque?: string | undefined;
|
|
638
639
|
})[];
|
|
639
640
|
readonly tools?: readonly ({
|
|
640
641
|
readonly type: "function";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { embeddingModel as model } from "../openai.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { embeddingModel as model } from "../openai-compatible.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
2
|
+
import { type OptionsInput as OpenAIEmbeddingOptionsInput } from "../protocols/openai-embeddings.js";
|
|
2
3
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
4
|
import type { ProviderPackage } from "../provider-package.js";
|
|
4
5
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
@@ -113,6 +114,7 @@ export declare const routes: import("../route.js").Route<{
|
|
|
113
114
|
readonly reasoning?: string | undefined;
|
|
114
115
|
readonly reasoning_text?: string | undefined;
|
|
115
116
|
readonly reasoning_details?: unknown;
|
|
117
|
+
readonly reasoning_opaque?: string | undefined;
|
|
116
118
|
})[];
|
|
117
119
|
readonly tools?: readonly ({
|
|
118
120
|
readonly type: "function";
|
|
@@ -191,6 +193,7 @@ export declare const configure: (input: Config) => {
|
|
|
191
193
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
192
194
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route.js").CompactionOperations | undefined>;
|
|
193
195
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
196
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
194
197
|
configure: typeof configure;
|
|
195
198
|
};
|
|
196
199
|
export declare const provider: {
|
|
@@ -199,4 +202,5 @@ export declare const provider: {
|
|
|
199
202
|
};
|
|
200
203
|
export declare const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
|
|
201
204
|
export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
205
|
+
export declare const embeddingModel: (modelID: string, settings: Settings) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
202
206
|
export * as OpenAICompatible from "./openai-compatible.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mergeProviderOptions, ProviderID, } from "../schema/index.js";
|
|
2
2
|
import { OpenAICompatibleChat } from "../protocols/openai-compatible-chat.js";
|
|
3
|
+
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
3
4
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
4
5
|
import { MediaRoute } from "../route/media.js";
|
|
5
6
|
import { AuthOptions } from "../route/auth-options.js";
|
|
@@ -17,6 +18,13 @@ export const configure = (input) => {
|
|
|
17
18
|
auth,
|
|
18
19
|
});
|
|
19
20
|
const media = MediaRoute.deployment(input, auth);
|
|
21
|
+
const embeddingRoute = OpenAIEmbeddings.route.with({
|
|
22
|
+
provider,
|
|
23
|
+
endpoint: { baseURL },
|
|
24
|
+
auth,
|
|
25
|
+
headers: input.headers,
|
|
26
|
+
http: input.http,
|
|
27
|
+
});
|
|
20
28
|
return {
|
|
21
29
|
id: ProviderID.make(provider),
|
|
22
30
|
model: (modelID) => route.model({ id: modelID }),
|
|
@@ -28,6 +36,7 @@ export const configure = (input) => {
|
|
|
28
36
|
provider,
|
|
29
37
|
providerOptions: mergeProviderOptions(/gpt-image|chatgpt-image/.test(modelID) ? undefined : { response_format: "b64_json" }, providerOptions),
|
|
30
38
|
}),
|
|
39
|
+
embedding: (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions }),
|
|
31
40
|
configure,
|
|
32
41
|
};
|
|
33
42
|
};
|
|
@@ -40,6 +49,10 @@ export const imageModel = (modelID, settings) => {
|
|
|
40
49
|
const input = config(settings);
|
|
41
50
|
return configure(input).image(modelID, input.providerOptions);
|
|
42
51
|
};
|
|
52
|
+
export const embeddingModel = (modelID, settings) => {
|
|
53
|
+
const input = config(settings);
|
|
54
|
+
return configure(input).embedding(modelID, input.providerOptions);
|
|
55
|
+
};
|
|
43
56
|
function config({ provider, ...settings }) {
|
|
44
57
|
return { ...toConfig(settings), provider };
|
|
45
58
|
}
|
|
@@ -5,11 +5,13 @@ import { ToolDefinition, type ModelID, type OpenString, type ProviderOptions, ty
|
|
|
5
5
|
import * as OpenAIResponses from "../protocols/openai-responses.js";
|
|
6
6
|
import { type OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
7
7
|
import { type OptionsInput as OpenAIDecisionOptionsInput } from "../protocols/openai-decisions.js";
|
|
8
|
+
import { type OptionsInput as OpenAIEmbeddingOptionsInput } from "../protocols/openai-embeddings.js";
|
|
8
9
|
export type { OpenAIOptionsInput, OpenAIResponseIncludable, OpenAIServiceTier } from "./openai-options.js";
|
|
9
10
|
export type { OpenAIImageOptions } from "../protocols/openai-images.js";
|
|
10
11
|
export type { OpenAISpeechOptions } from "../protocols/openai-speech.js";
|
|
11
12
|
export type { OpenAITranscriptionOptions } from "../protocols/openai-transcription.js";
|
|
12
13
|
export type { OptionsInput as OpenAIDecisionOptions } from "../protocols/openai-decisions.js";
|
|
14
|
+
export type { OptionsInput as OpenAIEmbeddingOptions } from "../protocols/openai-embeddings.js";
|
|
13
15
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
14
16
|
export declare const routes: (Route<{
|
|
15
17
|
readonly model: string;
|
|
@@ -111,6 +113,7 @@ export declare const routes: (Route<{
|
|
|
111
113
|
readonly reasoning?: string | undefined;
|
|
112
114
|
readonly reasoning_text?: string | undefined;
|
|
113
115
|
readonly reasoning_details?: unknown;
|
|
116
|
+
readonly reasoning_opaque?: string | undefined;
|
|
114
117
|
})[];
|
|
115
118
|
readonly tools?: readonly ({
|
|
116
119
|
readonly type: "function";
|
|
@@ -455,6 +458,7 @@ export declare const configure: (input?: Config) => {
|
|
|
455
458
|
speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/openai-speech.js").OpenAISpeechOptions>;
|
|
456
459
|
transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/openai-transcription.js").OpenAITranscriptionOptions>;
|
|
457
460
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenAIDecisionOptionsInput>;
|
|
461
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
458
462
|
configure: typeof configure;
|
|
459
463
|
};
|
|
460
464
|
export declare const provider: {
|
|
@@ -472,12 +476,14 @@ export declare const provider: {
|
|
|
472
476
|
speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/openai-speech.js").OpenAISpeechOptions>;
|
|
473
477
|
transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/openai-transcription.js").OpenAITranscriptionOptions>;
|
|
474
478
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenAIDecisionOptionsInput>;
|
|
479
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
475
480
|
configure: typeof configure;
|
|
476
481
|
};
|
|
477
482
|
export declare const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput, typeof OpenAIResponses.route.compact>;
|
|
478
483
|
export declare const chatModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
|
|
479
484
|
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
480
485
|
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<OpenAIDecisionOptionsInput>;
|
|
486
|
+
export declare const embeddingModel: (modelID: string, settings?: Settings) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
481
487
|
export declare const responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, {
|
|
482
488
|
endpoint: import("../route/client.js").CompactOperation;
|
|
483
489
|
trigger: import("../route/client.js").TriggerCompactOperation;
|
|
@@ -487,3 +493,4 @@ export declare const image: (modelID: string | ModelID, providerOptions?: Provid
|
|
|
487
493
|
export declare const speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/openai-speech.js").OpenAISpeechOptions>;
|
|
488
494
|
export declare const transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/openai-transcription.js").OpenAITranscriptionOptions>;
|
|
489
495
|
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenAIDecisionOptionsInput>;
|
|
496
|
+
export declare const embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
package/dist/providers/openai.js
CHANGED
|
@@ -8,6 +8,7 @@ import { OpenAIImages } from "../protocols/openai-images.js";
|
|
|
8
8
|
import { OpenAISpeech } from "../protocols/openai-speech.js";
|
|
9
9
|
import { OpenAITranscription } from "../protocols/openai-transcription.js";
|
|
10
10
|
import { OpenAIDecisions } from "../protocols/openai-decisions.js";
|
|
11
|
+
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
11
12
|
export const id = ProviderID.make("openai");
|
|
12
13
|
export const routes = [OpenAIResponses.route, OpenAIChat.route];
|
|
13
14
|
export const imageGeneration = (options = {}) => ToolDefinition.make({
|
|
@@ -63,6 +64,13 @@ export const configure = (input = {}) => {
|
|
|
63
64
|
http: media.http,
|
|
64
65
|
});
|
|
65
66
|
const decision = (modelID, providerOptions) => decisionRoute.model({ id: modelID, providerOptions });
|
|
67
|
+
const embeddingRoute = OpenAIEmbeddings.route.with({
|
|
68
|
+
endpoint: { baseURL: media.baseURL },
|
|
69
|
+
auth: media.auth,
|
|
70
|
+
headers: media.headers,
|
|
71
|
+
http: media.http,
|
|
72
|
+
});
|
|
73
|
+
const embedding = (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions });
|
|
66
74
|
return {
|
|
67
75
|
id,
|
|
68
76
|
model: responses,
|
|
@@ -72,6 +80,7 @@ export const configure = (input = {}) => {
|
|
|
72
80
|
speech,
|
|
73
81
|
transcription,
|
|
74
82
|
decision,
|
|
83
|
+
embedding,
|
|
75
84
|
configure,
|
|
76
85
|
};
|
|
77
86
|
};
|
|
@@ -103,9 +112,14 @@ export const decisionModel = (modelID, settings) => {
|
|
|
103
112
|
const input = config(settings);
|
|
104
113
|
return configure(input).decision(modelID, input.providerOptions);
|
|
105
114
|
};
|
|
115
|
+
export const embeddingModel = (modelID, settings) => {
|
|
116
|
+
const input = config(settings);
|
|
117
|
+
return configure(input).embedding(modelID, input.providerOptions);
|
|
118
|
+
};
|
|
106
119
|
export const responses = provider.responses;
|
|
107
120
|
export const chat = provider.chat;
|
|
108
121
|
export const image = provider.image;
|
|
109
122
|
export const speech = provider.speech;
|
|
110
123
|
export const transcription = provider.transcription;
|
|
111
124
|
export const decision = provider.decision;
|
|
125
|
+
export const embedding = provider.embedding;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { embeddingModel as model } from "../openrouter.js";
|
|
@@ -82,6 +82,11 @@ export interface OpenRouterDecisionOptions {
|
|
|
82
82
|
readonly trace?: Readonly<Record<string, unknown>>;
|
|
83
83
|
readonly user?: string;
|
|
84
84
|
}
|
|
85
|
+
export interface OpenRouterEmbeddingOptions {
|
|
86
|
+
readonly [key: string]: unknown;
|
|
87
|
+
readonly provider?: OpenRouterProviderRouting;
|
|
88
|
+
readonly user?: string;
|
|
89
|
+
}
|
|
85
90
|
export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
86
91
|
readonly baseURL?: string;
|
|
87
92
|
readonly providerOptions?: OpenRouterProviderOptionsInput | OpenRouterResponsesProviderOptionsInput;
|
|
@@ -178,6 +183,7 @@ declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
|
|
|
178
183
|
readonly reasoning: Schema.optional<Schema.String>;
|
|
179
184
|
readonly reasoning_text: Schema.optional<Schema.String>;
|
|
180
185
|
readonly reasoning_details: Schema.optional<Schema.Unknown>;
|
|
186
|
+
readonly reasoning_opaque: Schema.optional<Schema.String>;
|
|
181
187
|
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.Struct<{
|
|
182
188
|
readonly role: Schema.Literal<"tool">;
|
|
183
189
|
readonly tool_call_id: Schema.String;
|
|
@@ -368,6 +374,7 @@ export declare const protocol: Protocol<{
|
|
|
368
374
|
readonly reasoning?: string | undefined;
|
|
369
375
|
readonly reasoning_text?: string | undefined;
|
|
370
376
|
readonly reasoning_details?: unknown;
|
|
377
|
+
readonly reasoning_opaque?: string | undefined;
|
|
371
378
|
})[];
|
|
372
379
|
tools?: readonly ({
|
|
373
380
|
readonly type: "function";
|
|
@@ -471,6 +478,7 @@ export declare const protocol: Protocol<{
|
|
|
471
478
|
readonly reasoning?: string | null | undefined;
|
|
472
479
|
readonly reasoning_text?: string | null | undefined;
|
|
473
480
|
readonly reasoning_details?: unknown;
|
|
481
|
+
readonly reasoning_opaque?: string | null | undefined;
|
|
474
482
|
readonly tool_calls?: readonly {
|
|
475
483
|
readonly index?: number | null | undefined;
|
|
476
484
|
readonly id?: string | null | undefined;
|
|
@@ -496,6 +504,7 @@ export declare const protocol: Protocol<{
|
|
|
496
504
|
readonly prompt_cache_hit_tokens?: number | null | undefined;
|
|
497
505
|
readonly cache_read_input_tokens?: number | null | undefined;
|
|
498
506
|
readonly cache_created_input_tokens?: number | null | undefined;
|
|
507
|
+
readonly reasoning_tokens?: number | null | undefined;
|
|
499
508
|
readonly prompt_tokens_details?: {
|
|
500
509
|
readonly [x: string]: unknown;
|
|
501
510
|
readonly cached_tokens?: number | null | undefined;
|
|
@@ -518,6 +527,7 @@ export declare const protocol: Protocol<{
|
|
|
518
527
|
readonly prompt_cache_hit_tokens?: number | null | undefined;
|
|
519
528
|
readonly cache_read_input_tokens?: number | null | undefined;
|
|
520
529
|
readonly cache_created_input_tokens?: number | null | undefined;
|
|
530
|
+
readonly reasoning_tokens?: number | null | undefined;
|
|
521
531
|
readonly prompt_tokens_details?: {
|
|
522
532
|
readonly [x: string]: unknown;
|
|
523
533
|
readonly cached_tokens?: number | null | undefined;
|
|
@@ -636,6 +646,7 @@ export declare const route: Route<{
|
|
|
636
646
|
readonly reasoning?: string | undefined;
|
|
637
647
|
readonly reasoning_text?: string | undefined;
|
|
638
648
|
readonly reasoning_details?: unknown;
|
|
649
|
+
readonly reasoning_opaque?: string | undefined;
|
|
639
650
|
})[];
|
|
640
651
|
tools?: readonly ({
|
|
641
652
|
readonly type: "function";
|
|
@@ -1036,6 +1047,7 @@ export declare const routes: (Route<{
|
|
|
1036
1047
|
readonly reasoning?: string | undefined;
|
|
1037
1048
|
readonly reasoning_text?: string | undefined;
|
|
1038
1049
|
readonly reasoning_details?: unknown;
|
|
1050
|
+
readonly reasoning_opaque?: string | undefined;
|
|
1039
1051
|
})[];
|
|
1040
1052
|
tools?: readonly ({
|
|
1041
1053
|
readonly type: "function";
|
|
@@ -1135,6 +1147,7 @@ export declare const configure: (input?: Config) => {
|
|
|
1135
1147
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1136
1148
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1137
1149
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1150
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1138
1151
|
configure: typeof configure;
|
|
1139
1152
|
};
|
|
1140
1153
|
export declare const provider: {
|
|
@@ -1144,9 +1157,11 @@ export declare const provider: {
|
|
|
1144
1157
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1145
1158
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1146
1159
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1160
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1147
1161
|
configure: typeof configure;
|
|
1148
1162
|
};
|
|
1149
1163
|
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1164
|
+
export declare const embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1150
1165
|
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1151
1166
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1152
1167
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
@@ -1154,4 +1169,5 @@ export declare const model: ProviderPackage.Model<Settings, OpenRouterProviderOp
|
|
|
1154
1169
|
export declare const responsesModel: ProviderPackage.Model<Settings<OpenRouterResponsesProviderOptionsInput>, OpenRouterResponsesProviderOptionsInput>;
|
|
1155
1170
|
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1156
1171
|
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1172
|
+
export declare const embeddingModel: (modelID: string, settings?: Settings) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1157
1173
|
export * as OpenRouter from "./openrouter.js";
|
|
@@ -4,6 +4,7 @@ import { Endpoint } from "../route/endpoint.js";
|
|
|
4
4
|
import { Protocol } from "../route/protocol.js";
|
|
5
5
|
import { ProviderID, } from "../schema/index.js";
|
|
6
6
|
import { SystemOne } from "../protocols/system-one.js";
|
|
7
|
+
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
7
8
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
8
9
|
import { MediaRoute } from "../route/media.js";
|
|
9
10
|
import { HttpTransport } from "../route/transport/index.js";
|
|
@@ -159,6 +160,14 @@ export const configure = (input = {}) => {
|
|
|
159
160
|
compatibility: { mediaInput: "state" },
|
|
160
161
|
providerOptions,
|
|
161
162
|
});
|
|
163
|
+
const embeddingRoute = OpenAIEmbeddings.route.with({
|
|
164
|
+
provider: id,
|
|
165
|
+
endpoint: options.endpoint,
|
|
166
|
+
auth: options.auth,
|
|
167
|
+
headers: input.headers,
|
|
168
|
+
http: input.http,
|
|
169
|
+
});
|
|
170
|
+
const embedding = (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions });
|
|
162
171
|
const chat = (modelID) => chatRoute.model({ id: modelID, capabilities: { promptCacheKey: true } });
|
|
163
172
|
return {
|
|
164
173
|
id,
|
|
@@ -167,11 +176,13 @@ export const configure = (input = {}) => {
|
|
|
167
176
|
responses: (modelID) => configuredResponses.model({ id: modelID }),
|
|
168
177
|
image,
|
|
169
178
|
decision,
|
|
179
|
+
embedding,
|
|
170
180
|
configure,
|
|
171
181
|
};
|
|
172
182
|
};
|
|
173
183
|
export const provider = configure();
|
|
174
184
|
export const decision = provider.decision;
|
|
185
|
+
export const embedding = provider.embedding;
|
|
175
186
|
export const image = provider.image;
|
|
176
187
|
export const chat = provider.chat;
|
|
177
188
|
export const responses = provider.responses;
|
|
@@ -185,4 +196,8 @@ export const decisionModel = (modelID, settings) => {
|
|
|
185
196
|
const input = toConfig(settings);
|
|
186
197
|
return configure(input).decision(modelID, input.providerOptions);
|
|
187
198
|
};
|
|
199
|
+
export const embeddingModel = (modelID, settings) => {
|
|
200
|
+
const input = toConfig(settings);
|
|
201
|
+
return configure(input).embedding(modelID, input.providerOptions);
|
|
202
|
+
};
|
|
188
203
|
export * as OpenRouter from "./openrouter.js";
|
|
@@ -112,6 +112,7 @@ export declare const route: Route<{
|
|
|
112
112
|
readonly reasoning?: string | undefined;
|
|
113
113
|
readonly reasoning_text?: string | undefined;
|
|
114
114
|
readonly reasoning_details?: unknown;
|
|
115
|
+
readonly reasoning_opaque?: string | undefined;
|
|
115
116
|
})[];
|
|
116
117
|
readonly tools?: readonly ({
|
|
117
118
|
readonly type: "function";
|
|
@@ -286,6 +287,7 @@ export declare const routes: Route<{
|
|
|
286
287
|
readonly reasoning?: string | undefined;
|
|
287
288
|
readonly reasoning_text?: string | undefined;
|
|
288
289
|
readonly reasoning_details?: unknown;
|
|
290
|
+
readonly reasoning_opaque?: string | undefined;
|
|
289
291
|
})[];
|
|
290
292
|
readonly tools?: readonly ({
|
|
291
293
|
readonly type: "function";
|
|
@@ -363,6 +363,7 @@ export declare const routes: (Route<{
|
|
|
363
363
|
readonly reasoning?: string | undefined;
|
|
364
364
|
readonly reasoning_text?: string | undefined;
|
|
365
365
|
readonly reasoning_details?: unknown;
|
|
366
|
+
readonly reasoning_opaque?: string | undefined;
|
|
366
367
|
readonly tool_calls?: readonly ({
|
|
367
368
|
readonly id: string;
|
|
368
369
|
readonly type: "custom";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { embeddingModel as model } from "../vercel-ai-gateway.js";
|
|
@@ -81,6 +81,7 @@ export declare const configure: (input?: Config) => {
|
|
|
81
81
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
82
82
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
83
83
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
84
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
|
|
84
85
|
configure: typeof configure;
|
|
85
86
|
};
|
|
86
87
|
export declare const provider: {
|
|
@@ -91,9 +92,11 @@ export declare const provider: {
|
|
|
91
92
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
92
93
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
93
94
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
95
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
|
|
94
96
|
configure: typeof configure;
|
|
95
97
|
};
|
|
96
98
|
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
99
|
+
export declare const embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
|
|
97
100
|
export declare const messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
98
101
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
99
102
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
@@ -104,4 +107,5 @@ export declare const responsesModel: ProviderPackage.Model<Settings, ProviderOpt
|
|
|
104
107
|
export declare const chatModel: ProviderPackage.Model<Settings, ProviderOptionsInput>;
|
|
105
108
|
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
106
109
|
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
110
|
+
export declare const embeddingModel: (modelID: string, settings?: Settings) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
|
|
107
111
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
|
@@ -3,6 +3,7 @@ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
|
3
3
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
4
4
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
5
5
|
import { OpenAIDecisions } from "../protocols/openai-decisions.js";
|
|
6
|
+
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
6
7
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
7
8
|
import { XAIImages } from "../protocols/xai-images.js";
|
|
8
9
|
import { ProviderShared } from "../protocols/shared.js";
|
|
@@ -146,10 +147,19 @@ export const configure = (input = {}) => {
|
|
|
146
147
|
http: input.http,
|
|
147
148
|
});
|
|
148
149
|
const decision = (modelID, providerOptions) => decisionRoute.model({ id: modelID, providerOptions });
|
|
149
|
-
|
|
150
|
+
const embeddingRoute = OpenAIEmbeddings.route.with({
|
|
151
|
+
provider: id,
|
|
152
|
+
endpoint: { baseURL: configured.endpoint.baseURL },
|
|
153
|
+
auth: configured.auth,
|
|
154
|
+
headers: input.headers,
|
|
155
|
+
http: input.http,
|
|
156
|
+
});
|
|
157
|
+
const embedding = (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions });
|
|
158
|
+
return { id, model, messages, responses, chat, image, decision, embedding, configure };
|
|
150
159
|
};
|
|
151
160
|
export const provider = configure();
|
|
152
161
|
export const decision = provider.decision;
|
|
162
|
+
export const embedding = provider.embedding;
|
|
153
163
|
export const messages = provider.messages;
|
|
154
164
|
export const responses = provider.responses;
|
|
155
165
|
export const chat = provider.chat;
|
|
@@ -166,4 +176,8 @@ export const decisionModel = (modelID, settings) => {
|
|
|
166
176
|
const input = toConfig(settings);
|
|
167
177
|
return configure(input).decision(modelID, input.providerOptions);
|
|
168
178
|
};
|
|
179
|
+
export const embeddingModel = (modelID, settings) => {
|
|
180
|
+
const input = toConfig(settings);
|
|
181
|
+
return configure(input).embedding(modelID, input.providerOptions);
|
|
182
|
+
};
|
|
169
183
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
package/dist/providers/xai.d.ts
CHANGED
|
@@ -123,6 +123,7 @@ export declare const routes: (Route<unknown, import("../protocols/open-responses
|
|
|
123
123
|
readonly reasoning?: string | undefined;
|
|
124
124
|
readonly reasoning_text?: string | undefined;
|
|
125
125
|
readonly reasoning_details?: unknown;
|
|
126
|
+
readonly reasoning_opaque?: string | undefined;
|
|
126
127
|
})[];
|
|
127
128
|
readonly tools?: readonly ({
|
|
128
129
|
readonly type: "function";
|
|
@@ -316,6 +316,7 @@ export declare const routes: (Route<{
|
|
|
316
316
|
readonly reasoning?: string | undefined;
|
|
317
317
|
readonly reasoning_text?: string | undefined;
|
|
318
318
|
readonly reasoning_details?: unknown;
|
|
319
|
+
readonly reasoning_opaque?: string | undefined;
|
|
319
320
|
})[];
|
|
320
321
|
readonly tools?: readonly ({
|
|
321
322
|
readonly type: "function";
|
package/dist/providers/zai.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ export declare const routes: Route<{
|
|
|
114
114
|
readonly reasoning?: string | undefined;
|
|
115
115
|
readonly reasoning_text?: string | undefined;
|
|
116
116
|
readonly reasoning_details?: unknown;
|
|
117
|
+
readonly reasoning_opaque?: string | undefined;
|
|
117
118
|
})[];
|
|
118
119
|
readonly tools?: readonly ({
|
|
119
120
|
readonly type: "function";
|
package/dist/public.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageRespon
|
|
|
5
5
|
export type { ImageModelOptions, ImageOptions, ImageRequest, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
|
|
6
6
|
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
7
7
|
export type { AnswerFor, AnswersFor, DecisionInput, DecisionMediaPartInput, DecisionModelOptions, DecisionOptions, DecisionPartInput, DecisionQuestions, DecisionRequest, DecisionRequestInput, DecisionResponseFor, DecisionModelRoute, } from "./decision.js";
|
|
8
|
+
export { EmbeddingModel, EmbeddingModelSchema, EmbeddingResponse, EmbeddingUsage, EmbeddingValue } from "./embedding.js";
|
|
9
|
+
export type { EmbeddingInputType, EmbeddingModelOptions, EmbeddingModelRoute, EmbeddingOptions, EmbeddingRequest, EmbeddingRequestInput, EmbeddingValueInput, } from "./embedding.js";
|
|
8
10
|
export { Media } from "./media.js";
|
|
9
11
|
export type { AwaitOptions as GenerationAwaitOptions, Event as GenerationEvent, Poll, Route as GenerationRoute, Snapshot as GenerationSnapshot, Status as GenerationStatus, } from "./generation.js";
|
|
10
12
|
export type { ExecutableTool, Tool, ToolExecute, ToolExecuteContext, ToolInput, ToolInputType, ToolModelOutputInput, ToolOptions, ToolSchema, ToolToModelOutput, } from "./tool.js";
|
package/dist/public.js
CHANGED
|
@@ -2,4 +2,5 @@ export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./prov
|
|
|
2
2
|
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, GENERATION_KEYS, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, SystemMessage, UserMessage, AssistantMessage, ToolMessage, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
3
3
|
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
4
4
|
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
5
|
+
export { EmbeddingModel, EmbeddingModelSchema, EmbeddingResponse, EmbeddingUsage, EmbeddingValue } from "./embedding.js";
|
|
5
6
|
export { Media } from "./media.js";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { HttpClientResponse } from "effect/http";
|
|
3
|
+
import { EmbeddingModel, EmbeddingResponse, type EmbeddingOptions, type EmbeddingRequest } from "../embedding.js";
|
|
4
|
+
import { ProviderID, type HttpOptions, type AIError, type ProviderOptions } from "../schema/index.js";
|
|
5
|
+
import { Auth } from "./auth.js";
|
|
6
|
+
import { Endpoint } from "./endpoint.js";
|
|
7
|
+
import { MediaProtocol } from "./media-protocol.js";
|
|
8
|
+
/** One embedding API: how a request becomes its JSON body and how its response becomes an `EmbeddingResponse`. */
|
|
9
|
+
export interface Protocol {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly body: {
|
|
13
|
+
readonly from: (request: EmbeddingRequest) => Effect.Effect<Record<string, unknown>, AIError>;
|
|
14
|
+
};
|
|
15
|
+
readonly response: {
|
|
16
|
+
readonly decode: (response: HttpClientResponse.HttpClientResponse, context: {
|
|
17
|
+
readonly request: EmbeddingRequest;
|
|
18
|
+
readonly providerMetadataKey: string;
|
|
19
|
+
}) => Effect.Effect<EmbeddingResponse, AIError>;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare const protocol: (input: Protocol) => Protocol;
|
|
23
|
+
export interface Patch {
|
|
24
|
+
readonly id?: string;
|
|
25
|
+
readonly provider?: string | ProviderID;
|
|
26
|
+
/** ProviderMetadata namespace for responses; defaults to the provider. */
|
|
27
|
+
readonly providerMetadataKey?: string;
|
|
28
|
+
readonly endpoint?: Endpoint.EndpointPatch<MediaProtocol.Body, EmbeddingRequest>;
|
|
29
|
+
readonly auth?: Auth.Definition;
|
|
30
|
+
readonly headers?: Record<string, string>;
|
|
31
|
+
readonly http?: HttpOptions;
|
|
32
|
+
/**
|
|
33
|
+
* Most values one HTTP request may carry. Longer requests are split into requests of this size, sent a few at a
|
|
34
|
+
* time, and joined back in value order.
|
|
35
|
+
*/
|
|
36
|
+
readonly maxValues?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface Route {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly provider: ProviderID;
|
|
41
|
+
readonly providerMetadataKey: string;
|
|
42
|
+
readonly protocol: Protocol;
|
|
43
|
+
readonly endpoint: Endpoint.Definition<MediaProtocol.Body, EmbeddingRequest>;
|
|
44
|
+
readonly auth: Auth.Definition;
|
|
45
|
+
readonly headers?: Record<string, string>;
|
|
46
|
+
readonly http?: HttpOptions;
|
|
47
|
+
readonly maxValues?: number;
|
|
48
|
+
readonly with: (patch: Patch) => Route;
|
|
49
|
+
readonly model: <Options extends EmbeddingOptions = EmbeddingOptions>(input: {
|
|
50
|
+
readonly id: string;
|
|
51
|
+
readonly providerOptions?: ProviderOptions;
|
|
52
|
+
}) => EmbeddingModel<Options>;
|
|
53
|
+
}
|
|
54
|
+
export interface MakeInput extends Omit<Patch, "endpoint"> {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly provider: string | ProviderID;
|
|
57
|
+
readonly protocol: Protocol;
|
|
58
|
+
readonly endpoint: Endpoint.Definition<MediaProtocol.Body, EmbeddingRequest>;
|
|
59
|
+
}
|
|
60
|
+
export declare const make: (input: MakeInput) => Route;
|
|
61
|
+
export * as EmbeddingRoute from "./embedding.js";
|