@opencode-ai/ai 0.0.0-beta-17492
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 +392 -0
- package/dist/cache-policy.d.ts +2 -0
- package/dist/cache-policy.js +121 -0
- package/dist/image-client.d.ts +19 -0
- package/dist/image-client.js +19 -0
- package/dist/image.d.ts +110 -0
- package/dist/image.js +102 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +12 -0
- package/dist/llm.d.ts +230 -0
- package/dist/llm.js +77 -0
- package/dist/protocols/anthropic-messages.d.ts +633 -0
- package/dist/protocols/anthropic-messages.js +860 -0
- package/dist/protocols/bedrock-converse.d.ts +533 -0
- package/dist/protocols/bedrock-converse.js +584 -0
- package/dist/protocols/bedrock-event-stream.d.ts +9 -0
- package/dist/protocols/bedrock-event-stream.js +73 -0
- package/dist/protocols/gemini.d.ts +300 -0
- package/dist/protocols/gemini.js +512 -0
- package/dist/protocols/google-images.d.ts +30 -0
- package/dist/protocols/google-images.js +191 -0
- package/dist/protocols/index.d.ts +10 -0
- package/dist/protocols/index.js +10 -0
- package/dist/protocols/open-responses-channel.d.ts +26 -0
- package/dist/protocols/open-responses-channel.js +120 -0
- package/dist/protocols/open-responses.d.ts +951 -0
- package/dist/protocols/open-responses.js +873 -0
- package/dist/protocols/openai-chat.d.ts +795 -0
- package/dist/protocols/openai-chat.js +718 -0
- package/dist/protocols/openai-compatible-chat.d.ts +107 -0
- package/dist/protocols/openai-compatible-chat.js +20 -0
- package/dist/protocols/openai-compatible-responses.d.ts +96 -0
- package/dist/protocols/openai-compatible-responses.js +17 -0
- package/dist/protocols/openai-images.d.ts +32 -0
- package/dist/protocols/openai-images.js +188 -0
- package/dist/protocols/openai-responses-channel.d.ts +12 -0
- package/dist/protocols/openai-responses-channel.js +142 -0
- package/dist/protocols/openai-responses.d.ts +596 -0
- package/dist/protocols/openai-responses.js +208 -0
- package/dist/protocols/shared.d.ts +194 -0
- package/dist/protocols/shared.js +238 -0
- package/dist/protocols/utils/bedrock-auth.d.ts +21 -0
- package/dist/protocols/utils/bedrock-auth.js +43 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +15 -0
- package/dist/protocols/utils/bedrock-cache.js +29 -0
- package/dist/protocols/utils/bedrock-media.d.ts +49 -0
- package/dist/protocols/utils/bedrock-media.js +70 -0
- package/dist/protocols/utils/cache.d.ts +6 -0
- package/dist/protocols/utils/cache.js +8 -0
- package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
- package/dist/protocols/utils/gemini-tool-schema.js +103 -0
- package/dist/protocols/utils/image-input.d.ts +21 -0
- package/dist/protocols/utils/image-input.js +22 -0
- package/dist/protocols/utils/lifecycle.d.ts +20 -0
- package/dist/protocols/utils/lifecycle.js +68 -0
- package/dist/protocols/utils/open-responses-options.d.ts +21 -0
- package/dist/protocols/utils/open-responses-options.js +41 -0
- package/dist/protocols/utils/openai-image.d.ts +5 -0
- package/dist/protocols/utils/openai-image.js +18 -0
- package/dist/protocols/utils/openai-options.d.ts +14 -0
- package/dist/protocols/utils/openai-options.js +14 -0
- package/dist/protocols/utils/tool-schema.d.ts +8 -0
- package/dist/protocols/utils/tool-schema.js +81 -0
- package/dist/protocols/utils/tool-stream.d.ts +639 -0
- package/dist/protocols/utils/tool-stream.js +141 -0
- package/dist/protocols/xai-images.d.ts +26 -0
- package/dist/protocols/xai-images.js +111 -0
- package/dist/protocols/zai-images.d.ts +22 -0
- package/dist/protocols/zai-images.js +84 -0
- package/dist/protocols.d.ts +1 -0
- package/dist/protocols.js +1 -0
- package/dist/provider-error.d.ts +14 -0
- package/dist/provider-error.js +130 -0
- package/dist/provider-package.d.ts +15 -0
- package/dist/provider-package.js +1 -0
- package/dist/provider.d.ts +23 -0
- package/dist/provider.js +2 -0
- package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
- package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
- package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle.js +1 -0
- package/dist/providers/amazon-bedrock-mantle.d.ts +247 -0
- package/dist/providers/amazon-bedrock-mantle.js +68 -0
- package/dist/providers/amazon-bedrock.d.ts +172 -0
- package/dist/providers/amazon-bedrock.js +41 -0
- package/dist/providers/anthropic-compatible.d.ts +218 -0
- package/dist/providers/anthropic-compatible.js +45 -0
- package/dist/providers/anthropic.d.ts +216 -0
- package/dist/providers/anthropic.js +40 -0
- package/dist/providers/azure/chat.d.ts +2 -0
- package/dist/providers/azure/chat.js +1 -0
- package/dist/providers/azure/responses.d.ts +2 -0
- package/dist/providers/azure/responses.js +1 -0
- package/dist/providers/azure.d.ts +248 -0
- package/dist/providers/azure.js +90 -0
- package/dist/providers/cloudflare.d.ts +338 -0
- package/dist/providers/cloudflare.js +87 -0
- package/dist/providers/google-vertex/chat.d.ts +2 -0
- package/dist/providers/google-vertex/chat.js +1 -0
- package/dist/providers/google-vertex/gemini.d.ts +2 -0
- package/dist/providers/google-vertex/gemini.js +1 -0
- package/dist/providers/google-vertex/messages.d.ts +2 -0
- package/dist/providers/google-vertex/messages.js +1 -0
- package/dist/providers/google-vertex/responses.d.ts +2 -0
- package/dist/providers/google-vertex/responses.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +131 -0
- package/dist/providers/google-vertex-chat.js +50 -0
- package/dist/providers/google-vertex-messages.d.ts +215 -0
- package/dist/providers/google-vertex-messages.js +75 -0
- package/dist/providers/google-vertex-responses.d.ts +122 -0
- package/dist/providers/google-vertex-responses.js +51 -0
- package/dist/providers/google-vertex-shared.d.ts +22 -0
- package/dist/providers/google-vertex-shared.js +61 -0
- package/dist/providers/google-vertex.d.ts +115 -0
- package/dist/providers/google-vertex.js +64 -0
- package/dist/providers/google.d.ts +112 -0
- package/dist/providers/google.js +43 -0
- package/dist/providers/index.d.ts +18 -0
- package/dist/providers/index.js +18 -0
- package/dist/providers/open-responses-options.d.ts +16 -0
- package/dist/providers/open-responses-options.js +1 -0
- package/dist/providers/openai/chat.d.ts +2 -0
- package/dist/providers/openai/chat.js +1 -0
- package/dist/providers/openai/responses.d.ts +2 -0
- package/dist/providers/openai/responses.js +1 -0
- package/dist/providers/openai-compatible/responses.d.ts +1 -0
- package/dist/providers/openai-compatible/responses.js +1 -0
- package/dist/providers/openai-compatible-profile.d.ts +43 -0
- package/dist/providers/openai-compatible-profile.js +12 -0
- package/dist/providers/openai-compatible-responses.d.ts +120 -0
- package/dist/providers/openai-compatible-responses.js +33 -0
- package/dist/providers/openai-compatible.d.ts +167 -0
- package/dist/providers/openai-compatible.js +55 -0
- package/dist/providers/openai-options.d.ts +21 -0
- package/dist/providers/openai-options.js +41 -0
- package/dist/providers/openai.d.ts +264 -0
- package/dist/providers/openai.js +83 -0
- package/dist/providers/openrouter.d.ts +537 -0
- package/dist/providers/openrouter.js +117 -0
- package/dist/providers/xai.d.ts +249 -0
- package/dist/providers/xai.js +79 -0
- package/dist/providers/zai.d.ts +24 -0
- package/dist/providers/zai.js +21 -0
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +1 -0
- package/dist/route/auth-options.d.ts +34 -0
- package/dist/route/auth-options.js +14 -0
- package/dist/route/auth.d.ts +51 -0
- package/dist/route/auth.js +89 -0
- package/dist/route/client.d.ts +348 -0
- package/dist/route/client.js +214 -0
- package/dist/route/endpoint.d.ts +28 -0
- package/dist/route/endpoint.js +21 -0
- package/dist/route/executor.d.ts +23 -0
- package/dist/route/executor.js +227 -0
- package/dist/route/framing.d.ts +23 -0
- package/dist/route/framing.js +4 -0
- package/dist/route/index.d.ts +16 -0
- package/dist/route/index.js +9 -0
- package/dist/route/protocol.d.ts +77 -0
- package/dist/route/protocol.js +17 -0
- package/dist/route/transport/http.d.ts +34 -0
- package/dist/route/transport/http.js +63 -0
- package/dist/route/transport/index.d.ts +39 -0
- package/dist/route/transport/index.js +4 -0
- package/dist/route/transport/websocket-channel.d.ts +56 -0
- package/dist/route/transport/websocket-channel.js +1 -0
- package/dist/route/transport/websocket.d.ts +55 -0
- package/dist/route/transport/websocket.js +326 -0
- package/dist/route.d.ts +1 -0
- package/dist/route.js +1 -0
- package/dist/schema/errors.d.ts +159 -0
- package/dist/schema/errors.js +155 -0
- package/dist/schema/events.d.ts +4587 -0
- package/dist/schema/events.js +492 -0
- package/dist/schema/ids.d.ts +30 -0
- package/dist/schema/ids.js +19 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +5 -0
- package/dist/schema/messages.d.ts +402 -0
- package/dist/schema/messages.js +244 -0
- package/dist/schema/options.d.ts +159 -0
- package/dist/schema/options.js +202 -0
- package/dist/testing.d.ts +1493 -0
- package/dist/testing.js +88 -0
- package/dist/tool-runtime.d.ts +15 -0
- package/dist/tool-runtime.js +54 -0
- package/dist/tool.d.ts +135 -0
- package/dist/tool.js +66 -0
- package/dist/utils/record.d.ts +2 -0
- package/dist/utils/record.js +2 -0
- package/package.json +47 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../openai-compatible-responses.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../openai-compatible-responses.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface OpenAICompatibleProfile {
|
|
2
|
+
readonly provider: string;
|
|
3
|
+
readonly baseURL: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const profiles: {
|
|
6
|
+
readonly baseten: {
|
|
7
|
+
readonly provider: "baseten";
|
|
8
|
+
readonly baseURL: "https://inference.baseten.co/v1";
|
|
9
|
+
};
|
|
10
|
+
readonly cerebras: {
|
|
11
|
+
readonly provider: "cerebras";
|
|
12
|
+
readonly baseURL: "https://api.cerebras.ai/v1";
|
|
13
|
+
};
|
|
14
|
+
readonly deepinfra: {
|
|
15
|
+
readonly provider: "deepinfra";
|
|
16
|
+
readonly baseURL: "https://api.deepinfra.com/v1/openai";
|
|
17
|
+
};
|
|
18
|
+
readonly deepseek: {
|
|
19
|
+
readonly provider: "deepseek";
|
|
20
|
+
readonly baseURL: "https://api.deepseek.com/v1";
|
|
21
|
+
};
|
|
22
|
+
readonly fireworks: {
|
|
23
|
+
readonly provider: "fireworks";
|
|
24
|
+
readonly baseURL: "https://api.fireworks.ai/inference/v1";
|
|
25
|
+
};
|
|
26
|
+
readonly groq: {
|
|
27
|
+
readonly provider: "groq";
|
|
28
|
+
readonly baseURL: "https://api.groq.com/openai/v1";
|
|
29
|
+
};
|
|
30
|
+
readonly openrouter: {
|
|
31
|
+
readonly provider: "openrouter";
|
|
32
|
+
readonly baseURL: "https://openrouter.ai/api/v1";
|
|
33
|
+
};
|
|
34
|
+
readonly togetherai: {
|
|
35
|
+
readonly provider: "togetherai";
|
|
36
|
+
readonly baseURL: "https://api.together.xyz/v1";
|
|
37
|
+
};
|
|
38
|
+
readonly xai: {
|
|
39
|
+
readonly provider: "xai";
|
|
40
|
+
readonly baseURL: "https://api.x.ai/v1";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare const byProvider: Record<string, OpenAICompatibleProfile>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const profiles = {
|
|
2
|
+
baseten: { provider: "baseten", baseURL: "https://inference.baseten.co/v1" },
|
|
3
|
+
cerebras: { provider: "cerebras", baseURL: "https://api.cerebras.ai/v1" },
|
|
4
|
+
deepinfra: { provider: "deepinfra", baseURL: "https://api.deepinfra.com/v1/openai" },
|
|
5
|
+
deepseek: { provider: "deepseek", baseURL: "https://api.deepseek.com/v1" },
|
|
6
|
+
fireworks: { provider: "fireworks", baseURL: "https://api.fireworks.ai/inference/v1" },
|
|
7
|
+
groq: { provider: "groq", baseURL: "https://api.groq.com/openai/v1" },
|
|
8
|
+
openrouter: { provider: "openrouter", baseURL: "https://openrouter.ai/api/v1" },
|
|
9
|
+
togetherai: { provider: "togetherai", baseURL: "https://api.together.xyz/v1" },
|
|
10
|
+
xai: { provider: "xai", baseURL: "https://api.x.ai/v1" },
|
|
11
|
+
};
|
|
12
|
+
export const byProvider = Object.fromEntries(Object.values(profiles).map((profile) => [profile.provider, profile]));
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
|
+
import type { RouteDefaultsInput } from "../route/client.js";
|
|
4
|
+
import { type ModelID } from "../schema/index.js";
|
|
5
|
+
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
6
|
+
export type { OpenResponsesOptionsInput, OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
7
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
8
|
+
export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
9
|
+
readonly provider?: string;
|
|
10
|
+
readonly baseURL: string;
|
|
11
|
+
readonly providerOptions?: OpenResponsesProviderOptionsInput;
|
|
12
|
+
};
|
|
13
|
+
export interface Settings extends ProviderPackage.Settings {
|
|
14
|
+
readonly apiKey?: string;
|
|
15
|
+
readonly baseURL: string;
|
|
16
|
+
readonly provider?: string;
|
|
17
|
+
readonly providerOptions?: OpenResponsesProviderOptionsInput;
|
|
18
|
+
}
|
|
19
|
+
export declare const routes: import("../route/client.js").Route<{
|
|
20
|
+
readonly input: readonly ({
|
|
21
|
+
readonly type: "reasoning";
|
|
22
|
+
readonly summary: readonly {
|
|
23
|
+
readonly type: "summary_text";
|
|
24
|
+
readonly text: string;
|
|
25
|
+
}[];
|
|
26
|
+
readonly id?: string | undefined;
|
|
27
|
+
readonly encrypted_content?: string | null | undefined;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: "item_reference";
|
|
30
|
+
readonly id: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly role: "system";
|
|
33
|
+
readonly content: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly role: "user";
|
|
36
|
+
readonly content: readonly ({
|
|
37
|
+
readonly type: "input_image";
|
|
38
|
+
readonly image_url: string;
|
|
39
|
+
} | {
|
|
40
|
+
readonly type: "input_file";
|
|
41
|
+
readonly filename: string;
|
|
42
|
+
readonly file_data: string;
|
|
43
|
+
readonly mime_type?: string | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: "input_text";
|
|
46
|
+
readonly text: string;
|
|
47
|
+
})[];
|
|
48
|
+
} | {
|
|
49
|
+
readonly content: readonly {
|
|
50
|
+
readonly type: "output_text";
|
|
51
|
+
readonly text: string;
|
|
52
|
+
}[];
|
|
53
|
+
readonly role: "assistant";
|
|
54
|
+
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
55
|
+
} | {
|
|
56
|
+
readonly type: "function_call";
|
|
57
|
+
readonly call_id: string;
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly arguments: string;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: "function_call_output";
|
|
62
|
+
readonly call_id: string;
|
|
63
|
+
readonly output: string | readonly ({
|
|
64
|
+
readonly type: "input_image";
|
|
65
|
+
readonly image_url: string;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: "input_file";
|
|
68
|
+
readonly filename: string;
|
|
69
|
+
readonly file_data: string;
|
|
70
|
+
readonly mime_type?: string | undefined;
|
|
71
|
+
} | {
|
|
72
|
+
readonly type: "input_text";
|
|
73
|
+
readonly text: string;
|
|
74
|
+
})[];
|
|
75
|
+
})[];
|
|
76
|
+
readonly model: string;
|
|
77
|
+
readonly stream: true;
|
|
78
|
+
readonly instructions?: string | undefined;
|
|
79
|
+
readonly reasoning?: {
|
|
80
|
+
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
81
|
+
readonly effort?: string | undefined;
|
|
82
|
+
} | undefined;
|
|
83
|
+
readonly tools?: readonly {
|
|
84
|
+
readonly type: "function";
|
|
85
|
+
readonly description: string;
|
|
86
|
+
readonly name: string;
|
|
87
|
+
readonly parameters: {
|
|
88
|
+
readonly [x: string]: unknown;
|
|
89
|
+
};
|
|
90
|
+
readonly strict?: boolean | undefined;
|
|
91
|
+
}[] | undefined;
|
|
92
|
+
readonly text?: {
|
|
93
|
+
readonly verbosity?: "low" | "medium" | "high" | undefined;
|
|
94
|
+
} | undefined;
|
|
95
|
+
readonly temperature?: number | undefined;
|
|
96
|
+
readonly tool_choice?: "required" | "none" | "auto" | {
|
|
97
|
+
readonly type: "function";
|
|
98
|
+
readonly name: string;
|
|
99
|
+
} | undefined;
|
|
100
|
+
readonly top_p?: number | undefined;
|
|
101
|
+
readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
|
|
102
|
+
readonly store?: boolean | undefined;
|
|
103
|
+
readonly prompt_cache_key?: string | undefined;
|
|
104
|
+
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
|
|
105
|
+
readonly max_output_tokens?: number | undefined;
|
|
106
|
+
}, import("../route/transport/http.js").HttpPrepared<string>>[];
|
|
107
|
+
export declare const configure: (input: Config) => {
|
|
108
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
109
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenResponsesProviderOptionsInput>;
|
|
110
|
+
configure: (input: Config) => /*elided*/ any;
|
|
111
|
+
};
|
|
112
|
+
export declare const provider: {
|
|
113
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
114
|
+
configure: (input: Config) => {
|
|
115
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
116
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenResponsesProviderOptionsInput>;
|
|
117
|
+
configure: /*elided*/ any;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export declare const model: ProviderPackage.Definition<Settings, OpenResponsesProviderOptionsInput>["model"];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OpenAICompatibleResponses } from "../protocols/openai-compatible-responses.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
3
|
+
import { ProviderID } from "../schema/index.js";
|
|
4
|
+
export const id = ProviderID.make("openai-compatible");
|
|
5
|
+
export const routes = [OpenAICompatibleResponses.route];
|
|
6
|
+
export const configure = (input) => {
|
|
7
|
+
const provider = input.provider ?? "openai-compatible";
|
|
8
|
+
const { provider: _, baseURL, apiKey: _apiKey, auth: _auth, ...rest } = input;
|
|
9
|
+
const route = OpenAICompatibleResponses.route.with({
|
|
10
|
+
...rest,
|
|
11
|
+
provider,
|
|
12
|
+
endpoint: { baseURL },
|
|
13
|
+
auth: AuthOptions.bearer(input, []),
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
id: ProviderID.make(provider),
|
|
17
|
+
model: (modelID) => route.model({ id: modelID }),
|
|
18
|
+
configure,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const provider = {
|
|
22
|
+
id,
|
|
23
|
+
configure,
|
|
24
|
+
};
|
|
25
|
+
export const model = (modelID, settings) => configure({
|
|
26
|
+
apiKey: settings.apiKey,
|
|
27
|
+
baseURL: settings.baseURL,
|
|
28
|
+
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
29
|
+
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
30
|
+
limits: settings.limits,
|
|
31
|
+
provider: settings.provider,
|
|
32
|
+
providerOptions: settings.providerOptions,
|
|
33
|
+
}).model(modelID);
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type ModelID } from "../schema/index.js";
|
|
2
|
+
import type { RouteDefaultsInput } from "../route/client.js";
|
|
3
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
5
|
+
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
6
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
+
type GenericModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
8
|
+
readonly provider?: string;
|
|
9
|
+
readonly baseURL: string;
|
|
10
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
11
|
+
};
|
|
12
|
+
export interface Settings extends ProviderPackage.Settings {
|
|
13
|
+
readonly apiKey?: string;
|
|
14
|
+
readonly baseURL: string;
|
|
15
|
+
readonly provider?: string;
|
|
16
|
+
}
|
|
17
|
+
export type FamilyModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
18
|
+
readonly baseURL?: string;
|
|
19
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
20
|
+
};
|
|
21
|
+
export declare const routes: import("../route/client.js").Route<{
|
|
22
|
+
readonly model: string;
|
|
23
|
+
readonly messages: readonly ({
|
|
24
|
+
readonly role: "system";
|
|
25
|
+
readonly content: string | readonly ({
|
|
26
|
+
readonly type: "text";
|
|
27
|
+
readonly text: string;
|
|
28
|
+
readonly cache_control?: {
|
|
29
|
+
readonly type: "ephemeral";
|
|
30
|
+
readonly ttl?: string | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
} | {
|
|
33
|
+
readonly type: "image_url";
|
|
34
|
+
readonly image_url: {
|
|
35
|
+
readonly url: string;
|
|
36
|
+
};
|
|
37
|
+
})[];
|
|
38
|
+
} | {
|
|
39
|
+
readonly role: "user";
|
|
40
|
+
readonly content: string | readonly ({
|
|
41
|
+
readonly type: "text";
|
|
42
|
+
readonly text: string;
|
|
43
|
+
readonly cache_control?: {
|
|
44
|
+
readonly type: "ephemeral";
|
|
45
|
+
readonly ttl?: string | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: "image_url";
|
|
49
|
+
readonly image_url: {
|
|
50
|
+
readonly url: string;
|
|
51
|
+
};
|
|
52
|
+
})[];
|
|
53
|
+
} | {
|
|
54
|
+
readonly [x: string]: unknown;
|
|
55
|
+
readonly content: string | null;
|
|
56
|
+
readonly role: "assistant";
|
|
57
|
+
readonly reasoning?: string | undefined;
|
|
58
|
+
readonly reasoning_content?: string | undefined;
|
|
59
|
+
readonly reasoning_text?: string | undefined;
|
|
60
|
+
readonly cache_control?: {
|
|
61
|
+
readonly type: "ephemeral";
|
|
62
|
+
readonly ttl?: string | undefined;
|
|
63
|
+
} | undefined;
|
|
64
|
+
readonly tool_calls?: readonly {
|
|
65
|
+
readonly id: string;
|
|
66
|
+
readonly type: "function";
|
|
67
|
+
readonly function: {
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly arguments: string;
|
|
70
|
+
};
|
|
71
|
+
}[] | undefined;
|
|
72
|
+
readonly reasoning_details?: unknown;
|
|
73
|
+
} | {
|
|
74
|
+
readonly content: string;
|
|
75
|
+
readonly role: "tool";
|
|
76
|
+
readonly tool_call_id: string;
|
|
77
|
+
readonly cache_control?: {
|
|
78
|
+
readonly type: "ephemeral";
|
|
79
|
+
readonly ttl?: string | undefined;
|
|
80
|
+
} | undefined;
|
|
81
|
+
})[];
|
|
82
|
+
readonly stream: true;
|
|
83
|
+
readonly stop?: readonly string[] | undefined;
|
|
84
|
+
readonly max_completion_tokens?: number | undefined;
|
|
85
|
+
readonly max_tokens?: number | undefined;
|
|
86
|
+
readonly tools?: readonly {
|
|
87
|
+
readonly function: {
|
|
88
|
+
readonly name: string;
|
|
89
|
+
readonly description: string;
|
|
90
|
+
readonly parameters: {
|
|
91
|
+
readonly [x: string]: unknown;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
readonly type: "function";
|
|
95
|
+
readonly cache_control?: {
|
|
96
|
+
readonly type: "ephemeral";
|
|
97
|
+
readonly ttl?: string | undefined;
|
|
98
|
+
} | undefined;
|
|
99
|
+
}[] | undefined;
|
|
100
|
+
readonly temperature?: number | undefined;
|
|
101
|
+
readonly seed?: number | undefined;
|
|
102
|
+
readonly tool_choice?: "required" | "none" | "auto" | {
|
|
103
|
+
readonly type: "function";
|
|
104
|
+
readonly function: {
|
|
105
|
+
readonly name: string;
|
|
106
|
+
};
|
|
107
|
+
} | undefined;
|
|
108
|
+
readonly top_p?: number | undefined;
|
|
109
|
+
readonly store?: boolean | undefined;
|
|
110
|
+
readonly stream_options?: {
|
|
111
|
+
readonly include_usage: boolean;
|
|
112
|
+
} | undefined;
|
|
113
|
+
readonly prompt_cache_key?: string | undefined;
|
|
114
|
+
readonly reasoning_effort?: string | undefined;
|
|
115
|
+
readonly frequency_penalty?: number | undefined;
|
|
116
|
+
readonly presence_penalty?: number | undefined;
|
|
117
|
+
}, import("../route/transport/http.js").HttpPrepared<string>>[];
|
|
118
|
+
export declare const configure: (input: GenericModelOptions) => {
|
|
119
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
120
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
|
|
121
|
+
configure: (input: GenericModelOptions) => /*elided*/ any;
|
|
122
|
+
};
|
|
123
|
+
export declare const provider: {
|
|
124
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
125
|
+
configure: (input: GenericModelOptions) => {
|
|
126
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
127
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
|
|
128
|
+
configure: /*elided*/ any;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
export declare const model: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
|
|
132
|
+
export declare const baseten: {
|
|
133
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
134
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
|
|
135
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
136
|
+
};
|
|
137
|
+
export declare const cerebras: {
|
|
138
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
139
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
|
|
140
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
141
|
+
};
|
|
142
|
+
export declare const deepinfra: {
|
|
143
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
144
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
|
|
145
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
146
|
+
};
|
|
147
|
+
export declare const deepseek: {
|
|
148
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
149
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
|
|
150
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
151
|
+
};
|
|
152
|
+
export declare const fireworks: {
|
|
153
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
154
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
|
|
155
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
156
|
+
};
|
|
157
|
+
export declare const groq: {
|
|
158
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
159
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
|
|
160
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
161
|
+
};
|
|
162
|
+
export declare const togetherai: {
|
|
163
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
164
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
|
|
165
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
166
|
+
};
|
|
167
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ProviderID } from "../schema/index.js";
|
|
2
|
+
import * as OpenAICompatibleChat from "../protocols/openai-compatible-chat.js";
|
|
3
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
4
|
+
import { profiles } from "./openai-compatible-profile.js";
|
|
5
|
+
export const id = ProviderID.make("openai-compatible");
|
|
6
|
+
export const routes = [OpenAICompatibleChat.route];
|
|
7
|
+
export const configure = (input) => {
|
|
8
|
+
const provider = input.provider ?? "openai-compatible";
|
|
9
|
+
const { provider: _, baseURL, apiKey: _apiKey, auth: _auth, ...rest } = input;
|
|
10
|
+
const route = OpenAICompatibleChat.route.with({
|
|
11
|
+
...rest,
|
|
12
|
+
provider,
|
|
13
|
+
endpoint: { baseURL },
|
|
14
|
+
auth: AuthOptions.bearer(input, []),
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
id: ProviderID.make(provider),
|
|
18
|
+
model: (modelID) => route.model({ id: modelID, provider: ProviderID.make(provider) }),
|
|
19
|
+
configure,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const define = (profile) => {
|
|
23
|
+
const configureProfile = (input = {}) => {
|
|
24
|
+
const facade = configure({
|
|
25
|
+
...input,
|
|
26
|
+
baseURL: input.baseURL ?? profile.baseURL,
|
|
27
|
+
provider: profile.provider,
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
id: ProviderID.make(profile.provider),
|
|
31
|
+
model: facade.model,
|
|
32
|
+
configure: configureProfile,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
return configureProfile();
|
|
36
|
+
};
|
|
37
|
+
export const provider = {
|
|
38
|
+
id,
|
|
39
|
+
configure,
|
|
40
|
+
};
|
|
41
|
+
export const model = (modelID, settings) => configure({
|
|
42
|
+
apiKey: settings.apiKey,
|
|
43
|
+
baseURL: settings.baseURL,
|
|
44
|
+
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
45
|
+
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
46
|
+
limits: settings.limits,
|
|
47
|
+
provider: settings.provider,
|
|
48
|
+
}).model(modelID);
|
|
49
|
+
export const baseten = define(profiles.baseten);
|
|
50
|
+
export const cerebras = define(profiles.cerebras);
|
|
51
|
+
export const deepinfra = define(profiles.deepinfra);
|
|
52
|
+
export const deepseek = define(profiles.deepseek);
|
|
53
|
+
export const fireworks = define(profiles.fireworks);
|
|
54
|
+
export const groq = define(profiles.groq);
|
|
55
|
+
export const togetherai = define(profiles.togetherai);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ProviderOptions } from "../schema/index.js";
|
|
2
|
+
import type { OpenResponsesOptionsInput } from "./open-responses-options.js";
|
|
3
|
+
export type { OpenAIResponseIncludable, OpenAIServiceTier } from "../protocols/utils/openai-options.js";
|
|
4
|
+
export type OpenAIOptionsInput = OpenResponsesOptionsInput;
|
|
5
|
+
export type OpenAIProviderOptionsInput = ProviderOptions & {
|
|
6
|
+
readonly openai?: OpenAIOptionsInput;
|
|
7
|
+
};
|
|
8
|
+
export declare const gpt5DefaultOptions: (modelID: string, options?: {
|
|
9
|
+
readonly textVerbosity?: boolean;
|
|
10
|
+
}) => ProviderOptions | undefined;
|
|
11
|
+
export declare const openAIDefaultOptions: (modelID: string, options?: {
|
|
12
|
+
readonly textVerbosity?: boolean;
|
|
13
|
+
}) => ProviderOptions | undefined;
|
|
14
|
+
export declare const withOpenAIOptions: <Options extends {
|
|
15
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
16
|
+
}>(modelID: string, options: Options, defaults?: {
|
|
17
|
+
readonly textVerbosity?: boolean;
|
|
18
|
+
}) => Omit<Options, "providerOptions"> & {
|
|
19
|
+
readonly providerOptions?: ProviderOptions;
|
|
20
|
+
};
|
|
21
|
+
export * as OpenAIProviderOptions from "./openai-options.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { mergeProviderOptions } from "../schema/index.js";
|
|
2
|
+
const definedEntries = (input) => Object.entries(input).filter((entry) => entry[1] !== undefined);
|
|
3
|
+
const openAIProviderOptions = (options) => {
|
|
4
|
+
const openai = Object.fromEntries(definedEntries({
|
|
5
|
+
store: options?.store,
|
|
6
|
+
reasoningEffort: options?.reasoningEffort,
|
|
7
|
+
reasoningSummary: options?.reasoningSummary,
|
|
8
|
+
include: options?.include,
|
|
9
|
+
textVerbosity: options?.textVerbosity,
|
|
10
|
+
serviceTier: options?.serviceTier,
|
|
11
|
+
}));
|
|
12
|
+
if (Object.keys(openai).length === 0)
|
|
13
|
+
return undefined;
|
|
14
|
+
return { openai };
|
|
15
|
+
};
|
|
16
|
+
export const gpt5DefaultOptions = (modelID, options = {}) => {
|
|
17
|
+
const id = modelID.toLowerCase();
|
|
18
|
+
if (!id.includes("gpt-5") || id.includes("gpt-5-chat") || id.includes("gpt-5-pro"))
|
|
19
|
+
return undefined;
|
|
20
|
+
return openAIProviderOptions({
|
|
21
|
+
reasoningEffort: "medium",
|
|
22
|
+
reasoningSummary: "auto",
|
|
23
|
+
// GPT-5 reasoning models are configured stateless (`store: false`) by
|
|
24
|
+
// `openAIDefaultOptions` below, so the only way a follow-up turn can
|
|
25
|
+
// carry reasoning state is via the encrypted reasoning include. Without
|
|
26
|
+
// this, callers using the default model facade get reasoning summaries
|
|
27
|
+
// they cannot replay statelessly.
|
|
28
|
+
include: ["reasoning.encrypted_content"],
|
|
29
|
+
textVerbosity: options.textVerbosity === true && id.includes("gpt-5.") && !id.includes("codex") && !id.includes("-chat")
|
|
30
|
+
? "low"
|
|
31
|
+
: undefined,
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
export const openAIDefaultOptions = (modelID, options = {}) => mergeProviderOptions(openAIProviderOptions({ store: false }), gpt5DefaultOptions(modelID, options));
|
|
35
|
+
export const withOpenAIOptions = (modelID, options, defaults = {}) => {
|
|
36
|
+
return {
|
|
37
|
+
...options,
|
|
38
|
+
providerOptions: mergeProviderOptions(openAIDefaultOptions(modelID, defaults), options.providerOptions),
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export * as OpenAIProviderOptions from "./openai-options.js";
|