@opencode/ai 0.0.0-dev-416 → 0.0.0-dev-425
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 +2 -0
- package/dist/image.d.ts +336 -400
- package/dist/providers/alibaba.d.ts +1 -1
- package/dist/providers/anthropic-compatible.d.ts +2 -2
- package/dist/providers/anthropic-compatible.js +2 -5
- package/dist/providers/anthropic.d.ts +2 -2
- package/dist/providers/anthropic.js +2 -7
- package/dist/providers/assemblyai.d.ts +1 -1
- package/dist/providers/assemblyai.js +2 -7
- package/dist/providers/azure.d.ts +1 -1
- package/dist/providers/azure.js +2 -4
- package/dist/providers/baseten.d.ts +1 -1
- package/dist/providers/cerebras.d.ts +1 -1
- package/dist/providers/cloudflare-ai-gateway.d.ts +2 -2
- package/dist/providers/cloudflare-ai-gateway.js +4 -5
- package/dist/providers/cloudflare-workers-ai.d.ts +1 -1
- package/dist/providers/cohere.d.ts +1 -1
- package/dist/providers/deepgram.d.ts +1 -1
- package/dist/providers/deepgram.js +2 -7
- package/dist/providers/deepinfra.d.ts +1 -1
- package/dist/providers/deepseek.d.ts +1 -1
- package/dist/providers/digitalocean.d.ts +1 -1
- package/dist/providers/elevenlabs.d.ts +1 -1
- package/dist/providers/elevenlabs.js +2 -7
- package/dist/providers/fireworks.d.ts +1 -1
- package/dist/providers/google/interactions.d.ts +1 -1
- package/dist/providers/google.d.ts +2 -2
- package/dist/providers/google.js +2 -7
- package/dist/providers/groq.d.ts +1 -1
- package/dist/providers/meta.d.ts +1 -1
- package/dist/providers/minimax.d.ts +1 -1
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/moonshot.d.ts +1 -1
- package/dist/providers/openai-compatible-responses.d.ts +1 -1
- package/dist/providers/openai-compatible.d.ts +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/opencode.d.ts +1 -1
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/togetherai.d.ts +1 -1
- package/dist/providers/typesafe-ai.d.ts +1 -1
- package/dist/providers/venice.d.ts +1 -1
- package/dist/providers/vercel-ai-gateway.d.ts +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/zai-coding-plan.d.ts +1 -1
- package/dist/providers/zai.d.ts +1 -1
- package/dist/route/auth-options.d.ts +9 -5
- package/dist/route/auth-options.js +10 -7
- package/dist/schema/events.d.ts +2456 -2168
- package/dist/speech.d.ts +290 -294
- package/dist/transcription.d.ts +298 -242
- package/dist/video.d.ts +252 -264
- package/package.json +5 -5
|
@@ -22,7 +22,7 @@ export type Config = Location & Omit<RouteDefaultsInput, "providerOptions"> & Pr
|
|
|
22
22
|
readonly providerOptions?: ChatOptionsInput | MessagesOptionsInput | ResponsesOptionsInput;
|
|
23
23
|
};
|
|
24
24
|
export type Settings<Options = ChatOptionsInput> = Location & ProviderPackage.Settings & Options & {
|
|
25
|
-
readonly apiKey?: string;
|
|
25
|
+
readonly apiKey?: string | false;
|
|
26
26
|
};
|
|
27
27
|
export declare const routes: (Route<{
|
|
28
28
|
readonly model: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import type { RouteDefaultsInput } from "../route/client.js";
|
|
5
5
|
import { type ModelID } from "../schema/index.js";
|
|
6
6
|
export type AnthropicOptionsInput = AnthropicMessages.OptionsInput;
|
|
@@ -13,7 +13,7 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
|
13
13
|
readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
|
|
14
14
|
};
|
|
15
15
|
export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOptionsInput & ({
|
|
16
|
-
readonly apiKey?: string;
|
|
16
|
+
readonly apiKey?: string | false;
|
|
17
17
|
readonly authToken?: never;
|
|
18
18
|
} | {
|
|
19
19
|
readonly apiKey?: never;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
2
2
|
import { Auth } from "../route/auth.js";
|
|
3
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
3
4
|
import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
|
|
4
5
|
export const id = ProviderID.make("anthropic-compatible");
|
|
5
6
|
const compatibleRoute = AnthropicMessages.route.with({ id: "anthropic-compatible-messages", provider: id });
|
|
6
7
|
export const routes = [compatibleRoute];
|
|
7
|
-
const auth = (input) =>
|
|
8
|
-
if ("auth" in input && input.auth)
|
|
9
|
-
return input.auth;
|
|
10
|
-
return Auth.optional("apiKey" in input ? input.apiKey : undefined, "apiKey").pipe(Auth.header("x-api-key"));
|
|
11
|
-
};
|
|
8
|
+
const auth = (input) => AuthOptions.apiKey(input, [], Auth.header("x-api-key"));
|
|
12
9
|
export const configure = (input) => {
|
|
13
10
|
const provider = input.provider ?? "anthropic-compatible";
|
|
14
11
|
if (!input.baseURL)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RouteDefaultsInput } from "../route/client.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
3
|
import type { ProviderPackage } from "../provider-package.js";
|
|
4
4
|
import { type ModelID } from "../schema/index.js";
|
|
5
5
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
@@ -320,7 +320,7 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
|
320
320
|
readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
|
|
321
321
|
};
|
|
322
322
|
export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOptionsInput & ({
|
|
323
|
-
readonly apiKey?: string;
|
|
323
|
+
readonly apiKey?: string | false;
|
|
324
324
|
readonly authToken?: never;
|
|
325
325
|
} | {
|
|
326
326
|
readonly apiKey?: never;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
2
3
|
import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
|
|
3
4
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
4
5
|
import { AnthropicCompatible } from "./anthropic-compatible.js";
|
|
5
6
|
export const id = ProviderID.make("anthropic");
|
|
6
7
|
export const routes = [AnthropicMessages.route];
|
|
7
|
-
const auth = (options) =>
|
|
8
|
-
if ("auth" in options && options.auth)
|
|
9
|
-
return options.auth;
|
|
10
|
-
return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
|
|
11
|
-
.orElse(Auth.config("ANTHROPIC_API_KEY"))
|
|
12
|
-
.pipe(Auth.header("x-api-key"));
|
|
13
|
-
};
|
|
8
|
+
const auth = (options) => AuthOptions.apiKey(options, "ANTHROPIC_API_KEY", Auth.header("x-api-key"));
|
|
14
9
|
export const configure = (input = {}) => {
|
|
15
10
|
const { apiKey: _, auth: _auth, baseURL, ...rest } = input;
|
|
16
11
|
const compatible = AnthropicCompatible.configure({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
2
|
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
3
|
export type { AssemblyAITranscriptionOptions } from "../protocols/assemblyai-transcription.js";
|
|
4
4
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
2
3
|
import { MediaRoute } from "../route/media.js";
|
|
3
4
|
import { ProviderID } from "../schema/index.js";
|
|
4
5
|
import { AssemblyAITranscription } from "../protocols/assemblyai-transcription.js";
|
|
5
6
|
export const id = ProviderID.make("assemblyai");
|
|
6
7
|
// The key is the whole `authorization` value, without a scheme.
|
|
7
|
-
const auth = (options) =>
|
|
8
|
-
if ("auth" in options && options.auth)
|
|
9
|
-
return options.auth;
|
|
10
|
-
return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
|
|
11
|
-
.orElse(Auth.config("ASSEMBLYAI_API_KEY"))
|
|
12
|
-
.pipe(Auth.header("authorization"));
|
|
13
|
-
};
|
|
8
|
+
const auth = (options) => AuthOptions.apiKey(options, "ASSEMBLYAI_API_KEY", Auth.header("authorization"));
|
|
14
9
|
export const configure = (input = {}) => {
|
|
15
10
|
const media = MediaRoute.deployment(input, auth(input));
|
|
16
11
|
const transcription = (modelID) => AssemblyAITranscription.model({ ...media, id: modelID });
|
|
@@ -15,7 +15,7 @@ export type Config = AzureURL & RouteDefaultsInput & ProviderAuthOption<"optiona
|
|
|
15
15
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
16
16
|
};
|
|
17
17
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & AzureURL & {
|
|
18
|
-
readonly apiKey?: string;
|
|
18
|
+
readonly apiKey?: string | false;
|
|
19
19
|
readonly apiVersion?: string;
|
|
20
20
|
readonly queryParams?: Readonly<Record<string, string>>;
|
|
21
21
|
readonly useDeploymentBasedUrls?: boolean;
|
package/dist/providers/azure.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
-
import {} from "../route/auth-options.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
3
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
4
4
|
import { MediaRoute } from "../route/media.js";
|
|
5
5
|
import { HttpOptions, ProviderConfigurationError, ProviderID, mergeHttpOptions, } from "../schema/index.js";
|
|
@@ -51,9 +51,7 @@ const defaults = (input) => {
|
|
|
51
51
|
const auth = (input) => {
|
|
52
52
|
if ("auth" in input && input.auth)
|
|
53
53
|
return input.auth;
|
|
54
|
-
return Auth.remove("authorization").andThen(
|
|
55
|
-
.orElse(Auth.config("AZURE_OPENAI_API_KEY"))
|
|
56
|
-
.pipe(Auth.header("api-key")));
|
|
54
|
+
return Auth.remove("authorization").andThen(AuthOptions.apiKey(input, "AZURE_OPENAI_API_KEY", Auth.header("api-key")));
|
|
57
55
|
};
|
|
58
56
|
const configuredRoute = (route, input, modelID) => route.with({
|
|
59
57
|
auth: auth(input),
|
|
@@ -13,7 +13,7 @@ export interface BasetenDecisionOptions {
|
|
|
13
13
|
readonly max_len?: number;
|
|
14
14
|
}
|
|
15
15
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
16
|
-
readonly apiKey?: string;
|
|
16
|
+
readonly apiKey?: string | false;
|
|
17
17
|
readonly baseURL?: string;
|
|
18
18
|
};
|
|
19
19
|
export declare const route: Route<{
|
|
@@ -9,7 +9,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
9
9
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
10
10
|
};
|
|
11
11
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
12
|
-
readonly apiKey?: string;
|
|
12
|
+
readonly apiKey?: string | false;
|
|
13
13
|
readonly baseURL?: string;
|
|
14
14
|
};
|
|
15
15
|
export declare const route: Route<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config, Redacted } from "effect";
|
|
2
2
|
import type { ProviderPackage } from "../provider-package.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import type { RouteDefaultsInput } from "../route/client.js";
|
|
5
5
|
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
6
6
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
@@ -23,7 +23,7 @@ export type Config = GatewayURL & GatewayOptions & Omit<RouteDefaultsInput, "pro
|
|
|
23
23
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
24
24
|
};
|
|
25
25
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & GatewayURL & GatewayOptions & {
|
|
26
|
-
readonly apiKey?: string;
|
|
26
|
+
readonly apiKey?: string | false;
|
|
27
27
|
readonly gatewayApiKey?: string;
|
|
28
28
|
};
|
|
29
29
|
export declare const baseURL: (input: GatewayURL) => string;
|
|
@@ -2,6 +2,7 @@ import { CloudflareRunDecisions } from "../protocols/cloudflare-run-decisions.js
|
|
|
2
2
|
import { AnthropicMessages, OpenAIChat, OpenAIResponses } from "../protocols/index.js";
|
|
3
3
|
import { Auth } from "../route/auth.js";
|
|
4
4
|
import { Endpoint } from "../route/endpoint.js";
|
|
5
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
5
6
|
import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
|
|
6
7
|
import { encodeJson } from "../utils/json.js";
|
|
7
8
|
export const id = ProviderID.make("cloudflare-ai-gateway");
|
|
@@ -49,9 +50,7 @@ export const route = OpenAIChat.route.with({
|
|
|
49
50
|
endpoint: { baseURL: undefined },
|
|
50
51
|
});
|
|
51
52
|
export const routes = [responsesRoute, messagesRoute, route];
|
|
52
|
-
const credential = (input) =>
|
|
53
|
-
.orElse(Auth.config(authEnvVars[0]))
|
|
54
|
-
.orElse(Auth.config(authEnvVars[1]));
|
|
53
|
+
const credential = (input, apply) => AuthOptions.apiKey({ apiKey: input.gatewayApiKey ?? ("apiKey" in input ? input.apiKey : undefined) }, authEnvVars, apply);
|
|
55
54
|
const headers = (input) => ({
|
|
56
55
|
...(input.metadata === undefined ? {} : { "cf-aig-metadata": encodeJson(input.metadata) }),
|
|
57
56
|
...(input.cacheTtl === undefined ? {} : { "cf-aig-cache-ttl": String(input.cacheTtl) }),
|
|
@@ -64,7 +63,7 @@ export const configure = (input) => {
|
|
|
64
63
|
const custom = "auth" in input && input.auth ? input.auth : undefined;
|
|
65
64
|
const rest = {
|
|
66
65
|
endpoint: { baseURL: baseURL(input) },
|
|
67
|
-
auth: custom ?? credential(input).bearer(),
|
|
66
|
+
auth: custom ?? credential(input, (credential) => credential.bearer()),
|
|
68
67
|
headers: { "cf-aig-gateway-id": gatewayId(input), ...headers(input) },
|
|
69
68
|
http: input.http,
|
|
70
69
|
providerOptions: input.providerOptions,
|
|
@@ -75,7 +74,7 @@ export const configure = (input) => {
|
|
|
75
74
|
? {
|
|
76
75
|
...rest,
|
|
77
76
|
endpoint: { baseURL: passthroughURL(input, provider) },
|
|
78
|
-
auth: custom ?? Auth.bearerHeader("cf-aig-authorization"
|
|
77
|
+
auth: custom ?? credential(input, Auth.bearerHeader("cf-aig-authorization")),
|
|
79
78
|
headers: headers(input),
|
|
80
79
|
}
|
|
81
80
|
: rest;
|
|
@@ -13,7 +13,7 @@ export type Config = WorkersAIURL & Omit<RouteDefaultsInput, "providerOptions">
|
|
|
13
13
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
14
14
|
};
|
|
15
15
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & WorkersAIURL & {
|
|
16
|
-
readonly apiKey?: string;
|
|
16
|
+
readonly apiKey?: string | false;
|
|
17
17
|
};
|
|
18
18
|
export type { CloudflareWorkersAIImageOptions } from "../protocols/cloudflare-workers-ai-images.js";
|
|
19
19
|
export declare const baseURL: (input: WorkersAIURL) => string;
|
|
@@ -13,7 +13,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
13
13
|
readonly providerOptions?: ProviderOptions;
|
|
14
14
|
};
|
|
15
15
|
export type Settings<Options = CohereChat.ProviderOptionsInput> = ProviderPackage.Settings & Options & {
|
|
16
|
-
readonly apiKey?: string;
|
|
16
|
+
readonly apiKey?: string | false;
|
|
17
17
|
readonly baseURL?: string;
|
|
18
18
|
};
|
|
19
19
|
export declare const route: Route<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
2
|
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
3
|
export type { DeepgramEncoding, DeepgramSpeechOptions } from "../protocols/deepgram-speech.js";
|
|
4
4
|
export type { DeepgramTranscriptionOptions } from "../protocols/deepgram-transcription.js";
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
2
3
|
import { MediaRoute } from "../route/media.js";
|
|
3
4
|
import { ProviderID } from "../schema/index.js";
|
|
4
5
|
import { DeepgramSpeech } from "../protocols/deepgram-speech.js";
|
|
5
6
|
import { DeepgramTranscription } from "../protocols/deepgram-transcription.js";
|
|
6
7
|
export const id = ProviderID.make("deepgram");
|
|
7
|
-
const auth = (options) =>
|
|
8
|
-
if ("auth" in options && options.auth)
|
|
9
|
-
return options.auth;
|
|
10
|
-
return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
|
|
11
|
-
.orElse(Auth.config("DEEPGRAM_API_KEY"))
|
|
12
|
-
.pipe(Auth.scheme("Token"));
|
|
13
|
-
};
|
|
8
|
+
const auth = (options) => AuthOptions.apiKey(options, "DEEPGRAM_API_KEY", Auth.scheme("Token"));
|
|
14
9
|
export const configure = (input = {}) => {
|
|
15
10
|
const media = MediaRoute.deployment(input, auth(input));
|
|
16
11
|
return {
|
|
@@ -9,7 +9,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
9
9
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
10
10
|
};
|
|
11
11
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
12
|
-
readonly apiKey?: string;
|
|
12
|
+
readonly apiKey?: string | false;
|
|
13
13
|
readonly baseURL?: string;
|
|
14
14
|
};
|
|
15
15
|
export declare const route: Route<{
|
|
@@ -9,7 +9,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
9
9
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
10
10
|
};
|
|
11
11
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
12
|
-
readonly apiKey?: string;
|
|
12
|
+
readonly apiKey?: string | false;
|
|
13
13
|
readonly baseURL?: string;
|
|
14
14
|
};
|
|
15
15
|
export declare const route: Route<{
|
|
@@ -12,7 +12,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
12
12
|
readonly providerOptions?: OpenAIProviderOptionsInput | OpenResponsesProviderOptionsInput;
|
|
13
13
|
};
|
|
14
14
|
export type Settings<Options = OpenAIProviderOptionsInput> = ProviderPackage.Settings & Options & {
|
|
15
|
-
readonly apiKey?: string;
|
|
15
|
+
readonly apiKey?: string | false;
|
|
16
16
|
};
|
|
17
17
|
export declare const protocol: Protocol<{
|
|
18
18
|
readonly model: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
2
|
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
3
|
export type { ElevenLabsOutputFormat, ElevenLabsSpeechOptions } from "../protocols/elevenlabs-speech.js";
|
|
4
4
|
export type { ElevenLabsTranscriptionOptions } from "../protocols/elevenlabs-transcription.js";
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
2
3
|
import { MediaRoute } from "../route/media.js";
|
|
3
4
|
import { ProviderID } from "../schema/index.js";
|
|
4
5
|
import { ElevenLabsSpeech } from "../protocols/elevenlabs-speech.js";
|
|
5
6
|
import { ElevenLabsTranscription } from "../protocols/elevenlabs-transcription.js";
|
|
6
7
|
export const id = ProviderID.make("elevenlabs");
|
|
7
|
-
const auth = (options) =>
|
|
8
|
-
if ("auth" in options && options.auth)
|
|
9
|
-
return options.auth;
|
|
10
|
-
return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
|
|
11
|
-
.orElse(Auth.config("ELEVENLABS_API_KEY"))
|
|
12
|
-
.pipe(Auth.header("xi-api-key"));
|
|
13
|
-
};
|
|
8
|
+
const auth = (options) => AuthOptions.apiKey(options, "ELEVENLABS_API_KEY", Auth.header("xi-api-key"));
|
|
14
9
|
export const configure = (input = {}) => {
|
|
15
10
|
const media = MediaRoute.deployment(input, auth(input));
|
|
16
11
|
const speech = (modelID) => ElevenLabsSpeech.model({ ...media, id: modelID });
|
|
@@ -9,7 +9,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
9
9
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
10
10
|
};
|
|
11
11
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
12
|
-
readonly apiKey?: string;
|
|
12
|
+
readonly apiKey?: string | false;
|
|
13
13
|
readonly baseURL?: string;
|
|
14
14
|
};
|
|
15
15
|
export declare const route: Route<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../../provider-package.js";
|
|
2
2
|
import type { GoogleInteractions } from "../../protocols/google-interactions.js";
|
|
3
3
|
export type Settings = ProviderPackage.Settings & GoogleInteractions.ProviderOptionsInput & {
|
|
4
|
-
readonly apiKey?: string;
|
|
4
|
+
readonly apiKey?: string | false;
|
|
5
5
|
readonly baseURL?: string;
|
|
6
6
|
};
|
|
7
7
|
export declare const model: ProviderPackage.Model<Settings, GoogleInteractions.ProviderOptionsInput>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RouteDefaultsInput } from "../route/client.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
3
|
import type { ProviderPackage } from "../provider-package.js";
|
|
4
4
|
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
5
5
|
import { Gemini } from "../protocols/gemini.js";
|
|
@@ -164,7 +164,7 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
|
164
164
|
readonly providerOptions?: Gemini.ProviderOptionsInput & GoogleInteractions.ProviderOptionsInput;
|
|
165
165
|
};
|
|
166
166
|
export type Settings = ProviderPackage.Settings & Gemini.ProviderOptionsInput & {
|
|
167
|
-
readonly apiKey?: string;
|
|
167
|
+
readonly apiKey?: string | false;
|
|
168
168
|
readonly baseURL?: string;
|
|
169
169
|
};
|
|
170
170
|
export declare const configure: (input?: Config) => {
|
package/dist/providers/google.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
2
3
|
import { MediaRoute } from "../route/media.js";
|
|
3
4
|
import { ProviderID } from "../schema/index.js";
|
|
4
5
|
import { Gemini } from "../protocols/gemini.js";
|
|
@@ -9,13 +10,7 @@ import { GoogleTranscription } from "../protocols/google-transcription.js";
|
|
|
9
10
|
import { GoogleVideo } from "../protocols/google-video.js";
|
|
10
11
|
export const id = ProviderID.make("google");
|
|
11
12
|
export const routes = [Gemini.route, GoogleInteractions.route];
|
|
12
|
-
const auth = (options) =>
|
|
13
|
-
if ("auth" in options && options.auth)
|
|
14
|
-
return options.auth;
|
|
15
|
-
return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
|
|
16
|
-
.orElse(Auth.config("GOOGLE_GENERATIVE_AI_API_KEY"))
|
|
17
|
-
.pipe(Auth.header("x-goog-api-key"));
|
|
18
|
-
};
|
|
13
|
+
const auth = (options) => AuthOptions.apiKey(options, "GOOGLE_GENERATIVE_AI_API_KEY", Auth.header("x-goog-api-key"));
|
|
19
14
|
const configuredRoute = (input) => {
|
|
20
15
|
const { apiKey: _, auth: _auth, baseURL, ...rest } = input;
|
|
21
16
|
return Gemini.route.with({ ...rest, endpoint: { baseURL }, auth: auth(input) });
|
package/dist/providers/groq.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
18
18
|
readonly providerOptions?: ProviderOptions;
|
|
19
19
|
};
|
|
20
20
|
export type Settings = ProviderPackage.Settings & ProviderOptions & {
|
|
21
|
-
readonly apiKey?: string;
|
|
21
|
+
readonly apiKey?: string | false;
|
|
22
22
|
readonly baseURL?: string;
|
|
23
23
|
};
|
|
24
24
|
export declare const protocol: Protocol<{
|
package/dist/providers/meta.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
35
35
|
readonly providerOptions?: ProviderOptionsInput;
|
|
36
36
|
};
|
|
37
37
|
export type Settings = ProviderPackage.Settings & ProviderOptionsInput & {
|
|
38
|
-
readonly apiKey?: string;
|
|
38
|
+
readonly apiKey?: string | false;
|
|
39
39
|
readonly baseURL?: string;
|
|
40
40
|
};
|
|
41
41
|
export declare const routes: (Route<{
|
|
@@ -31,7 +31,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
31
31
|
readonly providerOptions?: ProviderOptionsInput;
|
|
32
32
|
};
|
|
33
33
|
export type Settings<Options = MessagesOptionsInput> = ProviderPackage.Settings & Options & {
|
|
34
|
-
readonly apiKey?: string;
|
|
34
|
+
readonly apiKey?: string | false;
|
|
35
35
|
readonly baseURL?: string;
|
|
36
36
|
};
|
|
37
37
|
export type { MiniMaxImageOptions };
|
|
@@ -10,7 +10,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
10
10
|
readonly providerOptions?: ProviderOptions;
|
|
11
11
|
};
|
|
12
12
|
export type Settings = ProviderPackage.Settings & ProviderOptions & {
|
|
13
|
-
readonly apiKey?: string;
|
|
13
|
+
readonly apiKey?: string | false;
|
|
14
14
|
readonly baseURL?: string;
|
|
15
15
|
};
|
|
16
16
|
export declare const route: import("../route/client.js").Route<{
|
|
@@ -28,7 +28,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
28
28
|
readonly providerOptions?: ChatOptionsInput | MessagesOptionsInput | ResponsesOptionsInput;
|
|
29
29
|
};
|
|
30
30
|
export type Settings<Options = ChatOptionsInput> = ProviderPackage.Settings & Options & {
|
|
31
|
-
readonly apiKey?: string;
|
|
31
|
+
readonly apiKey?: string | false;
|
|
32
32
|
readonly baseURL?: string;
|
|
33
33
|
};
|
|
34
34
|
export declare const routes: (Route<{
|
|
@@ -11,7 +11,7 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
|
11
11
|
readonly providerOptions?: OpenResponsesProviderOptionsInput;
|
|
12
12
|
};
|
|
13
13
|
export type Settings = ProviderPackage.Settings & OpenResponsesProviderOptionsInput & {
|
|
14
|
-
readonly apiKey?: string;
|
|
14
|
+
readonly apiKey?: string | false;
|
|
15
15
|
readonly baseURL: string;
|
|
16
16
|
readonly provider?: string;
|
|
17
17
|
};
|
|
@@ -10,7 +10,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
10
10
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
11
11
|
};
|
|
12
12
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
13
|
-
readonly apiKey?: string;
|
|
13
|
+
readonly apiKey?: string | false;
|
|
14
14
|
readonly baseURL: string;
|
|
15
15
|
readonly provider?: string;
|
|
16
16
|
};
|
|
@@ -434,7 +434,7 @@ export interface ImageGenerationOptions {
|
|
|
434
434
|
}
|
|
435
435
|
export declare const imageGeneration: (options?: ImageGenerationOptions) => ToolDefinition;
|
|
436
436
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
437
|
-
readonly apiKey?: string;
|
|
437
|
+
readonly apiKey?: string | false;
|
|
438
438
|
readonly baseURL?: string;
|
|
439
439
|
readonly organization?: string;
|
|
440
440
|
readonly project?: string;
|
|
@@ -8,7 +8,7 @@ export type Config = ProviderAuthOption<"optional"> & {
|
|
|
8
8
|
readonly http?: HttpOptions.Input;
|
|
9
9
|
};
|
|
10
10
|
export type Settings = ProviderPackage.Settings & {
|
|
11
|
-
readonly apiKey?: string;
|
|
11
|
+
readonly apiKey?: string | false;
|
|
12
12
|
};
|
|
13
13
|
export declare const configure: (input?: Config) => {
|
|
14
14
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -87,7 +87,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
87
87
|
readonly providerOptions?: OpenRouterProviderOptionsInput | OpenRouterResponsesProviderOptionsInput;
|
|
88
88
|
};
|
|
89
89
|
export type Settings<Options = OpenRouterProviderOptionsInput> = ProviderPackage.Settings & Options & {
|
|
90
|
-
readonly apiKey?: string;
|
|
90
|
+
readonly apiKey?: string | false;
|
|
91
91
|
readonly baseURL?: string;
|
|
92
92
|
};
|
|
93
93
|
declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
|
|
@@ -9,7 +9,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
9
9
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
10
10
|
};
|
|
11
11
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
12
|
-
readonly apiKey?: string;
|
|
12
|
+
readonly apiKey?: string | false;
|
|
13
13
|
readonly baseURL?: string;
|
|
14
14
|
};
|
|
15
15
|
export declare const route: Route<{
|
|
@@ -8,7 +8,7 @@ export type Config = ProviderAuthOption<"optional"> & {
|
|
|
8
8
|
readonly http?: HttpOptions.Input;
|
|
9
9
|
};
|
|
10
10
|
export type Settings = ProviderPackage.Settings & {
|
|
11
|
-
readonly apiKey?: string;
|
|
11
|
+
readonly apiKey?: string | false;
|
|
12
12
|
};
|
|
13
13
|
export declare const configure: (input?: Config) => {
|
|
14
14
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -12,7 +12,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
12
12
|
readonly providerOptions?: ChatOptionsInput | OpenResponsesProviderOptionsInput;
|
|
13
13
|
};
|
|
14
14
|
export type Settings<Options = ChatOptionsInput> = ProviderPackage.Settings & Options & {
|
|
15
|
-
readonly apiKey?: string;
|
|
15
|
+
readonly apiKey?: string | false;
|
|
16
16
|
readonly baseURL?: string;
|
|
17
17
|
readonly queryParams?: Readonly<Record<string, string>>;
|
|
18
18
|
};
|
|
@@ -68,7 +68,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
68
68
|
readonly providerOptions?: ProviderOptionsInput;
|
|
69
69
|
};
|
|
70
70
|
export type Settings = ProviderPackage.Settings & ProviderOptionsInput & {
|
|
71
|
-
readonly apiKey?: string;
|
|
71
|
+
readonly apiKey?: string | false;
|
|
72
72
|
};
|
|
73
73
|
export declare const routes: Route<{
|
|
74
74
|
readonly [x: string]: unknown;
|
package/dist/providers/xai.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
13
13
|
readonly providerOptions?: XAIProviderOptionsInput;
|
|
14
14
|
};
|
|
15
15
|
export type Settings = ProviderPackage.Settings & XAIProviderOptionsInput & {
|
|
16
|
-
readonly apiKey?: string;
|
|
16
|
+
readonly apiKey?: string | false;
|
|
17
17
|
readonly baseURL?: string;
|
|
18
18
|
};
|
|
19
19
|
export type { XAIImageOptions } from "../protocols/xai-images.js";
|
|
@@ -16,7 +16,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
16
16
|
readonly providerOptions?: ChatOptionsInput | MessagesOptionsInput | ResponsesOptionsInput;
|
|
17
17
|
};
|
|
18
18
|
export type Settings<Options = ChatOptionsInput> = ProviderPackage.Settings & Options & {
|
|
19
|
-
readonly apiKey?: string;
|
|
19
|
+
readonly apiKey?: string | false;
|
|
20
20
|
readonly baseURL?: string;
|
|
21
21
|
};
|
|
22
22
|
export declare const routes: (Route<{
|
package/dist/providers/zai.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthO
|
|
|
10
10
|
readonly providerOptions?: ChatOptionsInput;
|
|
11
11
|
};
|
|
12
12
|
export type Settings = ProviderPackage.Settings & ChatOptionsInput & {
|
|
13
|
-
readonly apiKey?: string;
|
|
13
|
+
readonly apiKey?: string | false;
|
|
14
14
|
readonly baseURL?: string;
|
|
15
15
|
};
|
|
16
16
|
export type { ZAIImageOptions } from "../protocols/zai-images.js";
|
|
@@ -5,12 +5,14 @@ export type AuthOverride = {
|
|
|
5
5
|
readonly auth: Auth.Definition;
|
|
6
6
|
readonly apiKey?: never;
|
|
7
7
|
};
|
|
8
|
+
/** `false` marks a provider that needs no key: no env lookup and no auth header from the package. */
|
|
9
|
+
export type ApiKey = string | Redacted.Redacted<string> | Config.Config<string | Redacted.Redacted<string>> | false;
|
|
8
10
|
export type OptionalApiKeyAuth = {
|
|
9
|
-
readonly apiKey?:
|
|
11
|
+
readonly apiKey?: ApiKey;
|
|
10
12
|
readonly auth?: never;
|
|
11
13
|
};
|
|
12
14
|
export type RequiredApiKeyAuth = {
|
|
13
|
-
readonly apiKey:
|
|
15
|
+
readonly apiKey: ApiKey;
|
|
14
16
|
readonly auth?: never;
|
|
15
17
|
};
|
|
16
18
|
export type ProviderAuthOption<Mode extends ApiKeyMode> = AuthOverride | (Mode extends "optional" ? OptionalApiKeyAuth : RequiredApiKeyAuth);
|
|
@@ -23,9 +25,11 @@ export type AtLeastOne<T> = {
|
|
|
23
25
|
[K in keyof T]: Required<Pick<T, K>> & Partial<Omit<T, K>>;
|
|
24
26
|
}[keyof T];
|
|
25
27
|
/**
|
|
26
|
-
* Standard
|
|
27
|
-
* override,
|
|
28
|
-
*
|
|
28
|
+
* Standard API-key resolution for providers: honor an explicit `auth`
|
|
29
|
+
* override, skip auth entirely for `apiKey: false`, otherwise resolve `apiKey`
|
|
30
|
+
* (option > config vars) and render it with `apply`.
|
|
29
31
|
*/
|
|
32
|
+
export declare const apiKey: (options: ProviderAuthOption<"optional">, envVar: string | ReadonlyArray<string>, apply: (credential: Auth.Credential) => Auth.Definition) => Auth.Definition;
|
|
33
|
+
/** `apiKey` resolution applied as `Authorization: Bearer <key>`. */
|
|
30
34
|
export declare const bearer: (options: ProviderAuthOption<"optional">, envVar: string | ReadonlyArray<string>) => Auth.Definition;
|
|
31
35
|
export * as AuthOptions from "./auth-options.js";
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Auth } from "./auth.js";
|
|
2
2
|
/**
|
|
3
|
-
* Standard
|
|
4
|
-
* override,
|
|
5
|
-
*
|
|
3
|
+
* Standard API-key resolution for providers: honor an explicit `auth`
|
|
4
|
+
* override, skip auth entirely for `apiKey: false`, otherwise resolve `apiKey`
|
|
5
|
+
* (option > config vars) and render it with `apply`.
|
|
6
6
|
*/
|
|
7
|
-
export const
|
|
7
|
+
export const apiKey = (options, envVar, apply) => {
|
|
8
8
|
if ("auth" in options && options.auth)
|
|
9
9
|
return options.auth;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.
|
|
10
|
+
const key = "apiKey" in options ? options.apiKey : undefined;
|
|
11
|
+
if (key === false)
|
|
12
|
+
return Auth.none;
|
|
13
|
+
return apply((Array.isArray(envVar) ? envVar : [envVar]).reduce((auth, name) => auth.orElse(Auth.config(name)), Auth.optional(key, "apiKey")));
|
|
13
14
|
};
|
|
15
|
+
/** `apiKey` resolution applied as `Authorization: Bearer <key>`. */
|
|
16
|
+
export const bearer = (options, envVar) => apiKey(options, envVar, (credential) => credential.bearer());
|
|
14
17
|
export * as AuthOptions from "./auth-options.js";
|