|
@@ -1,7 +1,6 @@
|
|
|
import { Config } from "effect"
|
|
import { Config } from "effect"
|
|
|
-import type { Auth } from "../src/route/auth"
|
|
|
|
|
|
|
+import { Auth } from "../src/route"
|
|
|
import type { ModelFactory } from "../src/route/auth-options"
|
|
import type { ModelFactory } from "../src/route/auth-options"
|
|
|
-import { Auth as RuntimeAuth } from "../src/route/auth"
|
|
|
|
|
import * as OpenAIChat from "../src/protocols/openai-chat"
|
|
import * as OpenAIChat from "../src/protocols/openai-chat"
|
|
|
import * as AmazonBedrock from "../src/providers/amazon-bedrock"
|
|
import * as AmazonBedrock from "../src/providers/amazon-bedrock"
|
|
|
import * as Anthropic from "../src/providers/anthropic"
|
|
import * as Anthropic from "../src/providers/anthropic"
|
|
@@ -28,7 +27,7 @@ type Model = {
|
|
|
readonly id: string
|
|
readonly id: string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-declare const auth: Auth
|
|
|
|
|
|
|
+declare const auth: Auth.Definition
|
|
|
declare const optionalAuthModel: ModelFactory<BaseOptions, "optional", Model>
|
|
declare const optionalAuthModel: ModelFactory<BaseOptions, "optional", Model>
|
|
|
declare const requiredAuthModel: ModelFactory<BaseOptions, "required", Model>
|
|
declare const requiredAuthModel: ModelFactory<BaseOptions, "required", Model>
|
|
|
const configApiKey = Config.redacted("OPENAI_API_KEY")
|
|
const configApiKey = Config.redacted("OPENAI_API_KEY")
|
|
@@ -76,9 +75,9 @@ OpenAI.responses("gpt-4.1-mini")
|
|
|
OpenAI.configure({}).responses("gpt-4.1-mini")
|
|
OpenAI.configure({}).responses("gpt-4.1-mini")
|
|
|
OpenAI.configure({ apiKey: "sk-test" }).responses("gpt-4.1-mini")
|
|
OpenAI.configure({ apiKey: "sk-test" }).responses("gpt-4.1-mini")
|
|
|
OpenAI.configure({ apiKey: configApiKey }).responses("gpt-4.1-mini")
|
|
OpenAI.configure({ apiKey: configApiKey }).responses("gpt-4.1-mini")
|
|
|
-OpenAI.configure({ auth: RuntimeAuth.bearer("oauth-token") }).responses("gpt-4.1-mini")
|
|
|
|
|
|
|
+OpenAI.configure({ auth: Auth.bearer("oauth-token") }).responses("gpt-4.1-mini")
|
|
|
OpenAI.configure({
|
|
OpenAI.configure({
|
|
|
- auth: RuntimeAuth.headers({ authorization: "Bearer gateway" }),
|
|
|
|
|
|
|
+ auth: Auth.headers({ authorization: "Bearer gateway" }),
|
|
|
baseURL: "https://gateway.example.com/v1",
|
|
baseURL: "https://gateway.example.com/v1",
|
|
|
}).responses("gpt-4.1-mini")
|
|
}).responses("gpt-4.1-mini")
|
|
|
OpenAI.configure({
|
|
OpenAI.configure({
|
|
@@ -102,40 +101,40 @@ OpenAI.configure({ generation: { maxTokens: "many" } })
|
|
|
OpenAI.configure({ providerOptions: { openai: { store: "false" } } })
|
|
OpenAI.configure({ providerOptions: { openai: { store: "false" } } })
|
|
|
|
|
|
|
|
// @ts-expect-error auth is an override, so OpenAI rejects apiKey with auth.
|
|
// @ts-expect-error auth is an override, so OpenAI rejects apiKey with auth.
|
|
|
-OpenAI.configure({ apiKey: "sk-test", auth: RuntimeAuth.bearer("oauth-token") })
|
|
|
|
|
|
|
+OpenAI.configure({ apiKey: "sk-test", auth: Auth.bearer("oauth-token") })
|
|
|
|
|
|
|
|
OpenAI.chat("gpt-4.1-mini")
|
|
OpenAI.chat("gpt-4.1-mini")
|
|
|
OpenAI.configure({ apiKey: "sk-test" }).chat("gpt-4.1-mini")
|
|
OpenAI.configure({ apiKey: "sk-test" }).chat("gpt-4.1-mini")
|
|
|
OpenAI.configure({ apiKey: configApiKey }).chat("gpt-4.1-mini")
|
|
OpenAI.configure({ apiKey: configApiKey }).chat("gpt-4.1-mini")
|
|
|
-OpenAI.configure({ auth: RuntimeAuth.bearer("oauth-token") }).chat("gpt-4.1-mini")
|
|
|
|
|
|
|
+OpenAI.configure({ auth: Auth.bearer("oauth-token") }).chat("gpt-4.1-mini")
|
|
|
|
|
|
|
|
// @ts-expect-error OpenAI chat selectors only accept model ids.
|
|
// @ts-expect-error OpenAI chat selectors only accept model ids.
|
|
|
OpenAI.configure({ apiKey: "sk-test" }).chat("gpt-4.1-mini", {})
|
|
OpenAI.configure({ apiKey: "sk-test" }).chat("gpt-4.1-mini", {})
|
|
|
|
|
|
|
|
// @ts-expect-error auth is an override, so OpenAI Chat rejects apiKey with auth.
|
|
// @ts-expect-error auth is an override, so OpenAI Chat rejects apiKey with auth.
|
|
|
-OpenAI.configure({ apiKey: "sk-test", auth: RuntimeAuth.bearer("oauth-token") })
|
|
|
|
|
|
|
+OpenAI.configure({ apiKey: "sk-test", auth: Auth.bearer("oauth-token") })
|
|
|
|
|
|
|
|
// @ts-expect-error Azure requires at least one of `resourceName` or `baseURL`.
|
|
// @ts-expect-error Azure requires at least one of `resourceName` or `baseURL`.
|
|
|
Azure.configure()
|
|
Azure.configure()
|
|
|
Azure.configure({ apiKey: "azure-key", resourceName: "resource" }).responses("deployment")
|
|
Azure.configure({ apiKey: "azure-key", resourceName: "resource" }).responses("deployment")
|
|
|
Azure.configure({ apiKey: configApiKey, resourceName: "resource" }).responses("deployment")
|
|
Azure.configure({ apiKey: configApiKey, resourceName: "resource" }).responses("deployment")
|
|
|
-Azure.configure({ auth: RuntimeAuth.header("api-key", "azure-key"), resourceName: "resource" }).responses("deployment")
|
|
|
|
|
|
|
+Azure.configure({ auth: Auth.header("api-key", "azure-key"), resourceName: "resource" }).responses("deployment")
|
|
|
|
|
|
|
|
// @ts-expect-error Azure model selectors only accept deployment ids.
|
|
// @ts-expect-error Azure model selectors only accept deployment ids.
|
|
|
Azure.configure({ apiKey: "azure-key", resourceName: "resource" }).responses("deployment", {})
|
|
Azure.configure({ apiKey: "azure-key", resourceName: "resource" }).responses("deployment", {})
|
|
|
|
|
|
|
|
// @ts-expect-error auth is an override, so Azure rejects apiKey with auth.
|
|
// @ts-expect-error auth is an override, so Azure rejects apiKey with auth.
|
|
|
-Azure.configure({ resourceName: "resource", apiKey: "azure-key", auth: RuntimeAuth.header("api-key", "override") })
|
|
|
|
|
|
|
+Azure.configure({ resourceName: "resource", apiKey: "azure-key", auth: Auth.header("api-key", "override") })
|
|
|
|
|
|
|
|
Azure.configure({ apiKey: "azure-key", resourceName: "resource" }).chat("deployment")
|
|
Azure.configure({ apiKey: "azure-key", resourceName: "resource" }).chat("deployment")
|
|
|
Azure.configure({ apiKey: configApiKey, resourceName: "resource" }).chat("deployment")
|
|
Azure.configure({ apiKey: configApiKey, resourceName: "resource" }).chat("deployment")
|
|
|
-Azure.configure({ auth: RuntimeAuth.header("api-key", "azure-key"), resourceName: "resource" }).chat("deployment")
|
|
|
|
|
|
|
+Azure.configure({ auth: Auth.header("api-key", "azure-key"), resourceName: "resource" }).chat("deployment")
|
|
|
|
|
|
|
|
// @ts-expect-error Azure chat model selectors only accept deployment ids.
|
|
// @ts-expect-error Azure chat model selectors only accept deployment ids.
|
|
|
Azure.configure({ apiKey: "azure-key", resourceName: "resource" }).chat("deployment", {})
|
|
Azure.configure({ apiKey: "azure-key", resourceName: "resource" }).chat("deployment", {})
|
|
|
|
|
|
|
|
// @ts-expect-error auth is an override, so Azure Chat rejects apiKey with auth.
|
|
// @ts-expect-error auth is an override, so Azure Chat rejects apiKey with auth.
|
|
|
-Azure.configure({ resourceName: "resource", apiKey: "azure-key", auth: RuntimeAuth.header("api-key", "override") })
|
|
|
|
|
|
|
+Azure.configure({ resourceName: "resource", apiKey: "azure-key", auth: Auth.header("api-key", "override") })
|
|
|
|
|
|
|
|
Anthropic.configure({ apiKey: "anthropic-key" }).model("claude-haiku")
|
|
Anthropic.configure({ apiKey: "anthropic-key" }).model("claude-haiku")
|
|
|
// @ts-expect-error Anthropic model selectors only accept model ids.
|
|
// @ts-expect-error Anthropic model selectors only accept model ids.
|
|
@@ -165,7 +164,7 @@ Google.configure({ apiKey: "google-key" }).model("gemini-2.5-flash", {})
|
|
|
|
|
|
|
|
GoogleVertex.configure({ apiKey: "vertex-key" }).model("gemini-3.5-flash")
|
|
GoogleVertex.configure({ apiKey: "vertex-key" }).model("gemini-3.5-flash")
|
|
|
GoogleVertex.configure({ accessToken: "vertex-token", project: "project" }).model("gemini-3.5-flash")
|
|
GoogleVertex.configure({ accessToken: "vertex-token", project: "project" }).model("gemini-3.5-flash")
|
|
|
-GoogleVertex.configure({ auth: RuntimeAuth.bearer("vertex-token"), project: "project" }).model("gemini-3.5-flash")
|
|
|
|
|
|
|
+GoogleVertex.configure({ auth: Auth.bearer("vertex-token"), project: "project" }).model("gemini-3.5-flash")
|
|
|
// @ts-expect-error Vertex Gemini model selectors only accept model ids.
|
|
// @ts-expect-error Vertex Gemini model selectors only accept model ids.
|
|
|
GoogleVertex.configure({ apiKey: "vertex-key" }).model("gemini-3.5-flash", {})
|
|
GoogleVertex.configure({ apiKey: "vertex-key" }).model("gemini-3.5-flash", {})
|
|
|
// @ts-expect-error Vertex Gemini config accepts only one auth source.
|
|
// @ts-expect-error Vertex Gemini config accepts only one auth source.
|
|
@@ -174,7 +173,7 @@ GoogleVertex.configure({ accessToken: "vertex-token", apiKey: "vertex-key", proj
|
|
|
GoogleVertex.model("gemini-3.5-flash", { accessToken: "vertex-token", apiKey: "vertex-key", project: "project" })
|
|
GoogleVertex.model("gemini-3.5-flash", { accessToken: "vertex-token", apiKey: "vertex-key", project: "project" })
|
|
|
|
|
|
|
|
GoogleVertexChat.configure({ accessToken: "vertex-token", project: "project" }).model("deepseek-ai/deepseek-v3.2-maas")
|
|
GoogleVertexChat.configure({ accessToken: "vertex-token", project: "project" }).model("deepseek-ai/deepseek-v3.2-maas")
|
|
|
-GoogleVertexChat.configure({ auth: RuntimeAuth.bearer("vertex-token"), project: "project" }).model(
|
|
|
|
|
|
|
+GoogleVertexChat.configure({ auth: Auth.bearer("vertex-token"), project: "project" }).model(
|
|
|
"deepseek-ai/deepseek-v3.2-maas",
|
|
"deepseek-ai/deepseek-v3.2-maas",
|
|
|
)
|
|
)
|
|
|
// @ts-expect-error Vertex Chat package settings do not accept API keys.
|
|
// @ts-expect-error Vertex Chat package settings do not accept API keys.
|
|
@@ -187,12 +186,12 @@ GoogleVertexChat.configure({ accessToken: "vertex-token", project: "project" }).
|
|
|
GoogleVertexChat.configure({
|
|
GoogleVertexChat.configure({
|
|
|
accessToken: "vertex-token",
|
|
accessToken: "vertex-token",
|
|
|
// @ts-expect-error Vertex Chat config accepts only one auth source.
|
|
// @ts-expect-error Vertex Chat config accepts only one auth source.
|
|
|
- auth: RuntimeAuth.bearer("vertex-token"),
|
|
|
|
|
|
|
+ auth: Auth.bearer("vertex-token"),
|
|
|
project: "project",
|
|
project: "project",
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
GoogleVertexResponses.configure({ accessToken: "vertex-token", project: "project" }).model("xai/grok-4.20-reasoning")
|
|
GoogleVertexResponses.configure({ accessToken: "vertex-token", project: "project" }).model("xai/grok-4.20-reasoning")
|
|
|
-GoogleVertexResponses.configure({ auth: RuntimeAuth.bearer("vertex-token"), project: "project" }).model(
|
|
|
|
|
|
|
+GoogleVertexResponses.configure({ auth: Auth.bearer("vertex-token"), project: "project" }).model(
|
|
|
"xai/grok-4.20-reasoning",
|
|
"xai/grok-4.20-reasoning",
|
|
|
)
|
|
)
|
|
|
// @ts-expect-error Vertex Responses package settings do not accept API keys.
|
|
// @ts-expect-error Vertex Responses package settings do not accept API keys.
|
|
@@ -205,16 +204,14 @@ GoogleVertexResponses.configure({ accessToken: "vertex-token", project: "project
|
|
|
GoogleVertexResponses.configure({
|
|
GoogleVertexResponses.configure({
|
|
|
accessToken: "vertex-token",
|
|
accessToken: "vertex-token",
|
|
|
// @ts-expect-error Vertex Responses config accepts only one auth source.
|
|
// @ts-expect-error Vertex Responses config accepts only one auth source.
|
|
|
- auth: RuntimeAuth.bearer("vertex-token"),
|
|
|
|
|
|
|
+ auth: Auth.bearer("vertex-token"),
|
|
|
project: "project",
|
|
project: "project",
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
GoogleVertexMessages.configure({ accessToken: "vertex-token", project: "project" }).model("claude-sonnet-4-6")
|
|
GoogleVertexMessages.configure({ accessToken: "vertex-token", project: "project" }).model("claude-sonnet-4-6")
|
|
|
// @ts-expect-error Vertex Messages package settings do not accept API keys.
|
|
// @ts-expect-error Vertex Messages package settings do not accept API keys.
|
|
|
GoogleVertexMessages.model("claude-sonnet-4-6", { apiKey: "vertex-key", project: "project" })
|
|
GoogleVertexMessages.model("claude-sonnet-4-6", { apiKey: "vertex-key", project: "project" })
|
|
|
-GoogleVertexMessages.configure({ auth: RuntimeAuth.bearer("vertex-token"), project: "project" }).model(
|
|
|
|
|
- "claude-sonnet-4-6",
|
|
|
|
|
-)
|
|
|
|
|
|
|
+GoogleVertexMessages.configure({ auth: Auth.bearer("vertex-token"), project: "project" }).model("claude-sonnet-4-6")
|
|
|
GoogleVertexMessages.configure({ accessToken: "vertex-token", project: "project" }).model(
|
|
GoogleVertexMessages.configure({ accessToken: "vertex-token", project: "project" }).model(
|
|
|
"claude-sonnet-4-6",
|
|
"claude-sonnet-4-6",
|
|
|
// @ts-expect-error Vertex Messages model selectors only accept model ids.
|
|
// @ts-expect-error Vertex Messages model selectors only accept model ids.
|
|
@@ -223,7 +220,7 @@ GoogleVertexMessages.configure({ accessToken: "vertex-token", project: "project"
|
|
|
GoogleVertexMessages.configure({
|
|
GoogleVertexMessages.configure({
|
|
|
accessToken: "vertex-token",
|
|
accessToken: "vertex-token",
|
|
|
// @ts-expect-error Vertex Messages config accepts only one auth source.
|
|
// @ts-expect-error Vertex Messages config accepts only one auth source.
|
|
|
- auth: RuntimeAuth.bearer("vertex-token"),
|
|
|
|
|
|
|
+ auth: Auth.bearer("vertex-token"),
|
|
|
project: "project",
|
|
project: "project",
|
|
|
})
|
|
})
|
|
|
|
|
|