refactor(ai): callable providers

This commit is contained in:
Aiden Cline 2026-10-31 16:41:31 -05:00
parent 01276f9061
commit 1306fee462
272 changed files with 3369 additions and 3120 deletions

View file

@ -8,11 +8,9 @@ and `ai.write` load `node:fs/promises` on first use, so no Effect `FileSystem` i
```ts
import { ai } from "@opencode/ai"
import { OpenAI } from "@opencode/ai/providers"
import { openai } from "@opencode/ai/providers"
const openai = OpenAI.configure({ apiKey: process.env.OPENAI_API_KEY })
const input = { model: openai.responses("gpt-4o-mini"), prompt: "Say hello." }
const input = { model: openai("gpt-4o-mini"), prompt: "Say hello." }
const response = await ai.generate(input)
console.log(response.text)
const generated = await ai.image.generate({ model: openai.image("gpt-image-2"), prompt: "A lighthouse" })
@ -28,13 +26,11 @@ The Effect API lives at `@opencode/ai/effect`. Its `ai` has the same namespaces
```ts
import { Effect } from "effect"
import { ai, AIClient } from "@opencode/ai/effect"
import { OpenAI } from "@opencode/ai/providers"
const openai = OpenAI.configure({ apiKey: process.env.OPENAI_API_KEY })
import { openai } from "@opencode/ai/providers"
const program = Effect.gen(function* () {
const response = yield* ai.generate({
model: openai.responses("gpt-4o-mini"), // `.chat(...)` selects the Chat Completions API instead
model: openai("gpt-4o-mini"), // `openai.chat(...)` selects the Chat Completions API instead
system: "You are concise.",
prompt: "Say hello in one short sentence.",
generation: { maxTokens: 40 },
@ -161,16 +157,15 @@ const events = ai
### Google Interactions
`Google.configure({ apiKey }).interactions(modelID)` selects the Interactions API; `.model(modelID)` still selects
GenerateContent. The package entrypoint is `@opencode/ai/providers/google/interactions`.
`google.interactions(modelID)` selects the Interactions API; `google(modelID)` still selects GenerateContent. The package entrypoint is `@opencode/ai/providers/google/interactions`.
For Vertex AI, use `GoogleVertexInteractions.configure({ project, location: "global" }).model(modelID)` or
For Vertex AI, use `googleVertexInteractions.configure({ project, location: "global" })(modelID)` or
`@opencode/ai/providers/google-vertex/interactions`. It uses Application Default Credentials by default, accepts
an explicit `accessToken` or `auth` override, and supports Express mode with `apiKey`. Vertex metadata and raw usage
live under `providerMetadata.vertex`. The default is still full-history replay with `store: false`.
```ts
const model = Google.configure({ apiKey }).interactions("gemini-3.8-flash")
const model = google.configure({ apiKey }).interactions("gemini-3.8-flash")
const response =
yield *
ai.generate({
@ -231,17 +226,17 @@ const everything = AIClient.layerWith(logged) // or AI.make({ layer: logged })
## Venice AI
`Venice` provides native Chat Completions with streaming tools and reasoning. `model` and `chat`
`venice` provides native Chat Completions with streaming tools and reasoning. `venice(modelID)` and `venice.chat`
select the same API, and `responses` selects its Responses API; credentials default to `VENICE_API_KEY`.
```ts
import { ai } from "@opencode/ai/effect"
import { Venice } from "@opencode/ai/providers"
import { venice } from "@opencode/ai/providers"
import { Effect } from "effect"
const program = Effect.gen(function* () {
const response = yield* ai.generate({
model: Venice.configure({ apiKey: process.env.VENICE_API_KEY }).chat("qwen3-6-27b"),
model: venice.configure({ apiKey: process.env.VENICE_API_KEY }).chat("qwen3-6-27b"),
prompt: "Explain this design.",
providerOptions: {
reasoningEffort: "high",
@ -272,10 +267,10 @@ values, or a `score` on ordered levels, each with the probability of every optio
```ts
import { Effect } from "effect"
import { ai, DecisionClient, Media } from "@opencode/ai/effect"
import { OpenAI } from "@opencode/ai/providers"
import { openai } from "@opencode/ai/providers"
const program = ai.decision.generate({
model: OpenAI.configure().decision("gpt-6-luna"),
model: openai.decision("gpt-6-luna"),
input: [
{ type: "text", text: "I was charged twice. Please refund the duplicate payment." },
{ type: "media", media: Media.url("https://example.com/receipt.png", { mediaType: "image/png" }) },
@ -312,24 +307,24 @@ Media goes wherever the host reads it, and a kind the host has no place for fail
```ts
import {
Baseten,
CloudflareAIGateway,
CloudflareWorkersAI,
DigitalOcean,
OpenCode,
OpenRouter,
TypeSafeAI,
VercelAIGateway,
baseten,
cloudflareAIGateway,
cloudflareWorkersAI,
digitalocean,
opencode,
openrouter,
typesafeAI,
vercelAIGateway,
} from "@opencode/ai/providers"
TypeSafeAI.configure().decision("jev-latest")
OpenCode.configure().decision("jev-1.13")
OpenRouter.configure().decision("typesafe/jev-1.13")
VercelAIGateway.configure().decision("typesafe-ai/jev")
Baseten.configure().decision("decision-models/baseten-elephant-9b-latest")
DigitalOcean.configure().decision("typesafe-jev-1.13.0")
CloudflareWorkersAI.configure({ accountId }).decision("@cf/cloudflare/clef")
CloudflareAIGateway.configure({ accountId }).decision("typesafe/jev")
typesafeAI.decision("jev-latest")
opencode.decision("jev-1.13")
openrouter.decision("typesafe/jev-1.13")
vercelAIGateway.decision("typesafe-ai/jev")
baseten.decision("decision-models/baseten-elephant-9b-latest")
digitalocean.decision("typesafe-jev-1.13.0")
cloudflareWorkersAI.configure({ accountId }).decision("@cf/cloudflare/clef")
cloudflareAIGateway.configure({ accountId }).decision("typesafe/jev")
```
OpenAI and Vercel AI Gateway use OpenAI's `/v1/decisions` API. TypeSafe, OpenCode, OpenRouter, Baseten and
@ -337,22 +332,22 @@ DigitalOcean use System One (`/systemone`), and Cloudflare sends the System One
## Alibaba Cloud Model Studio
`Alibaba` provides standard Model Studio inference. Configure a region explicitly, then select
Chat Completions (`.model` or `.chat`), Anthropic-compatible Messages (`.messages`), or OpenAI-compatible
`alibaba` provides standard Model Studio inference. Configure a region explicitly, then select
Chat Completions (call it, or `.chat`), Anthropic-compatible Messages (`.messages`), or OpenAI-compatible
Responses (`.responses`). These routes use HTTP/SSE.
```ts
import { ai } from "@opencode/ai/effect"
import { Alibaba } from "@opencode/ai/providers"
import { alibaba } from "@opencode/ai/providers"
const alibaba = Alibaba.configure({
const qwen = alibaba.configure({
region: "ap-southeast-1", // Singapore
apiKey: process.env.DASHSCOPE_API_KEY,
// workspaceID: "llm-your-workspace", // use a workspace-dedicated endpoint
})
const request = ai.request({
model: alibaba.model("qwen3.8-max"),
model: qwen("qwen3.8-max"),
prompt: "Explain this design.",
providerOptions: { reasoningEffort: "medium" },
})
@ -397,7 +392,7 @@ shared host; the entry above follows the base URL table. Dedicated hosts can be
- **Responses:** `reasoningEffort` → `reasoning.effort`, plus `enableThinking`, `store`,
`previousResponseId`, and `conversation`. Omitted `store` retains the API's default (`true`);
set it to `false` for client-managed history. `previousResponseId` requires a stored response.
Hosted tools are `Alibaba.webSearch()`, `Alibaba.webExtractor()`, and `Alibaba.codeInterpreter()`.
Hosted tools are `alibaba.webSearch()`, `alibaba.webExtractor()`, and `alibaba.codeInterpreter()`.
Web extraction is used together with web search. Hosted calls/results carry `providerExecuted: true`.
Omitted options preserve provider defaults. Effort values pass through unchanged and accept future
@ -418,16 +413,15 @@ hours. A complete `baseURL` for images includes `/api/v1`.
## Z.AI
`ZAI` uses the standard API. Chat Completions is the default language-model API;
`zai` uses the standard API. Chat Completions is the default language-model API;
the existing `.image(...)` selector provides image generation.
```ts
import { ai } from "@opencode/ai/effect"
import { ZAI, ZAICodingPlan } from "@opencode/ai/providers"
import { zai, zaiCodingPlan } from "@opencode/ai/providers"
const zai = ZAI.configure({ apiKey: process.env.ZAI_API_KEY })
const request = ai.request({
model: zai.model("glm-5.3"), // also zai.chat("glm-5.3")
model: zai("glm-5.3"), // also zai.chat("glm-5.3")
prompt: "Explain this design.",
providerOptions: {
reasoningEffort: "high",
@ -435,9 +429,8 @@ const request = ai.request({
},
})
const coding = ZAICodingPlan.configure({ apiKey: process.env.ZAI_API_KEY })
const messages = ai.request({
model: coding.messages("glm-5.3"),
model: zaiCodingPlan.messages("glm-5.3"),
prompt: "Explain this design.",
providerOptions: { effort: "high" },
})
@ -445,12 +438,12 @@ const messages = ai.request({
The products have distinct provider identities and endpoints:
| Provider | Selector | Default base URL |
| ----------------------------------- | --------------------------- | ------------------------------------- |
| `ZAI` (`zai`) | `.model`, `.chat`, `.image` | `https://api.z.ai/api/paas/v4` |
| `ZAICodingPlan` (`zai-coding-plan`) | `.model`, `.chat` | `https://api.z.ai/api/coding/paas/v4` |
| `ZAICodingPlan` | `.messages` | `https://api.z.ai/api/anthropic/v1` |
| `ZAICodingPlan` | `.responses` | `https://api.z.ai/api/v1` |
| Provider | Selector | Default base URL |
| ----------------------------------- | ----------------------- | ------------------------------------- |
| `zai` (`zai`) | call, `.chat`, `.image` | `https://api.z.ai/api/paas/v4` |
| `zaiCodingPlan` (`zai-coding-plan`) | call, `.chat` | `https://api.z.ai/api/coding/paas/v4` |
| `zaiCodingPlan` | `.messages` | `https://api.z.ai/api/anthropic/v1` |
| `zaiCodingPlan` | `.responses` | `https://api.z.ai/api/v1` |
Both read `ZAI_API_KEY` when `apiKey` is omitted and support an explicit `auth` override.
Coding Plan requires an active subscription. `baseURL` overrides the selected API's
@ -489,12 +482,10 @@ Moonshot defaults to Chat Completions, with Messages and Responses selectors for
```ts
import { ai } from "@opencode/ai/effect"
import { Moonshot } from "@opencode/ai/providers"
const moonshot = Moonshot.configure({ apiKey: process.env.MOONSHOT_API_KEY })
import { moonshot } from "@opencode/ai/providers"
const request = ai.request({
model: moonshot.model("kimi-k3"), // also moonshot.chat("kimi-k3")
model: moonshot("kimi-k3"), // also moonshot.chat("kimi-k3")
prompt: "Explain the tradeoffs in this design.",
providerOptions: { reasoningEffort: "high" },
})
@ -551,11 +542,10 @@ MiniMax defaults to its Messages API and reads `MINIMAX_API_KEY` when `apiKey` i
```ts
import { Effect } from "effect"
import { ai, AIClient } from "@opencode/ai/effect"
import { MiniMax } from "@opencode/ai/providers"
import { minimax } from "@opencode/ai/providers"
const minimax = MiniMax.configure({ apiKey: process.env.MINIMAX_API_KEY })
const request = ai.request({
model: minimax.model("MiniMax-M3"), // also minimax.messages("MiniMax-M3")
model: minimax("MiniMax-M3"), // also minimax.messages("MiniMax-M3")
prompt: "What is 173 multiplied by 219?",
providerOptions: { thinking: { type: "adaptive" } },
generation: { maxTokens: 1536 },
@ -589,11 +579,10 @@ use `https://api.minimax.cn/v1` for the mainland China platform. `minimax.image(
Use Meta's direct [Model API](https://dev.meta.ai/docs/overview) with `META_API_KEY`:
```ts
import { Meta } from "@opencode/ai/providers"
import { meta } from "@opencode/ai/providers"
const meta = Meta.configure() // or Meta.configure({ apiKey })
const request = ai.request({
model: meta.responses("muse-spark-1.3"), // meta.model(...) also selects Responses
model: meta("muse-spark-1.3"), // Responses; meta.configure({ apiKey }) sets the key explicitly
prompt: "What is 173 multiplied by 219? Reply with the integer.",
providerOptions: { reasoningEffort: "low" },
generation: { maxTokens: 1024 },
@ -620,7 +609,7 @@ with `display: "omitted"`, preserving encrypted `redacted_thinking` in `response
`providerOptions: { effort: "low" }` for depth or `thinking: { type: "enabled", budgetTokens: 1024 }`
for budget compatibility (with `generation.maxTokens > 1024`).
Add `tools: [Meta.webSearch()]` to a Spark Responses or Messages request for hosted web search.
Add `tools: [meta.webSearch()]` to a Spark Responses or Messages request for hosted web search.
Responses exposes hosted results and URL citations in text-part `providerMetadata.meta.annotations`.
To include search result lists, set `include: ["reasoning.encrypted_content", "web_search_call.results"]`.
Messages exposes hosted search calls; the recorded Messages API stream does not supply structured
@ -649,7 +638,7 @@ const edit = ai.image.generate({
The default image format is WEBP; `outputFormat` also accepts PNG/JPEG and `responseFormat: "url"`
returns a signed URL. `aspect` lowers to Meta's `size`, which is only an aspect-ratio hint: Meta renders about 2.5
megapixels whatever you ask, so `resolution` is ignored. For conversational images, select
`meta.responses("muse-image-1.0")` with `tools: [Meta.imageGeneration({ reasoningStrength: "low" })]`.
`meta.responses("muse-image-1.0")` with `tools: [meta.imageGeneration({ reasoningStrength: "low" })]`.
Generated images are provider-executed tool results with file content. Retain `response.message` to
replay the signed image handle on the next request. Muse Image accepts only the `image_generation` tool.
@ -666,9 +655,7 @@ at that ratio, `"2K"` about 2048×2048). Exact sizes, seeds, masks, and output f
```ts
import { ai, Media } from "@opencode/ai/effect"
import { OpenAI } from "@opencode/ai/providers"
const openai = OpenAI.configure({ apiKey: process.env.OPENAI_API_KEY })
import { openai } from "@opencode/ai/providers"
const program = Effect.gen(function* () {
const response = yield* ai.image.generate({
@ -779,10 +766,10 @@ const medium = ai.image.generate({
xAI image models use the same request API with xAI-native controls:
```ts
import { XAI } from "@opencode/ai/providers"
import { xai } from "@opencode/ai/providers"
const xai = ai.image.generate({
model: XAI.configure({ apiKey }).image("any-model-id"),
model: xai.configure({ apiKey }).image("any-model-id"),
prompt,
n: 2,
aspect: "16:9",
@ -798,11 +785,11 @@ const xai = ai.image.generate({
Google's current Gemini image models use the same direct API:
```ts
import { Google } from "@opencode/ai/providers"
import { google } from "@opencode/ai/providers"
const googleProgram = Effect.gen(function* () {
const response = yield* ai.image.generate({
model: Google.configure({ apiKey }).image("any-model-id"),
model: google.configure({ apiKey }).image("any-model-id"),
prompt: "A robot tending a rooftop garden",
aspect: "16:9",
resolution: "2K",
@ -827,10 +814,10 @@ their mapped aliases, and `http.body` is the final deep overlay. The selected mo
Z.ai image models infer open Z.ai-native options from the selected model:
```ts
import { ZAI } from "@opencode/ai/providers"
import { zai } from "@opencode/ai/providers"
const zai = ai.image.generate({
model: ZAI.configure({ apiKey }).image("any-model-id"),
model: zai.configure({ apiKey }).image("any-model-id"),
prompt,
providerOptions: {
quality: "hd",
@ -848,10 +835,10 @@ persist the bytes promptly if they must remain available.
### MiniMax images
```ts
import { MiniMax } from "@opencode/ai/providers"
import { minimax } from "@opencode/ai/providers"
const minimax = ai.image.generate({
model: MiniMax.configure({ apiKey }).image("image-01"),
model: minimax.configure({ apiKey }).image("image-01"),
prompt,
n: 2,
aspect: "16:9",
@ -886,7 +873,7 @@ const previews = ai.image
The provider may send fewer previews than requested when the final image is ready first.
Imagen is not available: Google shut it down on the Gemini API, and Vertex discontinued the Imagen 4 models on
2026-06-30. `Google.image(...)` uses Gemini-native image models.
2026-06-30. `google.image(...)` uses Gemini-native image models.
Conversational image generation remains part of the LLM interaction. OpenAI Responses exposes it through its hosted image tool:
@ -894,9 +881,9 @@ Conversational image generation remains part of the LLM interaction. OpenAI Resp
const program = Effect.gen(function* () {
const response = yield* ai.generate(
ai.request({
model: OpenAI.configure({ apiKey }).responses("gpt-5"),
model: openai.configure({ apiKey }).responses("gpt-5"),
prompt: "Design a solarpunk rooftop garden, then show me.",
tools: [OpenAI.imageGeneration({ quality: "high" })],
tools: [openai.imageGeneration({ quality: "high" })],
}),
)
@ -945,16 +932,14 @@ part of the same experimental surface.
### Video generation
Video mirrors `Image` with one difference: every provider is asynchronous, so the route is a submit-then-poll
`Generation`. Models come from `.video(...)` selectors on the `Google` (Veo), `XAI`, and `Runway` facades.
`Generation`. Models come from `.video(...)` selectors on `google` (Veo), `xai`, and `runway`.
Common fields (`frames`, `references`, `video`, `durationSeconds`, `aspect`, `resolution`, `audio`, `n`, `seed`,
`negativePrompt`) lower natively or fail with a typed `AIError` before any network call; provider-native controls live
under `providerOptions`, inferred from the selected model.
```ts
import { Video } from "@opencode/ai/experimental"
import { Google, Runway } from "@opencode/ai/providers"
const google = Google.configure({ apiKey: process.env.GOOGLE_GENERATIVE_AI_API_KEY })
import { google, runway } from "@opencode/ai/providers"
// Simple: submit and wait.
const program = Effect.gen(function* () {
@ -989,7 +974,7 @@ const controlled = Effect.gen(function* () {
})
// Progress as a stream: generation-queued | generation-progress | video | finish.
const events = Video.stream({ model: Runway.configure({ apiKey }).video("gen4.5"), prompt }, { poll })
const events = Video.stream({ model: runway.configure({ apiKey }).video("gen4.5"), prompt }, { poll })
```
Status polls, result fetches, cancels, and asset downloads all run through the same request executor with the route's
@ -1033,16 +1018,14 @@ await ai.write(video.video, "./kite.mp4")
Speech (text-to-speech) is one request whose response is parsed incrementally, so every route supports both
`Speech.generate` (the whole file) and `Speech.stream` (audio chunks as they arrive). Models come from `.speech(...)`
selectors on the `OpenAI`, `Google` (Gemini TTS), `ElevenLabs`, `Cartesia`, and `Deepgram` facades. Common fields
selectors on `openai`, `google` (Gemini TTS), `elevenlabs`, `cartesia`, and `deepgram`. Common fields
(`voice`, `format`, `speed`, `language`, `instructions`, `timestamps`) lower natively or fail with a typed `AIError`
before any network call; provider-native controls live under `providerOptions`, inferred from the selected model.
```ts
import { Media } from "@opencode/ai/effect"
import { Speech, SpeechEvent } from "@opencode/ai/experimental"
import { ElevenLabs, OpenAI } from "@opencode/ai/providers"
const openai = OpenAI.configure({ apiKey: process.env.OPENAI_API_KEY })
import { elevenlabs, openai } from "@opencode/ai/providers"
// The whole file, written to disk.
const program = Effect.gen(function* () {
@ -1060,7 +1043,7 @@ const program = Effect.gen(function* () {
// Chunks as they arrive: audio-delta* (interleaved with timestamps) then one finish carrying the assembled asset.
const events = Speech.stream({
model: ElevenLabs.configure({ apiKey }).speech("eleven_flash_v2_5"),
model: elevenlabs.configure({ apiKey }).speech("eleven_flash_v2_5"),
text: "Hello from OpenCode.",
voice: "JBFqnCBsd6RMkjVDRZzb",
format: "pcm",
@ -1119,8 +1102,8 @@ for await (const event of ai.experimental.speech.stream({ model, text: "Hello fr
Transcription (speech-to-text) is the one modality whose providers use every route kind: OpenAI and Gemini stream,
Deepgram and ElevenLabs answer inline, and AssemblyAI is queued. `Transcription.generate` and `Transcription.stream`
work on all of them; `Transcription.start` / `resume` return a `Generation` on queued routes and fail with
`UnsupportedOperation` elsewhere. Models come from `.transcription(...)` selectors on the `OpenAI`, `Google`,
`Deepgram`, `ElevenLabs`, and `AssemblyAI` facades. Common fields (`language`, `prompt`,
`UnsupportedOperation` elsewhere. Models come from `.transcription(...)` selectors on `openai`, `google`,
`deepgram`, `elevenlabs`, and `assemblyai`. Common fields (`language`, `prompt`,
`timestamps: "none" | "segment" | "word"`, `diarize`, `speakers`) lower natively or fail with a typed `AIError` before
any network call; a route may return more than asked.
@ -1128,16 +1111,14 @@ any network call; a route may return more than asked.
import { Console, Effect, Stream } from "effect"
import { Media } from "@opencode/ai/effect"
import { Transcription, TranscriptionEvent } from "@opencode/ai/experimental"
import { AssemblyAI, Deepgram, OpenAI } from "@opencode/ai/providers"
const openai = OpenAI.configure({ apiKey: process.env.OPENAI_API_KEY })
import { assemblyai, deepgram, openai } from "@opencode/ai/providers"
const program = Effect.gen(function* () {
const audio = yield* Media.file("./call.mp3")
// Speaker-labelled segments; labels are provider-native strings ("A", "0", "spk:0", "speaker_0").
const response = yield* Transcription.generate({
model: Deepgram.configure({ apiKey }).transcription("nova-3"),
model: deepgram.configure({ apiKey }).transcription("nova-3"),
audio,
diarize: true,
timestamps: "word",
@ -1154,7 +1135,7 @@ const program = Effect.gen(function* () {
)
// Queued: persist the token with the provider and model ID (the token alone cannot pick the model), resume, and await.
const model = AssemblyAI.configure({ apiKey }).transcription("universal-3-5-pro")
const model = assemblyai.configure({ apiKey }).transcription("universal-3-5-pro")
const generation = yield* Transcription.start({ model, audio })
const resumed = yield* Transcription.resume(model, JSON.parse(JSON.stringify(generation.token)))
const transcript = yield* resumed.await({ poll: { interval: "3 seconds" } })
@ -1196,11 +1177,11 @@ match; other types are sent and answered as-is. Only Cloudflare's Clairic serves
```ts
import { ai } from "@opencode/ai"
import { Extraction } from "@opencode/ai/experimental"
import { CloudflareWorkersAI } from "@opencode/ai/providers"
import { cloudflareWorkersAI } from "@opencode/ai/providers"
const response = await ai.run(
Extraction.generate({
model: CloudflareWorkersAI.configure({ accountId }).experimental.extraction("@cf/cloudflare/clairic"),
model: cloudflareWorkersAI.configure({ accountId }).experimental.extraction("@cf/cloudflare/clairic"),
input: "Invoice INV-2291, issued 2026-09-02, net 30. Total $1,080.00. Contact: Dana Ruiz, Priya Shah.",
fields: {
invoiceNumber: { type: "text" },
@ -1349,10 +1330,10 @@ Enable OpenAI compaction with typed provider options:
```ts
import { Effect } from "effect"
import { ai, LLMClient, Message } from "@opencode/ai/effect"
import { OpenAI } from "@opencode/ai/providers"
import { openai } from "@opencode/ai/providers"
const request = ai.request({
model: OpenAI.configure({ apiKey }).responses("gpt-5.3-codex"),
model: openai.configure({ apiKey }).responses("gpt-5.3-codex"),
messages,
providerOptions: {
contextManagement: [{ type: "compaction", compactThreshold: 200_000 }],
@ -1492,18 +1473,28 @@ Normalized cache usage is read back into `response.usage.cacheReadInputTokens` a
## Providers
Provider facades configure endpoint/auth/deployment details first, then expose model selectors that take only a model or deployment id. The selected model carries the executable route value used at runtime.
Each provider is a function. Calling it selects the provider's default API and reads the API key from the
environment: `openai("gpt-5.4")` is a Responses model and `anthropic("claude-sonnet-4-6")` a Messages model. Named
methods select another API (`openai.chat`, `google.interactions`, `minimax.chat`) or modality (`openai.image`,
`google.video`). `configure(config)` returns the same shape with an API key, base URL, headers, or default options:
```ts
import { OpenAI, CloudflareAIGateway } from "@opencode/ai/providers"
import { azure, openai } from "@opencode/ai/providers"
const openai = OpenAI.configure({ apiKey: process.env.OPENAI_API_KEY }).responses("gpt-4o-mini")
const gateway = CloudflareAIGateway.configure({
accountId,
gatewayApiKey: process.env.CLOUDFLARE_API_TOKEN,
}).model("workers-ai/@cf/meta/llama-3.1-8b-instruct")
openai("gpt-5.4")
openai.chat("gpt-5.4")
const gateway = openai.configure({ apiKey, baseURL: "https://gateway.example/v1" })
gateway("gpt-5.4")
// Providers without a default endpoint take their config on the call or through `configure`.
azure("gpt-5.4", { resourceName: "my-resource" })
azure.configure({ resourceName: "my-resource" }).chat("gpt-5.4")
```
Building a model does not touch the client, so the same providers work with the Promise and Effect APIs. Each
`@opencode/ai/providers/<provider>` module exports the same function. Its `model(modelID, settings)` export and the
`@opencode/ai/providers/<provider>/<api>` entrypoints load models from flat, serializable settings for catalogs.
For a provider that needs no key, such as a local server, pass `apiKey: false`: the package skips the environment lookup and sends no auth header (Amazon Bedrock and Google Vertex keep their own auth).
Included LLM providers: OpenAI, Anthropic, Google (Gemini), Google Vertex, Amazon Bedrock (Converse and Mantle), Azure OpenAI, Alibaba, Baseten, Cerebras, Cohere, Cloudflare AI Gateway, Cloudflare Workers AI, DeepInfra, DeepSeek, DigitalOcean, Fireworks, Groq, Meta, MiniMax, Mistral, Moonshot, OpenRouter, TogetherAI, Venice, Vercel AI Gateway, xAI, Z.ai, and Z.ai Coding Plan. TypeSafe AI and OpenCode expose decision models only. Generic Chat Completions, Responses, and Anthropic Messages-compatible entrypoints support custom endpoints.
@ -1511,17 +1502,17 @@ Included LLM providers: OpenAI, Anthropic, Google (Gemini), Google Vertex, Amazo
Each named provider owns its module, endpoint, authentication, and route setup. Providers with the same wire format compose the shared protocol directly:
```ts
import { DeepSeek, Fireworks } from "@opencode/ai/providers"
import { deepseek, fireworks } from "@opencode/ai/providers"
const deepseek = DeepSeek.configure({ apiKey }).model("deepseek-chat")
const fireworks = Fireworks.configure({ apiKey }).model("accounts/fireworks/models/my-model")
deepseek("deepseek-chat")
fireworks.configure({ apiKey })("accounts/fireworks/models/my-model")
```
The former `OpenAICompatible.baseten`, `.cerebras`, `.deepinfra`, `.deepseek`, `.fireworks`, `.groq`, and `.togetherai` presets are replaced by the top-level `Baseten`, `Cerebras`, `DeepInfra`, `DeepSeek`, `Fireworks`, `Groq`, and `TogetherAI` exports. Use `CloudflareAIGateway` and `CloudflareWorkersAI` directly; each has its own module. `OpenAICompatible` configures generic endpoints with an explicit `baseURL`.
`openaiCompatible` configures generic Chat Completions endpoints with an explicit `baseURL`; `openaiCompatibleResponses` and `anthropicCompatible` do the same for Responses and Anthropic Messages.
### Provider entrypoints
Provider modules are available through dedicated exports from `@opencode/ai`. Each LLM entrypoint exports `model(modelID, settings)`, where `settings` contains provider configuration plus common `headers` and `body` overlays.
Provider modules are available through dedicated exports from `@opencode/ai`. Each one exports `model(modelID, settings)`, where `settings` is flat and serializable: provider configuration plus common `headers` and `body` overlays. OpenCode loads catalog models this way.
```ts
import { model } from "@opencode/ai/providers/openai/responses"

View file

@ -4,7 +4,7 @@ import { NodeFileSystem } from "@effect/platform-node"
import { ai, AIClient, Media, Message, ProviderID, ToolRuntime } from "@opencode/ai/effect"
import { tool } from "@opencode/ai/effect"
import { Route, Auth, Endpoint, Framing, Protocol, RequestExecutor } from "@opencode/ai/route"
import { OpenAI } from "@opencode/ai/providers"
import { openai } from "@opencode/ai/providers"
/**
* A runnable walkthrough of the LLM package use-site API.
@ -22,18 +22,19 @@ import { OpenAI } from "@opencode/ai/providers"
const apiKey = Config.Redacted("OPENAI_API_KEY")
// 1. Configure a provider. The configured facade records provider identity,
// deployment options, authentication, and defaults. Per-modality selectors pick
// the API: `.responses(...)` / `.chat(...)` for LLM calls and `.image(...)` for
// image generation.
const openai = OpenAI.configure({
// 1. Pick a provider. Calling it selects its default API: `openai("gpt-4o-mini")`
// is a Responses model that reads `OPENAI_API_KEY`. `configure(...)` returns the
// same callable shape with provider identity, deployment options,
// authentication, and defaults. Named methods pick another API: `.chat(...)`
// for Chat Completions and `.image(...)` for image generation.
const configured = openai.configure({
apiKey,
generation: { maxTokens: 160 },
providerOptions: {
store: false,
},
})
const model = openai.responses("gpt-4o-mini")
const model = configured("gpt-4o-mini")
// 2. Build a provider-neutral request. This is useful when reusing one request
// across generate and stream examples.
@ -209,15 +210,14 @@ const FakeAdapter = Route.make({
framing: Framing.sse,
})
// A provider module exports a configured facade. Configuration happens before
// model selection; model selectors accept ids only.
const FakeEcho = {
id: ProviderID.make("fake-echo"),
configure: () => ({
// A provider module exports a callable provider. Calling it selects the default
// model; `configure` returns the same shape with new deployment options.
const configureFakeEcho = () =>
Object.assign((id: string) => FakeAdapter.model({ id }), {
id: ProviderID.make("fake-echo"),
model: (id: string) => FakeAdapter.model({ id }),
}),
}
configure: configureFakeEcho,
})
const fakeEcho = configureFakeEcho()
// 7. Run the fake provider offline. `RequestExecutor.middleware` sees every HTTP
// request before it is sent; here it answers with two SSE frames instead of
@ -232,7 +232,7 @@ const fakeExecutor = RequestExecutor.middleware((request) =>
)
const generateFake = Effect.gen(function* () {
const response = yield* ai.generate({ model: FakeEcho.configure().model("echo-1"), prompt: "Say hello." })
const response = yield* ai.generate({ model: fakeEcho("echo-1"), prompt: "Say hello." })
console.log("\n== fake provider ==")
console.log("generated text:", response.text)
})
@ -242,7 +242,7 @@ const generateFake = Effect.gen(function* () {
// `Media.write` persists them through the Effect `FileSystem`.
const generateImage = Effect.gen(function* () {
const response = yield* ai.image.generate({
model: openai.image("gpt-image-1-mini"),
model: configured.image("gpt-image-1-mini"),
prompt: "A flat black circle centered on a plain white background.",
aspect: "1:1",
// Exact pixel sizes and output formats are provider options.

View file

@ -7,8 +7,9 @@ import { AwsV4Signer } from "aws4fetch"
import { Config, ConfigProvider, Effect, FileSystem, PlatformError, Redacted } from "effect"
import { FetchHttpClient, HttpClient, HttpClientRequest, type HttpClientResponse } from "effect/http"
import * as ProviderShared from "../src/protocols/shared"
import { CloudflareAIGateway } from "../src/providers/cloudflare-ai-gateway.js"
import { CloudflareWorkersAI } from "../src/providers/cloudflare-workers-ai.js"
const cloudflareAIGatewayModule = await import("../src/providers/cloudflare-ai-gateway.js")
const cloudflareWorkersAIModule = await import("../src/providers/cloudflare-workers-ai.js")
type Provider = {
readonly id: string
@ -179,11 +180,11 @@ const PROVIDERS: ReadonlyArray<Provider> = [
],
validate: (env) =>
validateChat({
url: `${CloudflareAIGateway.baseURL({
url: `${cloudflareAIGatewayModule.baseURL({
accountId: env.CLOUDFLARE_ACCOUNT_ID,
gatewayId: env.CLOUDFLARE_GATEWAY_ID || undefined,
})}/chat/completions`,
token: Redacted.make(envValue(env, CloudflareAIGateway.authEnvVars)),
token: Redacted.make(envValue(env, cloudflareAIGatewayModule.authEnvVars)),
tokenHeader: "cf-aig-authorization",
model: "workers-ai/@cf/meta/llama-3.1-8b-instruct",
}),
@ -199,8 +200,8 @@ const PROVIDERS: ReadonlyArray<Provider> = [
],
validate: (env) =>
validateChat({
url: `${CloudflareWorkersAI.baseURL({ accountId: env.CLOUDFLARE_ACCOUNT_ID })}/chat/completions`,
token: Redacted.make(envValue(env, CloudflareWorkersAI.authEnvVars)),
url: `${cloudflareWorkersAIModule.baseURL({ accountId: env.CLOUDFLARE_ACCOUNT_ID })}/chat/completions`,
token: Redacted.make(envValue(env, cloudflareWorkersAIModule.authEnvVars)),
model: "@cf/meta/llama-3.1-8b-instruct",
}),
},

View file

@ -0,0 +1,11 @@
import { Struct } from "effect"
import type { Config, Settings } from "./alibaba.js"
export function config(input: Settings<Config["providerOptions"]>) {
const { body, ...rest } = input
return {
...rest,
http: body === undefined ? undefined : { body },
providerOptions: Struct.omit(rest, ["apiKey", "baseURL", "headers", "region", "workspaceID"]),
}
}

View file

@ -1,4 +1,3 @@
import { Struct } from "effect"
import type { ProviderPackage } from "../provider-package.js"
import { AlibabaChat } from "../protocols/alibaba-chat.js"
import { AlibabaImages } from "../protocols/alibaba-images.js"
@ -9,6 +8,7 @@ import { Route, type RouteDefaultsInput } from "../route/client.js"
import { Endpoint } from "../route/endpoint.js"
import { Framing } from "../route/framing.js"
import { MediaRoute } from "../route/media.js"
import { config } from "./alibaba-settings.js"
import {
ProviderConfigurationError,
ProviderID,
@ -17,7 +17,7 @@ import {
type ProviderOptions,
} from "../schema/index.js"
export const id = ProviderID.make("alibaba")
const id = ProviderID.make("alibaba")
export type Region =
| "ap-southeast-1"
@ -81,9 +81,25 @@ const responsesRoute = Route.make({
framing: Framing.sse,
})
export type MessagesSettings = Settings<MessagesOptionsInput>
export type ResponsesSettings = Settings<ResponsesOptionsInput>
export const routes = [chatRoute, messagesRoute, responsesRoute]
export const configure = (input: Config) => {
const webSearch = () => hostedTool("web_search", "Search the web with Alibaba's hosted search tool.")
const webExtractor = () => hostedTool("web_extractor", "Extract web page content with Alibaba's hosted tool.")
const codeInterpreter = () => hostedTool("code_interpreter", "Execute code with Alibaba's hosted interpreter.")
function hostedTool(type: "web_search" | "web_extractor" | "code_interpreter", description: string) {
return ToolDefinition.make({
name: type,
description,
inputSchema: { type: "object", properties: {} },
native: { alibaba: { type } },
})
}
const configure = (input: Config) => {
const { apiKey: _key, auth: _auth, region, workspaceID, baseURL, ...rest } = input
const host =
region === undefined
@ -115,46 +131,25 @@ export const configure = (input: Config) => {
const media = MediaRoute.deployment({ ...input, baseURL: baseURL ?? `https://${host}/api/v1` }, opts.auth)
const image = (id: string | ModelID, providerOptions?: ProviderOptions) =>
AlibabaImages.model({ ...media, id, providerOptions })
return { id, model: chat, chat, messages, responses, image, configure }
}
export const provider = { id, configure }
export const model: ProviderPackage.Model<Settings, ChatOptionsInput> = (id, input) => configure(config(input)).chat(id)
export const messagesModel: ProviderPackage.Model<Settings<MessagesOptionsInput>, MessagesOptionsInput> = (id, input) =>
configure(config(input)).messages(id)
export const responsesModel: ProviderPackage.Model<Settings<ResponsesOptionsInput>, ResponsesOptionsInput> = (
id,
input,
) => configure(config(input)).responses(id)
export const chat = model
export const messages = messagesModel
export const responses = responsesModel
export const imageModel = (id: string, settings: Settings) => {
const input = config(settings)
return configure(input).image(id, input.providerOptions)
}
function config(input: Settings<Config["providerOptions"]>) {
const { body, ...rest } = input
return {
...rest,
http: body === undefined ? undefined : { body },
providerOptions: Struct.omit(rest, ["apiKey", "baseURL", "headers", "region", "workspaceID"]),
}
}
export const webSearch = () => hostedTool("web_search", "Search the web with Alibaba's hosted search tool.")
export const webExtractor = () => hostedTool("web_extractor", "Extract web page content with Alibaba's hosted tool.")
export const codeInterpreter = () => hostedTool("code_interpreter", "Execute code with Alibaba's hosted interpreter.")
function hostedTool(type: "web_search" | "web_extractor" | "code_interpreter", description: string) {
return ToolDefinition.make({
name: type,
description,
inputSchema: { type: "object", properties: {} },
native: { alibaba: { type } },
return Object.assign(chat, {
id,
chat,
messages,
responses,
image,
webSearch,
webExtractor,
codeInterpreter,
configure,
})
}
export * as Alibaba from "./alibaba.js"
export const alibaba = Object.assign((modelID: string | ModelID, input: Config) => configure(input)(modelID), {
id,
webSearch,
webExtractor,
codeInterpreter,
configure,
})
export const model: ProviderPackage.Model<Settings, ChatOptionsInput> = (id, input) => configure(config(input)).chat(id)

View file

@ -1,2 +1,9 @@
export { imageModel as model } from "../alibaba.js"
import { alibaba, type Settings } from "../alibaba.js"
import { config } from "../alibaba-settings.js"
export type { Settings } from "../alibaba.js"
export const model = (modelID: string, settings: Settings) => {
const input = config(settings)
return alibaba.configure(input).image(modelID, input.providerOptions)
}

View file

@ -1,3 +1,8 @@
import type { Alibaba } from "../alibaba.js"
export { messagesModel as model } from "../alibaba.js"
export type Settings = Alibaba.Settings<Alibaba.MessagesOptionsInput>
import type { ProviderPackage } from "../../provider-package.js"
import { alibaba, type MessagesOptionsInput, type MessagesSettings } from "../alibaba.js"
import { config } from "../alibaba-settings.js"
export type { MessagesSettings as Settings } from "../alibaba.js"
export const model: ProviderPackage.Model<MessagesSettings, MessagesOptionsInput> = (modelID, settings) =>
alibaba.configure(config(settings)).messages(modelID)

View file

@ -1,3 +1,8 @@
import type { Alibaba } from "../alibaba.js"
export { responsesModel as model } from "../alibaba.js"
export type Settings = Alibaba.Settings<Alibaba.ResponsesOptionsInput>
import type { ProviderPackage } from "../../provider-package.js"
import { alibaba, type ResponsesOptionsInput, type ResponsesSettings } from "../alibaba.js"
import { config } from "../alibaba-settings.js"
export type { ResponsesSettings as Settings } from "../alibaba.js"
export const model: ProviderPackage.Model<ResponsesSettings, ResponsesOptionsInput> = (modelID, settings) =>
alibaba.configure(config(settings)).responses(modelID)

View file

@ -9,7 +9,7 @@ import { claudeVersion } from "../protocols/utils/claude-model.js"
import { ProviderConfigurationError, ProviderID, type ModelID } from "../schema/index.js"
import { withOpenAIOptions, type OpenAIProviderOptionsInput } from "./openai-options.js"
export const id = ProviderID.make("amazon-bedrock")
const id = ProviderID.make("amazon-bedrock")
export type OpenAIOptionsInput = OpenAIProviderOptionsInput
export type MessagesOptionsInput = AnthropicMessages.ProviderOptionsInput
@ -114,7 +114,7 @@ const defaults = (input: Config) => {
return rest
}
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
if (input.auth === "bearer" && input.apiKey === undefined && process.env.AWS_BEARER_TOKEN_BEDROCK === undefined)
throw new ProviderConfigurationError({ provider: id, message: "Amazon Bedrock Mantle bearer auth requires apiKey" })
if (input.auth === "sigv4" && input.apiKey !== undefined)
@ -141,20 +141,10 @@ export const configure = (input: Config = {}) => {
const messages = (modelID: string | ModelID) =>
configuredMessagesRoute.with(modelDefaults).model<AnthropicMessages.ProviderOptionsInput>({ id: modelID })
return {
id,
model: responses,
chat,
messages,
responses,
configure,
}
return Object.assign(responses, { id, chat, messages, responses, configure })
}
export const provider = configure()
export const chat = provider.chat
export const messages = provider.messages
export const responses = provider.responses
export const amazonBedrockMantle = configure()
const fromSettings = ({
apiKey,

View file

@ -5,7 +5,7 @@ import * as BedrockConverse from "../protocols/bedrock-converse.js"
import type { BedrockCredentials } from "../protocols/bedrock-converse.js"
import { BedrockAuth } from "../protocols/utils/bedrock-auth.js"
export const id = ProviderID.make("amazon-bedrock")
const id = ProviderID.make("amazon-bedrock")
export type Config = RouteDefaultsInput & {
/** Bedrock API key. Falls back to `AWS_BEARER_TOKEN_BEDROCK`; bearer auth takes precedence over SigV4. */
@ -54,16 +54,16 @@ const configuredRoute = (input: Config) => {
})
}
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const route = configuredRoute(input)
return {
return Object.assign((modelID: string | ModelID) => route.model<BedrockConverse.OptionsInput>({ id: modelID }), {
id,
model: (modelID: string | ModelID) => route.model<BedrockConverse.OptionsInput>({ id: modelID }),
configure,
}
})
}
export const provider = configure()
export const amazonBedrock = configure()
export const model: ProviderPackage.Model<Settings, BedrockConverse.OptionsInput> = (
modelID,
{ apiKey, auth, baseURL, credentials, profile, region, topP, headers, body, ...providerOptions }: Settings = {},
@ -79,4 +79,4 @@ export const model: ProviderPackage.Model<Settings, BedrockConverse.OptionsInput
providerOptions,
profile,
region,
}).model(modelID)
})(modelID)

View file

@ -9,7 +9,7 @@ export type AnthropicOptionsInput = AnthropicMessages.OptionsInput
export type AnthropicProviderOptionsInput = AnthropicMessages.ProviderOptionsInput
export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput
export const id = ProviderID.make("anthropic-compatible")
const id = ProviderID.make("anthropic-compatible")
export type Config = RouteDefaultsInput &
ProviderAuthOption<"optional"> & {
@ -33,7 +33,7 @@ export const routes = [compatibleRoute]
const auth = (input: ProviderAuthOption<"optional">) => AuthOptions.apiKey(input, [], Auth.header("x-api-key"))
export const configure = (input: Config) => {
const configure = (input: Config) => {
const provider = input.provider ?? "anthropic-compatible"
if (!input.baseURL)
throw new ProviderConfigurationError({
@ -47,17 +47,19 @@ export const configure = (input: Config) => {
endpoint: { baseURL },
auth: auth(input),
})
return {
id: ProviderID.make(provider),
model: (modelID: string | ModelID) => route.model<AnthropicMessages.ProviderOptionsInput>({ id: modelID }),
configure,
}
return Object.assign(
(modelID: string | ModelID) => route.model<AnthropicMessages.ProviderOptionsInput>({ id: modelID }),
{ id: ProviderID.make(provider), configure },
)
}
export const provider = {
id,
configure,
}
export const anthropicCompatible = Object.assign(
(modelID: string | ModelID, input: Config) => configure(input)(modelID),
{
id,
configure,
},
)
export const model: ProviderPackage.Model<Settings, AnthropicMessages.ProviderOptionsInput> = (
modelID,
@ -75,7 +77,5 @@ export const model: ProviderPackage.Model<Settings, AnthropicMessages.ProviderOp
http: body === undefined ? undefined : { body },
provider,
providerOptions,
}).model(modelID)
})(modelID)
}
export * as AnthropicCompatible from "./anthropic-compatible.js"

View file

@ -4,13 +4,13 @@ import { AuthOptions, type ProviderAuthOption } from "../route/auth-options.js"
import type { ProviderPackage } from "../provider-package.js"
import { ProviderConfigurationError, ProviderID, type ModelID } from "../schema/index.js"
import { AnthropicMessages } from "../protocols/anthropic-messages.js"
import { AnthropicCompatible } from "./anthropic-compatible.js"
import { anthropicCompatible } from "./anthropic-compatible.js"
export type AnthropicOptionsInput = AnthropicMessages.OptionsInput
export type AnthropicProviderOptionsInput = AnthropicMessages.ProviderOptionsInput
export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput
export const id = ProviderID.make("anthropic")
const id = ProviderID.make("anthropic")
export const routes = [AnthropicMessages.route]
@ -32,22 +32,19 @@ export type Settings = ProviderPackage.Settings &
const auth = (options: ProviderAuthOption<"optional">) =>
AuthOptions.apiKey(options, "ANTHROPIC_API_KEY", Auth.header("x-api-key"))
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _, auth: _auth, baseURL, ...rest } = input
const compatible = AnthropicCompatible.configure({
const compatible = anthropicCompatible.configure({
...rest,
auth: auth(input),
baseURL: baseURL ?? AnthropicMessages.DEFAULT_BASE_URL,
provider: id,
})
return {
id,
model: (modelID: string | ModelID) => compatible.model(modelID),
configure,
}
return Object.assign((modelID: string | ModelID) => compatible(modelID), { id, configure })
}
export const provider = configure()
export const anthropic = configure()
export const model: ProviderPackage.Model<Settings, AnthropicMessages.ProviderOptionsInput> = (
modelID,
{ apiKey, authToken, baseURL, body, headers, ...providerOptions }: Settings = {},
@ -63,5 +60,5 @@ export const model: ProviderPackage.Model<Settings, AnthropicMessages.ProviderOp
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).model(modelID)
})(modelID)
}

View file

@ -6,7 +6,7 @@ import { AssemblyAITranscription } from "../protocols/assemblyai-transcription.j
export type { AssemblyAITranscriptionOptions } from "../protocols/assemblyai-transcription.js"
export const id = ProviderID.make("assemblyai")
const id = ProviderID.make("assemblyai")
export type Config = ProviderAuthOption<"optional"> & {
/** `https://api.eu.assemblyai.com` for the EU region. */
@ -19,7 +19,7 @@ export type Config = ProviderAuthOption<"optional"> & {
const auth = (options: ProviderAuthOption<"optional">) =>
AuthOptions.apiKey(options, "ASSEMBLYAI_API_KEY", Auth.header("authorization"))
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const media = MediaRoute.deployment(input, auth(input))
const transcription = (modelID: string | ModelID) => AssemblyAITranscription.model({ ...media, id: modelID })
return {
@ -29,5 +29,4 @@ export const configure = (input: Config = {}) => {
}
}
export const provider = configure()
export const transcription = provider.transcription
export const assemblyai = configure()

View file

@ -0,0 +1,30 @@
import { ProviderConfigurationError, ProviderID } from "../schema/index.js"
import type { Config, Settings } from "./azure.js"
export const config = ({
apiKey,
apiVersion,
baseURL,
body,
headers,
queryParams,
resourceName,
useDeploymentBasedUrls,
...providerOptions
}: Settings<Config["providerOptions"]>): Config => {
const common = {
apiKey,
apiVersion,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
queryParams,
useDeploymentBasedUrls,
}
if (baseURL !== undefined) return { ...common, baseURL }
if (resourceName !== undefined) return { ...common, resourceName }
throw new ProviderConfigurationError({
provider: ProviderID.make("azure"),
message: "Azure requires resourceName or baseURL",
})
}

View file

@ -4,21 +4,15 @@ import type { Route, RouteDefaultsInput, CompactionOperations } from "../route/c
import { Endpoint } from "../route/endpoint.js"
import type { ProviderPackage } from "../provider-package.js"
import { MediaRoute } from "../route/media.js"
import {
HttpOptions,
ProviderConfigurationError,
ProviderID,
mergeHttpOptions,
type ModelID,
type ProviderOptions,
} from "../schema/index.js"
import { HttpOptions, ProviderID, mergeHttpOptions, type ModelID, type ProviderOptions } from "../schema/index.js"
import { AnthropicMessages } from "../protocols/anthropic-messages.js"
import { OpenAIImages } from "../protocols/openai-images.js"
import * as OpenAIChat from "../protocols/openai-chat.js"
import * as OpenAIResponses from "../protocols/openai-responses.js"
import { config } from "./azure-settings.js"
import { withOpenAIOptions, type OpenAIProviderOptionsInput } from "./openai-options.js"
export const id = ProviderID.make("azure")
const id = ProviderID.make("azure")
const routeAuth = Auth.remove("authorization")
const RESPONSES_WEBSOCKET_ROTATE_AFTER_MS = 55 * 60 * 1000
@ -129,7 +123,7 @@ function endpoint(input: Config, modelID: string | ModelID) {
return { baseURL: `${baseURL}/v1`, query }
}
export const configure = (input: Config) => {
const configure = (input: Config) => {
const modelDefaults = defaults(input)
const responses = (modelID: string | ModelID) =>
@ -171,62 +165,15 @@ export const configure = (input: Config) => {
})
}
return {
id,
model: responses,
responses,
chat,
messages,
image,
configure,
}
return Object.assign(responses, { id, responses, chat, messages, image, configure })
}
export const provider = {
export const azure = Object.assign((modelID: string | ModelID, input: Config) => configure(input)(modelID), {
id,
configure,
}
})
const config = ({
apiKey,
apiVersion,
baseURL,
body,
headers,
queryParams,
resourceName,
useDeploymentBasedUrls,
...providerOptions
}: Settings<Config["providerOptions"]>): Config => {
const common = {
apiKey,
apiVersion,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
queryParams,
useDeploymentBasedUrls,
}
if (baseURL !== undefined) return { ...common, baseURL }
if (resourceName !== undefined) return { ...common, resourceName }
throw new ProviderConfigurationError({ provider: id, message: "Azure requires resourceName or baseURL" })
}
export const responsesModel: ProviderPackage.Model<
Settings,
OpenAIProviderOptionsInput,
typeof responsesRoute.compact
> = (modelID, settings) => configure(config(settings)).responses(modelID)
export const chatModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).chat(modelID)
export const messagesModel: ProviderPackage.Model<MessagesSettings, AnthropicMessages.ProviderOptionsInput> = (
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput, typeof responsesRoute.compact> = (
modelID,
settings,
) => configure(config(settings)).messages(modelID)
export const imageModel = (modelID: string, settings: Settings) => {
const input = config(settings)
return configure(input).image(modelID, input.providerOptions)
}
export const model = responsesModel
export const responses = responsesModel
export const chat = chatModel
) => configure(config(settings)).responses(modelID)

View file

@ -1,2 +1,9 @@
export { chatModel as model } from "../azure.js"
import type { ProviderPackage } from "../../provider-package.js"
import { azure, type Settings } from "../azure.js"
import { config } from "../azure-settings.js"
import type { OpenAIProviderOptionsInput } from "../openai-options.js"
export type { Settings } from "../azure.js"
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
azure.configure(config(settings)).chat(modelID)

View file

@ -1,2 +1,9 @@
export { imageModel as model } from "../azure.js"
import { azure, type Settings } from "../azure.js"
import { config } from "../azure-settings.js"
export type { Settings } from "../azure.js"
export const model = (modelID: string, settings: Settings) => {
const input = config(settings)
return azure.configure(input).image(modelID, input.providerOptions)
}

View file

@ -1,2 +1,11 @@
export { messagesModel as model } from "../azure.js"
import type { ProviderPackage } from "../../provider-package.js"
import type { AnthropicMessages } from "../../protocols/anthropic-messages.js"
import { azure, type MessagesSettings } from "../azure.js"
import { config } from "../azure-settings.js"
export type { MessagesSettings as Settings } from "../azure.js"
export const model: ProviderPackage.Model<MessagesSettings, AnthropicMessages.ProviderOptionsInput> = (
modelID,
settings,
) => azure.configure(config(settings)).messages(modelID)

View file

@ -1,2 +1 @@
export { responsesModel as model } from "../azure.js"
export type { Settings } from "../azure.js"
export { model, type Settings } from "../azure.js"

View file

@ -0,0 +1,11 @@
import type { Settings } from "./baseten.js"
export function config({ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}

View file

@ -8,8 +8,9 @@ import { DecisionRoute } from "../route/decision.js"
import { Endpoint } from "../route/endpoint.js"
import { ProviderID, type ModelID, type ProviderOptions } from "../schema/index.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
import { config } from "./baseten-settings.js"
export const id = ProviderID.make("baseten")
const id = ProviderID.make("baseten")
const baseURL = "https://inference.baseten.co/v1"
export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
@ -52,7 +53,7 @@ const decisionProtocol = DecisionRoute.protocol({
},
})
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const auth = AuthOptions.bearer(input, "BASETEN_API_KEY")
const configured = route.with({
@ -72,32 +73,14 @@ export const configure = (input: Config = {}) => {
})
const decision = (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
decisionRoute.model<BasetenDecisionOptions>({ id: modelID, providerOptions })
return {
return Object.assign((modelID: string | ModelID) => configured.model<OpenAIProviderOptionsInput>({ id: modelID }), {
id,
model: (modelID: string | ModelID) => configured.model<OpenAIProviderOptionsInput>({ id: modelID }),
decision,
configure,
}
})
}
export const provider = configure()
export const decision = provider.decision
export const baseten = configure()
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const decisionModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).decision(modelID, input.providerOptions)
}
function config({ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}
export * as Baseten from "./baseten.js"
configure(config(settings))(modelID)

View file

@ -1,2 +1,9 @@
export { decisionModel as model } from "../baseten.js"
import { baseten, type Settings } from "../baseten.js"
import { config } from "../baseten-settings.js"
export type { Settings } from "../baseten.js"
export const model = (modelID: string, settings?: Settings) => {
const input = config(settings)
return baseten.configure(input).decision(modelID, input.providerOptions)
}

View file

@ -5,7 +5,7 @@ import { CartesiaSpeech } from "../protocols/cartesia-speech.js"
export type { CartesiaEncoding, CartesiaSpeechOptions } from "../protocols/cartesia-speech.js"
export const id = ProviderID.make("cartesia")
const id = ProviderID.make("cartesia")
export type Config = ProviderAuthOption<"optional"> & {
readonly baseURL?: string
@ -15,15 +15,10 @@ export type Config = ProviderAuthOption<"optional"> & {
const auth = (options: ProviderAuthOption<"optional">) => AuthOptions.bearer(options, "CARTESIA_API_KEY")
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const media = MediaRoute.deployment(input, auth(input))
const speech = (modelID: string | ModelID) => CartesiaSpeech.model({ ...media, id: modelID })
return {
id,
speech,
configure,
}
return { id, speech, configure }
}
export const provider = configure()
export const speech = provider.speech
export const cartesia = configure()

View file

@ -6,7 +6,7 @@ import { Endpoint } from "../route/endpoint.js"
import { ProviderID, type ModelID } from "../schema/index.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
export const id = ProviderID.make("cerebras")
const id = ProviderID.make("cerebras")
const baseURL = "https://api.cerebras.ai/v1"
export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
@ -32,16 +32,15 @@ export const route = Route.make({
export const routes = [route]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const configured = route.with({
...defaults,
endpoint: { baseURL: endpoint ?? baseURL },
auth: AuthOptions.bearer(input, "CEREBRAS_API_KEY"),
})
return {
id,
model: (modelID: string | ModelID) =>
return Object.assign(
(modelID: string | ModelID) =>
configured.model<OpenAIProviderOptionsInput>({
id: modelID,
compatibility: {
@ -50,11 +49,11 @@ export const configure = (input: Config = {}) => {
supportsPromptCacheKey: true,
},
}),
configure,
}
{ id, configure },
)
}
export const provider = configure()
export const cerebras = configure()
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (
modelID,
@ -66,4 +65,4 @@ export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).model(modelID)
})(modelID)

View file

@ -0,0 +1,33 @@
import type { Settings } from "./cloudflare-ai-gateway.js"
export function config({
accountId,
apiKey,
baseURL: configuredBaseURL,
body,
cacheKey,
cacheTtl,
collectLog,
gatewayApiKey,
gatewayId,
headers,
metadata,
skipCache,
...providerOptions
}: Settings) {
const connection = configuredBaseURL === undefined ? { accountId: accountId ?? "" } : { baseURL: configuredBaseURL }
return {
...connection,
apiKey,
cacheKey,
cacheTtl,
collectLog,
gatewayApiKey,
gatewayId,
headers,
http: body === undefined ? undefined : { body },
metadata,
providerOptions,
skipCache,
}
}

View file

@ -9,8 +9,9 @@ import type { RouteDefaultsInput } from "../route/client.js"
import { ProviderConfigurationError, ProviderID, type ModelID, type ProviderOptions } from "../schema/index.js"
import { encodeJson } from "../utils/json.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
import { config } from "./cloudflare-ai-gateway-settings.js"
export const id = ProviderID.make("cloudflare-ai-gateway")
const id = ProviderID.make("cloudflare-ai-gateway")
export const authEnvVars = ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKEN"] as const
type GatewayURL = AtLeastOne<{
@ -68,7 +69,7 @@ const requireAccountId = (input: GatewayURL) => {
if (input.accountId) return input.accountId
throw new ProviderConfigurationError({
provider: id,
message: "CloudflareAIGateway.configure requires accountId unless baseURL is supplied",
message: "cloudflareAIGateway.configure requires accountId unless baseURL is supplied",
})
}
@ -110,7 +111,7 @@ const headers = (input: Config) => ({
...input.headers,
})
export const configure = (input: Config) => {
const configure = (input: Config) => {
const custom = "auth" in input && input.auth ? input.auth : undefined
const rest = {
endpoint: { baseURL: baseURL(input) },
@ -154,66 +155,20 @@ export const configure = (input: Config) => {
http: input.http,
})
.model({ id: value, providerOptions })
return {
id,
model: (value: string | ModelID) => {
return Object.assign(
(value: string | ModelID) => {
if (value.startsWith("openai/")) return responses(value)
if (value.startsWith("anthropic/")) return messages(value)
return chat(value)
},
chat,
responses,
messages,
decision,
configure,
}
{ id, chat, responses, messages, decision, configure },
)
}
export const provider = { id, configure }
export const cloudflareAIGateway = Object.assign(
(modelID: string | ModelID, input: Config) => configure(input)(modelID),
{ id, configure },
)
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const chat: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).chat(modelID)
export const responses: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).responses(modelID)
export const messages: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).messages(modelID)
export const decisionModel = (modelID: string, settings: Settings) => {
const input = config(settings)
return configure(input).decision(modelID, input.providerOptions)
}
function config({
accountId,
apiKey,
baseURL: configuredBaseURL,
body,
cacheKey,
cacheTtl,
collectLog,
gatewayApiKey,
gatewayId,
headers,
metadata,
skipCache,
...providerOptions
}: Settings) {
const connection = configuredBaseURL === undefined ? { accountId: accountId ?? "" } : { baseURL: configuredBaseURL }
return {
...connection,
apiKey,
cacheKey,
cacheTtl,
collectLog,
gatewayApiKey,
gatewayId,
headers,
http: body === undefined ? undefined : { body },
metadata,
providerOptions,
skipCache,
}
}
export * as CloudflareAIGateway from "./cloudflare-ai-gateway.js"
configure(config(settings))(modelID)

View file

@ -1,2 +1,9 @@
export { decisionModel as model } from "../cloudflare-ai-gateway.js"
import { cloudflareAIGateway, type Settings } from "../cloudflare-ai-gateway.js"
import { config } from "../cloudflare-ai-gateway-settings.js"
export type { Settings } from "../cloudflare-ai-gateway.js"
export const model = (modelID: string, settings: Settings) => {
const input = config(settings)
return cloudflareAIGateway.configure(input).decision(modelID, input.providerOptions)
}

View file

@ -0,0 +1,11 @@
import type { Settings } from "./cloudflare-workers-ai.js"
export function config({ accountId, apiKey, baseURL, body, headers, ...providerOptions }: Settings) {
return {
...(baseURL === undefined ? { accountId: accountId ?? "" } : { baseURL }),
apiKey,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}

View file

@ -9,8 +9,9 @@ import { Endpoint } from "../route/endpoint.js"
import { MediaRoute } from "../route/media.js"
import { ProviderConfigurationError, ProviderID, type ModelID, type ProviderOptions } from "../schema/index.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
import { config } from "./cloudflare-workers-ai-settings.js"
export const id = ProviderID.make("cloudflare-workers-ai")
const id = ProviderID.make("cloudflare-workers-ai")
export const authEnvVars = ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN", "CLOUDFLARE_API_TOKEN"] as const
type WorkersAIURL = AtLeastOne<{
@ -37,7 +38,7 @@ export const baseURL = (input: WorkersAIURL) => {
if (!input.accountId)
throw new ProviderConfigurationError({
provider: id,
message: "CloudflareWorkersAI.configure requires accountId unless baseURL is supplied",
message: "cloudflareWorkersAI.configure requires accountId unless baseURL is supplied",
})
return `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(input.accountId)}/ai/v1`
}
@ -64,7 +65,7 @@ export const route = Route.make({
export const routes = [route]
export const configure = (input: Config) => {
const configure = (input: Config) => {
const { accountId: _accountId, apiKey: _apiKey, auth: _auth, baseURL: _baseURL, ...defaults } = input
const auth = AuthOptions.bearer(input, authEnvVars)
const configured = route.with({ ...defaults, endpoint: { baseURL: baseURL(input) }, auth })
@ -80,9 +81,8 @@ export const configure = (input: Config) => {
http: input.http,
})
.model({ id: modelID, providerOptions })
return {
return Object.assign((modelID: string | ModelID) => configured.model<OpenAIProviderOptionsInput>({ id: modelID }), {
id,
model: (modelID: string | ModelID) => configured.model<OpenAIProviderOptionsInput>({ id: modelID }),
decision,
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
CloudflareWorkersAIImages.model({ ...runDeployment(), id: modelID, providerOptions }),
@ -90,31 +90,13 @@ export const configure = (input: Config) => {
extraction: (modelID: string | ModelID) => CloudflareRunExtraction.model({ ...runDeployment(), id: modelID }),
},
configure,
}
})
}
export const provider = { id, configure }
export const cloudflareWorkersAI = Object.assign(
(modelID: string | ModelID, input: Config) => configure(input)(modelID),
{ id, configure },
)
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const imageModel = (modelID: string, settings: Settings) => {
const input = config(settings)
return configure(input).image(modelID, input.providerOptions)
}
export const decisionModel = (modelID: string, settings: Settings) => {
const input = config(settings)
return configure(input).decision(modelID, input.providerOptions)
}
function config(settings: Settings) {
const { accountId: _, apiKey, baseURL: _url, body, headers, ...providerOptions } = settings
return {
apiKey,
baseURL: baseURL(settings),
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}
export * as CloudflareWorkersAI from "./cloudflare-workers-ai.js"
configure(config(settings))(modelID)

View file

@ -1,2 +1,9 @@
export { decisionModel as model } from "../cloudflare-workers-ai.js"
import { cloudflareWorkersAI, type Settings } from "../cloudflare-workers-ai.js"
import { config } from "../cloudflare-workers-ai-settings.js"
export type { Settings } from "../cloudflare-workers-ai.js"
export const model = (modelID: string, settings: Settings) => {
const input = config(settings)
return cloudflareWorkersAI.configure(input).decision(modelID, input.providerOptions)
}

View file

@ -1,2 +1,9 @@
export { imageModel as model } from "../cloudflare-workers-ai.js"
import { cloudflareWorkersAI, type Settings } from "../cloudflare-workers-ai.js"
import { config } from "../cloudflare-workers-ai-settings.js"
export type { Settings } from "../cloudflare-workers-ai.js"
export const model = (modelID: string, settings: Settings) => {
const input = config(settings)
return cloudflareWorkersAI.configure(input).image(modelID, input.providerOptions)
}

View file

@ -6,7 +6,7 @@ import { AuthOptions, type ProviderAuthOption } from "../route/auth-options.js"
import { ProviderID, type ModelID, type OpenString } from "../schema/index.js"
import type { ProviderPackage } from "../provider-package.js"
export const id = ProviderID.make("cohere")
const id = ProviderID.make("cohere")
const COMPATIBILITY_BASE_URL = "https://api.cohere.ai/compatibility/v1"
export type ChatOptionsInput = { readonly reasoningEffort?: OpenString<"none" | "high"> }
export type ProviderOptions = CohereChat.ProviderOptionsInput & ChatOptionsInput
@ -18,6 +18,8 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
export type Settings<Options = CohereChat.ProviderOptionsInput> = ProviderPackage.Settings &
Options & { readonly apiKey?: string | false; readonly baseURL?: string }
export type ChatSettings = Settings<ChatOptionsInput>
export const route = CohereChat.route
export const chatRoute = Route.make({
id: "cohere-chat-completions",
@ -29,14 +31,13 @@ export const chatRoute = Route.make({
})
export const routes = [route, chatRoute]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL, ...defaults } = input
const auth = AuthOptions.bearer(input, "COHERE_API_KEY")
const native = route.with({ ...defaults, auth, endpoint: { baseURL: baseURL ?? CohereChat.DEFAULT_BASE_URL } })
const chat = chatRoute.with({ ...defaults, auth, endpoint: { baseURL: baseURL ?? COMPATIBILITY_BASE_URL } })
return {
return Object.assign((modelID: string | ModelID) => native.model<CohereChat.ProviderOptionsInput>({ id: modelID }), {
id,
model: (modelID: string | ModelID) => native.model<CohereChat.ProviderOptionsInput>({ id: modelID }),
chat: (modelID: string | ModelID) =>
chat.model<ChatOptionsInput>({
id: modelID,
@ -47,10 +48,9 @@ export const configure = (input: Config = {}) => {
},
}),
configure,
}
})
}
export const provider = configure()
export const chat = provider.chat
export const cohere = configure()
export const model: ProviderPackage.Model<Settings, CohereChat.ProviderOptionsInput> = (
modelID,
{ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {},
@ -61,5 +61,4 @@ export const model: ProviderPackage.Model<Settings, CohereChat.ProviderOptionsIn
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).model(modelID)
export * as Cohere from "./cohere.js"
})(modelID)

View file

@ -1,16 +1,18 @@
import type { ProviderPackage } from "../../provider-package.js"
import { Cohere } from "../cohere.js"
import { cohere, type ChatOptionsInput, type ChatSettings } from "../cohere.js"
export type Settings = Cohere.Settings<Cohere.ChatOptionsInput>
export type { ChatSettings as Settings } from "../cohere.js"
export const model: ProviderPackage.Model<Settings, Cohere.ChatOptionsInput> = (
export const model: ProviderPackage.Model<ChatSettings, ChatOptionsInput> = (
modelID,
{ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {},
{ apiKey, baseURL, body, headers, ...providerOptions }: ChatSettings = {},
) =>
Cohere.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).chat(modelID)
cohere
.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
})
.chat(modelID)

View file

@ -8,7 +8,7 @@ import { DeepgramTranscription } from "../protocols/deepgram-transcription.js"
export type { DeepgramEncoding, DeepgramSpeechOptions } from "../protocols/deepgram-speech.js"
export type { DeepgramTranscriptionOptions } from "../protocols/deepgram-transcription.js"
export const id = ProviderID.make("deepgram")
const id = ProviderID.make("deepgram")
export type Config = ProviderAuthOption<"optional"> & {
readonly baseURL?: string
@ -19,7 +19,7 @@ export type Config = ProviderAuthOption<"optional"> & {
const auth = (options: ProviderAuthOption<"optional">) =>
AuthOptions.apiKey(options, "DEEPGRAM_API_KEY", Auth.scheme("Token"))
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const media = MediaRoute.deployment(input, auth(input))
return {
id,
@ -29,6 +29,4 @@ export const configure = (input: Config = {}) => {
}
}
export const provider = configure()
export const speech = provider.speech
export const transcription = provider.transcription
export const deepgram = configure()

View file

@ -6,7 +6,7 @@ import { Endpoint } from "../route/endpoint.js"
import { ProviderID, type ModelID } from "../schema/index.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
export const id = ProviderID.make("deepinfra")
const id = ProviderID.make("deepinfra")
const baseURL = "https://api.deepinfra.com/v1/openai"
export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
@ -32,7 +32,7 @@ export const route = Route.make({
export const routes = [route]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const root = endpoint?.replace(/\/+$/, "")
const configured = route.with({
@ -42,9 +42,8 @@ export const configure = (input: Config = {}) => {
},
auth: AuthOptions.bearer(input, "DEEPINFRA_API_KEY"),
})
return {
id,
model: (modelID: string | ModelID) =>
return Object.assign(
(modelID: string | ModelID) =>
configured.model<OpenAIProviderOptionsInput>({
id: modelID,
compatibility: {
@ -53,11 +52,11 @@ export const configure = (input: Config = {}) => {
supportsPromptCacheKey: true,
},
}),
configure,
}
{ id, configure },
)
}
export const provider = configure()
export const deepinfra = configure()
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (
modelID,
@ -69,4 +68,4 @@ export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).model(modelID)
})(modelID)

View file

@ -6,7 +6,7 @@ import { Endpoint } from "../route/endpoint.js"
import { ProviderID, type ModelID } from "../schema/index.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
export const id = ProviderID.make("deepseek")
const id = ProviderID.make("deepseek")
const baseURL = "https://api.deepseek.com/v1"
export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
@ -32,25 +32,24 @@ export const route = Route.make({
export const routes = [route]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const configured = route.with({
...defaults,
endpoint: { baseURL: endpoint ?? baseURL },
auth: AuthOptions.bearer(input, "DEEPSEEK_API_KEY"),
})
return {
id,
model: (modelID: string | ModelID) =>
return Object.assign(
(modelID: string | ModelID) =>
configured.model<OpenAIProviderOptionsInput>({
id: modelID,
compatibility: { maxTokensField: "max_tokens" },
}),
configure,
}
{ id, configure },
)
}
export const provider = configure()
export const deepseek = configure()
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (
modelID,
@ -62,6 +61,4 @@ export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).model(modelID)
export * as DeepSeek from "./deepseek.js"
})(modelID)

View file

@ -0,0 +1,17 @@
import type { Config, Settings } from "./digitalocean.js"
export function config({
apiKey,
baseURL,
body,
headers,
...providerOptions
}: Settings<Config["providerOptions"]> = {}) {
return {
apiKey,
baseURL,
headers,
http: { body },
providerOptions,
}
}

View file

@ -12,8 +12,9 @@ import { Protocol } from "../route/protocol.js"
import { ProviderID, type ModelID, type ProviderOptions } from "../schema/index.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js"
import { config } from "./digitalocean-settings.js"
export const id = ProviderID.make("digitalocean")
const id = ProviderID.make("digitalocean")
const baseURL = "https://inference.do-ai.run/v1"
export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
@ -25,6 +26,8 @@ export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
export type Settings<Options = OpenAIProviderOptionsInput> = ProviderPackage.Settings &
Options & { readonly apiKey?: string | false }
export type ResponsesSettings = Settings<OpenResponsesProviderOptionsInput>
export const protocol = Protocol.make({
id: "digitalocean-chat",
body: {
@ -55,7 +58,7 @@ const responsesRoute = Route.make({
export const routes = [route, responsesRoute]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const auth = AuthOptions.bearer(input, ["DIGITALOCEAN_ACCESS_TOKEN", "DIGITALOCEAN_API_KEY", "DO_INFERENCE_API_KEY"])
const options = { ...defaults, endpoint: { baseURL: endpoint ?? baseURL }, auth }
@ -82,47 +85,18 @@ export const configure = (input: Config = {}) => {
supportsPromptCacheKey: true,
},
})
return {
return Object.assign(chat, {
id,
model: chat,
chat,
responses: (modelID: string | ModelID) =>
configuredResponses.model<OpenResponsesProviderOptionsInput>({ id: modelID }),
image,
decision,
configure,
}
})
}
export const provider = configure()
export const decision = provider.decision
export const image = provider.image
export const chat = provider.chat
export const responses = provider.responses
export const digitalocean = configure()
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const responsesModel: ProviderPackage.Model<
Settings<OpenResponsesProviderOptionsInput>,
OpenResponsesProviderOptionsInput
> = (modelID, settings) => configure(config(settings)).responses(modelID)
export const imageModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).image(modelID, input.providerOptions)
}
export const decisionModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).decision(modelID, input.providerOptions)
}
function config({ apiKey, baseURL, body, headers, ...providerOptions }: Settings<Config["providerOptions"]> = {}) {
return {
apiKey,
baseURL,
headers,
http: { body },
providerOptions,
}
}
export * as DigitalOcean from "./digitalocean.js"
configure(config(settings))(modelID)

View file

@ -1,2 +1,9 @@
export { decisionModel as model } from "../digitalocean.js"
import { digitalocean, type Settings } from "../digitalocean.js"
import { config } from "../digitalocean-settings.js"
export type { Settings } from "../digitalocean.js"
export const model = (modelID: string, settings?: Settings) => {
const input = config(settings)
return digitalocean.configure(input).decision(modelID, input.providerOptions)
}

View file

@ -1,2 +1,9 @@
export { imageModel as model } from "../digitalocean.js"
import { digitalocean, type Settings } from "../digitalocean.js"
import { config } from "../digitalocean-settings.js"
export type { Settings } from "../digitalocean.js"
export const model = (modelID: string, settings?: Settings) => {
const input = config(settings)
return digitalocean.configure(input).image(modelID, input.providerOptions)
}

View file

@ -1,4 +1,9 @@
import type { ProviderPackage } from "../../provider-package.js"
import type { OpenResponsesProviderOptionsInput } from "../open-responses-options.js"
import type { DigitalOcean } from "../digitalocean.js"
export { responsesModel as model } from "../digitalocean.js"
export type Settings = DigitalOcean.Settings<OpenResponsesProviderOptionsInput>
import { digitalocean, type ResponsesSettings } from "../digitalocean.js"
import { config } from "../digitalocean-settings.js"
export type { ResponsesSettings as Settings } from "../digitalocean.js"
export const model: ProviderPackage.Model<ResponsesSettings, OpenResponsesProviderOptionsInput> = (modelID, settings) =>
digitalocean.configure(config(settings)).responses(modelID)

View file

@ -8,7 +8,7 @@ import { ElevenLabsTranscription } from "../protocols/elevenlabs-transcription.j
export type { ElevenLabsOutputFormat, ElevenLabsSpeechOptions } from "../protocols/elevenlabs-speech.js"
export type { ElevenLabsTranscriptionOptions } from "../protocols/elevenlabs-transcription.js"
export const id = ProviderID.make("elevenlabs")
const id = ProviderID.make("elevenlabs")
export type Config = ProviderAuthOption<"optional"> & {
readonly baseURL?: string
@ -19,18 +19,11 @@ export type Config = ProviderAuthOption<"optional"> & {
const auth = (options: ProviderAuthOption<"optional">) =>
AuthOptions.apiKey(options, "ELEVENLABS_API_KEY", Auth.header("xi-api-key"))
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const media = MediaRoute.deployment(input, auth(input))
const speech = (modelID: string | ModelID) => ElevenLabsSpeech.model({ ...media, id: modelID })
const transcription = (modelID: string | ModelID) => ElevenLabsTranscription.model({ ...media, id: modelID })
return {
id,
speech,
transcription,
configure,
}
return { id, speech, transcription, configure }
}
export const provider = configure()
export const speech = provider.speech
export const transcription = provider.transcription
export const elevenlabs = configure()

View file

@ -6,7 +6,7 @@ import { Endpoint } from "../route/endpoint.js"
import { ProviderID, type ModelID } from "../schema/index.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
export const id = ProviderID.make("fireworks")
const id = ProviderID.make("fireworks")
const baseURL = "https://api.fireworks.ai/inference/v1"
export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
@ -32,22 +32,21 @@ export const route = Route.make({
export const routes = [route]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const configured = route.with({
...defaults,
endpoint: { baseURL: endpoint ?? baseURL },
auth: AuthOptions.bearer(input, "FIREWORKS_API_KEY"),
})
return {
id,
model: (modelID: string | ModelID) =>
return Object.assign(
(modelID: string | ModelID) =>
configured.model<OpenAIProviderOptionsInput>({ id: modelID, compatibility: { supportsPromptCacheKey: true } }),
configure,
}
{ id, configure },
)
}
export const provider = configure()
export const fireworks = configure()
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (
modelID,
@ -59,6 +58,4 @@ export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).model(modelID)
export * as Fireworks from "./fireworks.js"
})(modelID)

View file

@ -0,0 +1,11 @@
import type { Settings } from "./google.js"
export function config({ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}

View file

@ -6,7 +6,7 @@ import { ProviderConfigurationError, ProviderID, type ModelID } from "../schema/
import { GoogleVertexShared } from "./google-vertex-shared.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
export const id = ProviderID.make("google-vertex")
const id = ProviderID.make("google-vertex")
export type Config = RouteDefaultsInput &
GoogleVertexShared.OAuthOptions & {
@ -60,19 +60,21 @@ const configuredRoute = (input: Config) => {
})
}
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const route = configuredRoute(input)
return {
return Object.assign((modelID: string | ModelID) => route.model<OpenAIProviderOptionsInput>({ id: modelID }), {
id,
model: (modelID: string | ModelID) => route.model<OpenAIProviderOptionsInput>({ id: modelID }),
configure,
}
})
}
export const provider = {
id,
configure,
}
export const googleVertexChat = Object.assign(
(modelID: string | ModelID, input: Config = {}) => configure(input)(modelID),
{
id,
configure,
},
)
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (
modelID,
@ -88,5 +90,5 @@ export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>
location,
project,
providerOptions,
}).model(modelID)
})(modelID)
}

View file

@ -9,7 +9,7 @@ import { GoogleVertexShared } from "./google-vertex-shared.js"
export type GoogleInteractionsOptionsInput = GoogleInteractions.OptionsInput
export const id = ProviderID.make("google-vertex")
const id = ProviderID.make("google-vertex")
export type Config = RouteDefaultsInput &
GoogleVertexShared.ApiKeyOptions & {
@ -70,19 +70,18 @@ const configuredRoute = (input: Config) => {
})
}
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const route = configuredRoute(input)
return {
id,
model: (modelID: string | ModelID) => route.model<GoogleInteractions.ProviderOptionsInput>({ id: modelID }),
configure,
}
return Object.assign(
(modelID: string | ModelID) => route.model<GoogleInteractions.ProviderOptionsInput>({ id: modelID }),
{ id, configure },
)
}
export const provider = {
id,
configure,
}
export const googleVertexInteractions = Object.assign(
(modelID: string | ModelID, input: Config = {}) => configure(input)(modelID),
{ id, configure },
)
export const model: ProviderPackage.Model<Settings, GoogleInteractions.ProviderOptionsInput> = (
modelID,
@ -101,5 +100,5 @@ export const model: ProviderPackage.Model<Settings, GoogleInteractions.ProviderO
location,
project,
providerOptions,
}).model(modelID)
})(modelID)
}

View file

@ -15,7 +15,7 @@ export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput
const VERSION = "vertex-2023-10-16" as const
const HEADER_VERSION = "2023-06-01" as const
export const id = ProviderID.make("google-vertex")
const id = ProviderID.make("google-vertex")
export type Config = RouteDefaultsInput &
GoogleVertexShared.OAuthOptions & {
@ -90,19 +90,18 @@ const configuredRoute = (input: Config) => {
})
}
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const route = configuredRoute(input)
return {
id,
model: (modelID: string | ModelID) => route.model<AnthropicMessages.ProviderOptionsInput>({ id: modelID }),
configure,
}
return Object.assign(
(modelID: string | ModelID) => route.model<AnthropicMessages.ProviderOptionsInput>({ id: modelID }),
{ id, configure },
)
}
export const provider = {
id,
configure,
}
export const googleVertexMessages = Object.assign(
(modelID: string | ModelID, input: Config = {}) => configure(input)(modelID),
{ id, configure },
)
export const model: ProviderPackage.Model<Settings, AnthropicMessages.ProviderOptionsInput> = (
modelID,
@ -118,5 +117,5 @@ export const model: ProviderPackage.Model<Settings, AnthropicMessages.ProviderOp
location,
project,
providerOptions,
}).model(modelID)
})(modelID)
}

View file

@ -9,7 +9,7 @@ import { HttpTransport } from "../route/transport/index.js"
import { ProviderConfigurationError, ProviderID, type ModelID } from "../schema/index.js"
import { GoogleVertexShared } from "./google-vertex-shared.js"
export const id = ProviderID.make("google-vertex")
const id = ProviderID.make("google-vertex")
export type Config = RouteDefaultsInput &
GoogleVertexShared.OAuthOptions & {
@ -76,19 +76,18 @@ const configuredRoute = (input: Config) => {
})
}
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const route = configuredRoute(input)
return {
return Object.assign((modelID: string | ModelID) => route.model<MistralChat.ProviderOptionsInput>({ id: modelID }), {
id,
model: (modelID: string | ModelID) => route.model<MistralChat.ProviderOptionsInput>({ id: modelID }),
configure,
}
})
}
export const provider = {
id,
configure,
}
export const googleVertexMistral = Object.assign(
(modelID: string | ModelID, input: Config = {}) => configure(input)(modelID),
{ id, configure },
)
export const model: ProviderPackage.Model<Settings, MistralChat.ProviderOptionsInput> = (
modelID,
@ -104,5 +103,5 @@ export const model: ProviderPackage.Model<Settings, MistralChat.ProviderOptionsI
location,
project,
providerOptions,
}).model(modelID)
})(modelID)
}

View file

@ -6,7 +6,7 @@ import { ProviderConfigurationError, ProviderID, type ModelID } from "../schema/
import { GoogleVertexShared } from "./google-vertex-shared.js"
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js"
export const id = ProviderID.make("google-vertex")
const id = ProviderID.make("google-vertex")
export type Config = RouteDefaultsInput &
GoogleVertexShared.OAuthOptions & {
@ -61,19 +61,18 @@ const configuredRoute = (input: Config) => {
})
}
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const route = configuredRoute(input)
return {
return Object.assign((modelID: string | ModelID) => route.model<OpenResponsesProviderOptionsInput>({ id: modelID }), {
id,
model: (modelID: string | ModelID) => route.model<OpenResponsesProviderOptionsInput>({ id: modelID }),
configure,
}
})
}
export const provider = {
id,
configure,
}
export const googleVertexResponses = Object.assign(
(modelID: string | ModelID, input: Config = {}) => configure(input)(modelID),
{ id, configure },
)
export const model: ProviderPackage.Model<Settings, OpenResponsesProviderOptionsInput> = (
modelID,
@ -89,5 +88,5 @@ export const model: ProviderPackage.Model<Settings, OpenResponsesProviderOptions
location,
project,
providerOptions,
}).model(modelID)
})(modelID)
}

View file

@ -0,0 +1,28 @@
import { ProviderConfigurationError, ProviderID } from "../schema/index.js"
import type { Settings } from "./google-vertex.js"
export function config({
accessToken,
apiKey,
baseURL,
body,
headers,
location,
project,
...providerOptions
}: Settings = {}) {
if (apiKey !== undefined && accessToken !== undefined)
throw new ProviderConfigurationError({
provider: ProviderID.make("google-vertex"),
message: "Google Vertex apiKey cannot be combined with accessToken or auth",
})
return {
...(apiKey === undefined ? { accessToken: accessToken } : { apiKey: apiKey }),
baseURL,
headers,
http: body === undefined ? undefined : { body },
location,
project,
providerOptions,
}
}

View file

@ -15,6 +15,7 @@ import {
type ProviderOptions,
} from "../schema/index.js"
import { GoogleVertexShared } from "./google-vertex-shared.js"
import { config } from "./google-vertex-settings.js"
export interface GeminiOptionsInput extends Gemini.OptionsInput {
readonly labels?: Readonly<Record<string, string>>
@ -22,7 +23,7 @@ export interface GeminiOptionsInput extends Gemini.OptionsInput {
export type GeminiProviderOptionsInput = GeminiOptionsInput
export const id = ProviderID.make("google-vertex")
const id = ProviderID.make("google-vertex")
export type Config = RouteDefaultsInput &
GoogleVertexShared.ApiKeyOptions & {
@ -115,47 +116,24 @@ const connection = (input: Config, modelID: string | ModelID) => {
}
}
export const configure = (input: Config = {}) => {
return {
id,
model: (modelID: string | ModelID) =>
configuredRoute(input, modelID).model<GeminiProviderOptionsInput>({ id: modelID }),
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => {
const target = connection(input, modelID)
return GoogleImages.model({
...MediaRoute.deployment({ ...input, baseURL: target.endpoint.baseURL }, target.auth),
id: modelID,
providerOptions,
})
const configure = (input: Config = {}) => {
return Object.assign(
(modelID: string | ModelID) => configuredRoute(input, modelID).model<GeminiProviderOptionsInput>({ id: modelID }),
{
id,
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => {
const target = connection(input, modelID)
return GoogleImages.model({
...MediaRoute.deployment({ ...input, baseURL: target.endpoint.baseURL }, target.auth),
id: modelID,
providerOptions,
})
},
configure,
},
configure,
}
)
}
export const provider = {
id,
configure,
}
export const googleVertex = configure()
export const model: ProviderPackage.Model<Settings, GeminiProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const imageModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).image(modelID, input.providerOptions)
}
function config({ accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }: Settings = {}) {
if (apiKey !== undefined && accessToken !== undefined)
throw new ProviderConfigurationError({
provider: id,
message: "Google Vertex apiKey cannot be combined with accessToken or auth",
})
return {
...(apiKey === undefined ? { accessToken: accessToken } : { apiKey: apiKey }),
baseURL,
headers,
http: body === undefined ? undefined : { body },
location,
project,
providerOptions,
}
}
configure(config(settings))(modelID)

View file

@ -1,2 +1,9 @@
export { imageModel as model } from "../google-vertex.js"
import { googleVertex, type Settings } from "../google-vertex.js"
import { config } from "../google-vertex-settings.js"
export type { Settings } from "../google-vertex.js"
export const model = (modelID: string, settings?: Settings) => {
const input = config(settings)
return googleVertex.configure(input).image(modelID, input.providerOptions)
}

View file

@ -10,6 +10,7 @@ import { GoogleImages } from "../protocols/google-images.js"
import { GoogleSpeech } from "../protocols/google-speech.js"
import { GoogleTranscription } from "../protocols/google-transcription.js"
import { GoogleVideo } from "../protocols/google-video.js"
import { config } from "./google-settings.js"
export type { GoogleImageOptions } from "../protocols/google-images.js"
export type { GoogleSpeechOptions } from "../protocols/google-speech.js"
@ -19,7 +20,7 @@ export type GeminiOptionsInput = Gemini.OptionsInput
export type GeminiProviderOptionsInput = Gemini.ProviderOptionsInput
export type GoogleInteractionsOptionsInput = GoogleInteractions.OptionsInput
export const id = ProviderID.make("google")
const id = ProviderID.make("google")
export const routes = [Gemini.route, GoogleInteractions.route]
@ -48,13 +49,12 @@ const interactionsRoute = (input: Config) => {
return GoogleInteractions.route.with({ ...rest, endpoint: { baseURL }, auth: auth(input) })
}
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const route = configuredRoute(input)
const media = MediaRoute.deployment(input, auth(input))
const gemini = (modelID: string | ModelID) => route.model<Gemini.ProviderOptionsInput>({ id: modelID })
return {
return Object.assign(gemini, {
id,
model: gemini,
gemini,
interactions: (modelID: string | ModelID) =>
interactionsRoute(input).model<GoogleInteractions.ProviderOptionsInput>({ id: modelID }),
@ -64,30 +64,9 @@ export const configure = (input: Config = {}) => {
speech: (modelID: string | ModelID) => GoogleSpeech.model({ ...media, id: modelID }),
transcription: (modelID: string | ModelID) => GoogleTranscription.model({ ...media, id: modelID }),
configure,
}
})
}
export const provider = configure()
export const google = configure()
export const model: ProviderPackage.Model<Settings, Gemini.ProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const imageModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).image(modelID, input.providerOptions)
}
function config({ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}
export const image = provider.image
export const gemini = provider.gemini
export const interactions = provider.interactions
export const video = provider.video
export const speech = provider.speech
export const transcription = provider.transcription
configure(config(settings))(modelID)

View file

@ -1,2 +1,9 @@
export { imageModel as model } from "../google.js"
import { google, type Settings } from "../google.js"
import { config } from "../google-settings.js"
export type { Settings } from "../google.js"
export const model = (modelID: string, settings?: Settings) => {
const input = config(settings)
return google.configure(input).image(modelID, input.providerOptions)
}

View file

@ -1,4 +1,4 @@
import { configure } from "../google.js"
import { google } from "../google.js"
import type { ProviderPackage } from "../../provider-package.js"
import type { GoogleInteractions } from "../../protocols/google-interactions.js"
@ -12,10 +12,12 @@ export const model: ProviderPackage.Model<Settings, GoogleInteractions.ProviderO
modelID,
{ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {},
) =>
configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).interactions(modelID)
google
.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
})
.interactions(modelID)

View file

@ -9,7 +9,7 @@ import { Protocol } from "../route/protocol.js"
import { ProviderID, type ModelID, type LLMRequest } from "../schema/index.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
export const id = ProviderID.make("groq")
const id = ProviderID.make("groq")
const baseURL = "https://api.groq.com/openai/v1"
export type ProviderOptions = Pick<OpenAIProviderOptionsInput, "reasoningEffort"> & {
@ -71,16 +71,15 @@ export const route = Route.make({
framing: OpenAIChat.framing,
})
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const configured = route.with({
...defaults,
endpoint: { baseURL: endpoint ?? baseURL },
auth: AuthOptions.bearer(input, "GROQ_API_KEY"),
})
return {
id,
model: (modelID: string | ModelID) =>
return Object.assign(
(modelID: string | ModelID) =>
configured.model<ProviderOptions>({
id: modelID,
compatibility: {
@ -90,11 +89,11 @@ export const configure = (input: Config = {}) => {
supportsStrictMode: false,
},
}),
configure,
}
{ id, configure },
)
}
export const provider = configure()
export const groq = configure()
export const model: ProviderPackage.Model<Settings, ProviderOptions> = (
modelID,
@ -106,6 +105,4 @@ export const model: ProviderPackage.Model<Settings, ProviderOptions> = (
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).model(modelID)
export * as Groq from "./groq.js"
})(modelID)

View file

@ -1,44 +1,44 @@
export * as Alibaba from "./alibaba.js"
export * as Anthropic from "./anthropic.js"
export * as AnthropicCompatible from "./anthropic-compatible.js"
export * as AmazonBedrock from "./amazon-bedrock.js"
export * as AmazonBedrockMantle from "./amazon-bedrock-mantle.js"
export * as AssemblyAI from "./assemblyai.js"
export * as Azure from "./azure.js"
export * as Baseten from "./baseten.js"
export * as Cartesia from "./cartesia.js"
export * as Cerebras from "./cerebras.js"
export * as Cohere from "./cohere.js"
export * as CloudflareAIGateway from "./cloudflare-ai-gateway.js"
export * as CloudflareWorkersAI from "./cloudflare-workers-ai.js"
export * as DeepInfra from "./deepinfra.js"
export * as Deepgram from "./deepgram.js"
export * as DeepSeek from "./deepseek.js"
export * as DigitalOcean from "./digitalocean.js"
export * as ElevenLabs from "./elevenlabs.js"
export * as Fireworks from "./fireworks.js"
export * as Google from "./google.js"
export * as GoogleVertex from "./google-vertex.js"
export * as GoogleVertexChat from "./google-vertex-chat.js"
export * as GoogleVertexInteractions from "./google-vertex-interactions.js"
export * as GoogleVertexMessages from "./google-vertex-messages.js"
export * as GoogleVertexMistral from "./google-vertex-mistral.js"
export * as GoogleVertexResponses from "./google-vertex-responses.js"
export * as Groq from "./groq.js"
export * as Meta from "./meta.js"
export * as MiniMax from "./minimax.js"
export * as Mistral from "./mistral.js"
export * as Moonshot from "./moonshot.js"
export * as OpenAI from "./openai.js"
export * as OpenAICompatible from "./openai-compatible.js"
export * as OpenAICompatibleResponses from "./openai-compatible-responses.js"
export * as OpenCode from "./opencode.js"
export * as OpenRouter from "./openrouter.js"
export * as Runway from "./runway.js"
export * as TogetherAI from "./togetherai.js"
export * as TypeSafeAI from "./typesafe-ai.js"
export * as VercelAIGateway from "./vercel-ai-gateway.js"
export * as Venice from "./venice.js"
export * as XAI from "./xai.js"
export * as ZAI from "./zai.js"
export * as ZAICodingPlan from "./zai-coding-plan.js"
export { alibaba } from "./alibaba.js"
export { amazonBedrock } from "./amazon-bedrock.js"
export { amazonBedrockMantle } from "./amazon-bedrock-mantle.js"
export { anthropic } from "./anthropic.js"
export { anthropicCompatible } from "./anthropic-compatible.js"
export { assemblyai } from "./assemblyai.js"
export { azure } from "./azure.js"
export { baseten } from "./baseten.js"
export { cartesia } from "./cartesia.js"
export { cerebras } from "./cerebras.js"
export { cloudflareAIGateway } from "./cloudflare-ai-gateway.js"
export { cloudflareWorkersAI } from "./cloudflare-workers-ai.js"
export { cohere } from "./cohere.js"
export { deepgram } from "./deepgram.js"
export { deepinfra } from "./deepinfra.js"
export { deepseek } from "./deepseek.js"
export { digitalocean } from "./digitalocean.js"
export { elevenlabs } from "./elevenlabs.js"
export { fireworks } from "./fireworks.js"
export { google } from "./google.js"
export { googleVertex } from "./google-vertex.js"
export { googleVertexChat } from "./google-vertex-chat.js"
export { googleVertexInteractions } from "./google-vertex-interactions.js"
export { googleVertexMessages } from "./google-vertex-messages.js"
export { googleVertexMistral } from "./google-vertex-mistral.js"
export { googleVertexResponses } from "./google-vertex-responses.js"
export { groq } from "./groq.js"
export { meta } from "./meta.js"
export { minimax } from "./minimax.js"
export { mistral } from "./mistral.js"
export { moonshot } from "./moonshot.js"
export { openai } from "./openai.js"
export { openaiCompatible } from "./openai-compatible.js"
export { openaiCompatibleResponses } from "./openai-compatible-responses.js"
export { opencode } from "./opencode.js"
export { openrouter } from "./openrouter.js"
export { runway } from "./runway.js"
export { togetherai } from "./togetherai.js"
export { typesafeAI } from "./typesafe-ai.js"
export { venice } from "./venice.js"
export { vercelAIGateway } from "./vercel-ai-gateway.js"
export { xai } from "./xai.js"
export { zai } from "./zai.js"
export { zaiCodingPlan } from "./zai-coding-plan.js"

View file

@ -0,0 +1,11 @@
import type { Settings } from "./meta.js"
export function config({ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}

View file

@ -10,8 +10,9 @@ import { Endpoint } from "../route/endpoint.js"
import { MediaRoute } from "../route/media.js"
import { ProviderID, ToolDefinition, type ModelID, type OpenString } from "../schema/index.js"
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js"
import { config } from "./meta-settings.js"
export const id = ProviderID.make("meta")
const id = ProviderID.make("meta")
const baseURL = "https://api.meta.ai/v1"
export type ProviderOptionsInput = OpenResponsesProviderOptionsInput &
@ -32,7 +33,7 @@ export interface WebSearchOptions {
}
}
export const webSearch = (options: WebSearchOptions = {}) =>
const webSearch = (options: WebSearchOptions = {}) =>
ToolDefinition.make({
name: "web_search",
description: "Search the web with Meta's hosted search tool.",
@ -56,7 +57,7 @@ export interface ImageGenerationOptions {
readonly enableShell?: boolean
}
export const imageGeneration = (options: ImageGenerationOptions = {}) =>
const imageGeneration = (options: ImageGenerationOptions = {}) =>
ToolDefinition.make({
name: "image_generation",
description: "Generate or edit an image with Muse Image.",
@ -118,7 +119,7 @@ const messagesRoute = Route.make({
export const routes = [responsesRoute, chatRoute, messagesRoute]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const options = {
...defaults,
@ -141,34 +142,10 @@ export const configure = (input: Config = {}) => {
})
const media = MediaRoute.deployment(input, options.auth)
const image = (modelID: string | ModelID) => MetaImages.model({ ...media, id: modelID })
return { id, model: responses, responses, chat, messages, image, configure }
return Object.assign(responses, { id, responses, chat, messages, image, webSearch, imageGeneration, configure })
}
export const provider = configure()
export const responses = provider.responses
export const chat = provider.chat
export const messages = provider.messages
export const image = provider.image
export const meta = configure()
export const model: ProviderPackage.Model<Settings, OpenResponsesProviderOptionsInput> = (modelID, settings) =>
fromSettings(settings).responses(modelID)
export const chatModel: ProviderPackage.Model<Settings, OpenResponsesProviderOptionsInput> = (modelID, settings) =>
fromSettings(settings).chat(modelID)
export const messagesModel: ProviderPackage.Model<Settings, MessagesOptionsInput> = (modelID, settings) =>
fromSettings(settings).messages(modelID)
export const imageModel = (modelID: string, settings?: Settings) => fromSettings(settings).image(modelID)
function fromSettings({ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {}) {
return configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
})
}
export * as Meta from "./meta.js"
configure(config(settings)).responses(modelID)

View file

@ -1,2 +1,9 @@
export { chatModel as model } from "../meta.js"
import type { ProviderPackage } from "../../provider-package.js"
import { meta, type Settings } from "../meta.js"
import { config } from "../meta-settings.js"
import type { OpenResponsesProviderOptionsInput } from "../open-responses-options.js"
export type { Settings } from "../meta.js"
export const model: ProviderPackage.Model<Settings, OpenResponsesProviderOptionsInput> = (modelID, settings) =>
meta.configure(config(settings)).chat(modelID)

View file

@ -1,2 +1,6 @@
export { imageModel as model } from "../meta.js"
import { meta, type Settings } from "../meta.js"
import { config } from "../meta-settings.js"
export type { Settings } from "../meta.js"
export const model = (modelID: string, settings?: Settings) => meta.configure(config(settings)).image(modelID)

View file

@ -1,2 +1,8 @@
export { messagesModel as model } from "../meta.js"
import type { ProviderPackage } from "../../provider-package.js"
import { meta, type MessagesOptionsInput, type Settings } from "../meta.js"
import { config } from "../meta-settings.js"
export type { Settings } from "../meta.js"
export const model: ProviderPackage.Model<Settings, MessagesOptionsInput> = (modelID, settings) =>
meta.configure(config(settings)).messages(modelID)

View file

@ -0,0 +1,11 @@
import type { Settings } from "./minimax.js"
export function config({ apiKey, baseURL, body, headers, ...providerOptions }: Settings<{}> = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}

View file

@ -12,8 +12,9 @@ import { Framing } from "../route/framing.js"
import { MediaRoute } from "../route/media.js"
import { Protocol } from "../route/protocol.js"
import { ProviderID, type LLMRequest, type ModelID, type ProviderOptions } from "../schema/index.js"
import { config } from "./minimax-settings.js"
export const id = ProviderID.make("minimax")
const id = ProviderID.make("minimax")
export type MessagesOptionsInput = {
/** M3 defaults to disabled; M2.x always thinks. */
@ -48,6 +49,11 @@ export type Settings<Options = MessagesOptionsInput> = ProviderPackage.Settings
readonly baseURL?: string
}
export type ChatSettings = Settings<ChatOptionsInput>
export type ResponsesSettings = Settings<ResponsesOptionsInput>
export type ImageSettings = Settings<MiniMaxImageOptions>
export type { MiniMaxImageOptions }
const ChatOptions = Schema.Struct({
@ -108,7 +114,7 @@ const responsesRoute = Route.make({
export const routes = [messagesRoute, chatRoute, responsesRoute]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL, ...rest } = input
const auth = AuthOptions.bearer(input, "MINIMAX_API_KEY")
const defaults = {
@ -131,31 +137,10 @@ export const configure = (input: Config = {}) => {
const media = MediaRoute.deployment(input, auth)
const image = (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
MiniMaxImages.model({ ...media, id: modelID, providerOptions })
return { id, model: messages, messages, chat, responses, image, configure }
return Object.assign(messages, { id, messages, chat, responses, image, configure })
}
export const provider = configure()
export const minimax = configure()
export const model: ProviderPackage.Model<Settings<MessagesOptionsInput>, MessagesOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const imageModel = (modelID: string, settings?: Settings<MiniMaxImageOptions>) => {
const input = config(settings)
return configure(input).image(modelID, input.providerOptions)
}
export const messages = provider.messages
export const chat = provider.chat
export const responses = provider.responses
export const image = provider.image
function config({ apiKey, baseURL, body, headers, ...providerOptions }: Settings<{}> = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}
export * as MiniMax from "./minimax.js"
configure(config(settings))(modelID)

View file

@ -1,16 +1,18 @@
import type { ProviderPackage } from "../../provider-package.js"
import { MiniMax } from "../minimax.js"
import { minimax, type ChatOptionsInput, type ChatSettings } from "../minimax.js"
export type Settings = MiniMax.Settings<MiniMax.ChatOptionsInput>
export type { ChatSettings as Settings } from "../minimax.js"
export const model: ProviderPackage.Model<Settings, MiniMax.ChatOptionsInput> = (
export const model: ProviderPackage.Model<ChatSettings, ChatOptionsInput> = (
modelID,
{ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {},
{ apiKey, baseURL, body, headers, ...providerOptions }: ChatSettings = {},
) =>
MiniMax.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).chat(modelID)
minimax
.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
})
.chat(modelID)

View file

@ -1,4 +1,9 @@
import type { MiniMax } from "../minimax.js"
import { minimax, type ImageSettings } from "../minimax.js"
import { config } from "../minimax-settings.js"
export { imageModel as model } from "../minimax.js"
export type Settings = MiniMax.Settings<MiniMax.MiniMaxImageOptions>
export type { ImageSettings as Settings } from "../minimax.js"
export const model = (modelID: string, settings?: ImageSettings) => {
const input = config(settings)
return minimax.configure(input).image(modelID, input.providerOptions)
}

View file

@ -1,16 +1,18 @@
import type { ProviderPackage } from "../../provider-package.js"
import { MiniMax } from "../minimax.js"
import { minimax, type ResponsesOptionsInput, type ResponsesSettings } from "../minimax.js"
export type Settings = MiniMax.Settings<MiniMax.ResponsesOptionsInput>
export type { ResponsesSettings as Settings } from "../minimax.js"
export const model: ProviderPackage.Model<Settings, MiniMax.ResponsesOptionsInput> = (
export const model: ProviderPackage.Model<ResponsesSettings, ResponsesOptionsInput> = (
modelID,
{ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {},
{ apiKey, baseURL, body, headers, ...providerOptions }: ResponsesSettings = {},
) =>
MiniMax.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).responses(modelID)
minimax
.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
})
.responses(modelID)

View file

@ -4,7 +4,7 @@ import { AuthOptions, type ProviderAuthOption } from "../route/auth-options.js"
import type { RouteDefaultsInput } from "../route/client.js"
import { ProviderID, type ModelID } from "../schema/index.js"
export const id = ProviderID.make("mistral")
const id = ProviderID.make("mistral")
export type ProviderOptions = MistralChat.ProviderOptionsInput
@ -23,21 +23,20 @@ export type Settings = ProviderPackage.Settings &
export const route = MistralChat.route
export const routes = [route]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL, ...defaults } = input
const configured = route.with({
...defaults,
endpoint: { baseURL: baseURL ?? MistralChat.DEFAULT_BASE_URL },
auth: AuthOptions.bearer(input, "MISTRAL_API_KEY"),
})
return {
return Object.assign((modelID: string | ModelID) => configured.model<ProviderOptions>({ id: modelID }), {
id,
model: (modelID: string | ModelID) => configured.model<ProviderOptions>({ id: modelID }),
configure,
}
})
}
export const provider = configure()
export const mistral = configure()
export const model: ProviderPackage.Model<Settings, ProviderOptions> = (
modelID,
@ -49,6 +48,4 @@ export const model: ProviderPackage.Model<Settings, ProviderOptions> = (
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).model(modelID)
export * as Mistral from "./mistral.js"
})(modelID)

View file

@ -11,7 +11,7 @@ import { Framing } from "../route/framing.js"
import { Protocol } from "../route/protocol.js"
import { ProviderID, type LLMRequest, type ModelID } from "../schema/index.js"
export const id = ProviderID.make("moonshotai")
const id = ProviderID.make("moonshotai")
export type ReasoningEffort = "low" | "high" | "max" | (string & {})
@ -48,6 +48,9 @@ export type Settings<Options = ChatOptionsInput> = ProviderPackage.Settings &
readonly baseURL?: string
}
export type MessagesSettings = Settings<MessagesOptionsInput>
export type ResponsesSettings = Settings<ResponsesOptionsInput>
const ChatOptions = Schema.Struct({
reasoningEffort: Schema.optional(Schema.String),
thinking: Schema.optional(
@ -98,7 +101,7 @@ const responsesRoute = Route.make({
export const routes = [chatRoute, messagesRoute, responsesRoute]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL, ...rest } = input
const defaults = {
...rest,
@ -125,13 +128,10 @@ export const configure = (input: Config = {}) => {
responsesRoute
.with(defaults)
.model<ResponsesOptionsInput>({ id: modelID, compatibility: { sanitizer: "moonshot" } })
return { id, model: chat, chat, messages, responses, configure }
return Object.assign(chat, { id, chat, messages, responses, configure })
}
export const provider = configure()
export const chat = provider.chat
export const messages = provider.messages
export const responses = provider.responses
export const moonshot = configure()
export const model: ProviderPackage.Model<Settings, ChatOptionsInput> = (
modelID,
@ -143,6 +143,4 @@ export const model: ProviderPackage.Model<Settings, ChatOptionsInput> = (
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).model(modelID)
export * as Moonshot from "./moonshot.js"
})(modelID)

View file

@ -1,16 +1,18 @@
import type { ProviderPackage } from "../../provider-package.js"
import { Moonshot } from "../moonshot.js"
import { moonshot, type MessagesOptionsInput, type MessagesSettings } from "../moonshot.js"
export type Settings = Moonshot.Settings<Moonshot.MessagesOptionsInput>
export type { MessagesSettings as Settings } from "../moonshot.js"
export const model: ProviderPackage.Model<Settings, Moonshot.MessagesOptionsInput> = (
export const model: ProviderPackage.Model<MessagesSettings, MessagesOptionsInput> = (
modelID,
{ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {},
{ apiKey, baseURL, body, headers, ...providerOptions }: MessagesSettings = {},
) =>
Moonshot.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).messages(modelID)
moonshot
.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
})
.messages(modelID)

View file

@ -1,16 +1,18 @@
import type { ProviderPackage } from "../../provider-package.js"
import { Moonshot } from "../moonshot.js"
import { moonshot, type ResponsesOptionsInput, type ResponsesSettings } from "../moonshot.js"
export type Settings = Moonshot.Settings<Moonshot.ResponsesOptionsInput>
export type { ResponsesSettings as Settings } from "../moonshot.js"
export const model: ProviderPackage.Model<Settings, Moonshot.ResponsesOptionsInput> = (
export const model: ProviderPackage.Model<ResponsesSettings, ResponsesOptionsInput> = (
modelID,
{ apiKey, baseURL, body, headers, ...providerOptions }: Settings = {},
{ apiKey, baseURL, body, headers, ...providerOptions }: ResponsesSettings = {},
) =>
Moonshot.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).responses(modelID)
moonshot
.configure({
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
})
.responses(modelID)

View file

@ -7,7 +7,7 @@ import type { OpenResponsesProviderOptionsInput } from "./open-responses-options
export type { OpenResponsesOptionsInput, OpenResponsesProviderOptionsInput } from "./open-responses-options.js"
export const id = ProviderID.make("openai-compatible")
const id = ProviderID.make("openai-compatible")
export type Config = RouteDefaultsInput &
ProviderAuthOption<"optional"> & {
@ -25,7 +25,7 @@ export type Settings = ProviderPackage.Settings &
export const routes = [OpenAICompatibleResponses.route]
export const configure = (input: Config) => {
const configure = (input: Config) => {
const provider = input.provider ?? "openai-compatible"
const { provider: _, baseURL, apiKey: _apiKey, auth: _auth, ...rest } = input
const route = OpenAICompatibleResponses.route.with({
@ -34,17 +34,16 @@ export const configure = (input: Config) => {
endpoint: { baseURL },
auth: AuthOptions.bearer(input, []),
})
return {
return Object.assign((modelID: string | ModelID) => route.model<OpenResponsesProviderOptionsInput>({ id: modelID }), {
id: ProviderID.make(provider),
model: (modelID: string | ModelID) => route.model<OpenResponsesProviderOptionsInput>({ id: modelID }),
configure,
}
})
}
export const provider = {
id,
configure,
}
export const openaiCompatibleResponses = Object.assign(
(modelID: string | ModelID, input: Config) => configure(input)(modelID),
{ id, configure },
)
export const model: ProviderPackage.Model<Settings, OpenResponsesProviderOptionsInput> = (
modelID,
@ -57,4 +56,4 @@ export const model: ProviderPackage.Model<Settings, OpenResponsesProviderOptions
http: body === undefined ? undefined : { body },
provider,
providerOptions,
}).model(modelID)
})(modelID)

View file

@ -0,0 +1,12 @@
import type { Settings } from "./openai-compatible.js"
export function config({ apiKey, baseURL, body, headers, provider, ...providerOptions }: Settings) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
provider,
providerOptions,
}
}

View file

@ -6,8 +6,9 @@ import type { RouteDefaultsInput } from "../route/client.js"
import { AuthOptions, type ProviderAuthOption } from "../route/auth-options.js"
import type { ProviderPackage } from "../provider-package.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
import { config } from "./openai-compatible-settings.js"
export const id = ProviderID.make("openai-compatible")
const id = ProviderID.make("openai-compatible")
export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
ProviderAuthOption<"optional"> & {
@ -25,7 +26,7 @@ export type Settings = ProviderPackage.Settings &
export const routes = [OpenAICompatibleChat.route]
export const configure = (input: Config) => {
const configure = (input: Config) => {
const provider = input.provider ?? "openai-compatible"
const { provider: _, baseURL, apiKey: _apiKey, auth: _auth, ...rest } = input
const auth = AuthOptions.bearer(input, [])
@ -36,9 +37,8 @@ export const configure = (input: Config) => {
auth,
})
const media = MediaRoute.deployment(input, auth)
return {
return Object.assign((modelID: string | ModelID) => route.model<OpenAIProviderOptionsInput>({ id: modelID }), {
id: ProviderID.make(provider),
model: (modelID: string | ModelID) => route.model<OpenAIProviderOptionsInput>({ id: modelID }),
// Many compatible hosts default to hosted URLs. GPT Image models always return bytes and reject the field; a
// proxy serving one under another name can drop the default with `response_format: null`.
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
@ -52,30 +52,13 @@ export const configure = (input: Config) => {
),
}),
configure,
}
})
}
export const provider = {
export const openaiCompatible = Object.assign((modelID: string | ModelID, input: Config) => configure(input)(modelID), {
id,
configure,
}
})
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const imageModel = (modelID: string, settings: Settings) => {
const input = config(settings)
return configure(input).image(modelID, input.providerOptions)
}
function config({ apiKey, baseURL, body, headers, provider, ...providerOptions }: Settings) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
provider,
providerOptions,
}
}
export * as OpenAICompatible from "./openai-compatible.js"
configure(config(settings))(modelID)

View file

@ -1,2 +1,9 @@
export { imageModel as model } from "../openai-compatible.js"
import { openaiCompatible, type Settings } from "../openai-compatible.js"
import { config } from "../openai-compatible-settings.js"
export type { Settings } from "../openai-compatible.js"
export const model = (modelID: string, settings: Settings) => {
const input = config(settings)
return openaiCompatible.configure(input).image(modelID, input.providerOptions)
}

View file

@ -0,0 +1,26 @@
import type { Config, Settings } from "./openai.js"
export const config = ({
apiKey,
baseURL,
body,
headers: given,
organization,
project,
queryParams,
...providerOptions
}: Settings = {}): Config => {
const headers = {
...(organization === undefined ? {} : { "OpenAI-Organization": organization }),
...(project === undefined ? {} : { "OpenAI-Project": project }),
...given,
}
return {
apiKey,
baseURL,
headers: Object.keys(headers).length === 0 ? undefined : headers,
http: body === undefined ? undefined : { body },
providerOptions,
queryParams,
}
}

View file

@ -17,6 +17,7 @@ import { withOpenAIOptions, type OpenAIProviderOptionsInput } from "./openai-opt
import { OpenAIImages } from "../protocols/openai-images.js"
import { OpenAISpeech } from "../protocols/openai-speech.js"
import { OpenAITranscription } from "../protocols/openai-transcription.js"
import { config } from "./openai-settings.js"
import { OpenAIDecisions, type OptionsInput as OpenAIDecisionOptionsInput } from "../protocols/openai-decisions.js"
export type { OpenAIOptionsInput, OpenAIResponseIncludable, OpenAIServiceTier } from "./openai-options.js"
@ -25,7 +26,7 @@ export type { OpenAISpeechOptions } from "../protocols/openai-speech.js"
export type { OpenAITranscriptionOptions } from "../protocols/openai-transcription.js"
export type { OptionsInput as OpenAIDecisionOptions } from "../protocols/openai-decisions.js"
export const id = ProviderID.make("openai")
const id = ProviderID.make("openai")
export const routes = [OpenAIResponses.route, OpenAIChat.route]
@ -52,7 +53,7 @@ export interface ImageGenerationOptions {
>
}
export const imageGeneration = (options: ImageGenerationOptions = {}) =>
const imageGeneration = (options: ImageGenerationOptions = {}) =>
ToolDefinition.make({
name: "image_generation",
description: "Generate or edit an image using OpenAI's hosted image generation tool.",
@ -97,7 +98,7 @@ const configuredRoute = <Body, Prepared, Compact extends CompactionOperations |
endpoint: { baseURL: input.baseURL, query: input.queryParams },
})
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const responsesRoute = configuredRoute(OpenAIResponses.route, input)
const chatRoute = configuredRoute(OpenAIChat.route, input)
const modelDefaults = defaults(input)
@ -131,67 +132,23 @@ export const configure = (input: Config = {}) => {
const decision = (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
decisionRoute.model<OpenAIDecisionOptionsInput>({ id: modelID, providerOptions })
return {
return Object.assign((modelID: string | ModelID) => responses(modelID), {
id,
model: responses,
responses,
chat,
image,
speech,
transcription,
decision,
imageGeneration,
configure,
}
})
}
export const provider = configure()
const config = ({
apiKey,
baseURL,
body,
headers: given,
organization,
project,
queryParams,
...providerOptions
}: Settings = {}): Config => {
const headers = {
...(organization === undefined ? {} : { "OpenAI-Organization": organization }),
...(project === undefined ? {} : { "OpenAI-Project": project }),
...given,
}
return {
apiKey,
baseURL,
headers: Object.keys(headers).length === 0 ? undefined : headers,
http: body === undefined ? undefined : { body },
providerOptions,
queryParams,
}
}
export const openai = configure()
export const model: ProviderPackage.Model<
Settings,
OpenAIProviderOptionsInput,
typeof OpenAIResponses.route.compact
> = (modelID, settings) => {
return configure(config(settings)).responses(modelID)
}
export const chatModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).chat(modelID)
export const imageModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).image(modelID, input.providerOptions)
}
export const decisionModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).decision(modelID, input.providerOptions)
}
export const responses = provider.responses
export const chat = provider.chat
export const image = provider.image
export const speech = provider.speech
export const transcription = provider.transcription
export const decision = provider.decision
> = (modelID, settings) => configure(config(settings)).responses(modelID)

View file

@ -1,2 +1,9 @@
export { chatModel as model } from "../openai.js"
import type { ProviderPackage } from "../../provider-package.js"
import { openai, type Settings } from "../openai.js"
import type { OpenAIProviderOptionsInput } from "../openai-options.js"
import { config } from "../openai-settings.js"
export type { Settings } from "../openai.js"
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (modelID, settings) =>
openai.configure(config(settings)).chat(modelID)

View file

@ -1,2 +1,9 @@
export { imageModel as model } from "../openai.js"
import { openai, type Settings } from "../openai.js"
import { config } from "../openai-settings.js"
export type { Settings } from "../openai.js"
export const model = (modelID: string, settings?: Settings) => {
const input = config(settings)
return openai.configure(input).image(modelID, input.providerOptions)
}

View file

@ -3,7 +3,7 @@ import type { ProviderPackage } from "../provider-package.js"
import { AuthOptions, type ProviderAuthOption } from "../route/auth-options.js"
import { SystemOne } from "../protocols/system-one.js"
export const id = ProviderID.make("opencode")
const id = ProviderID.make("opencode")
const baseURL = "https://opencode.ai/inference/systemone/v1"
export type Config = ProviderAuthOption<"optional"> & {
@ -14,7 +14,7 @@ export type Config = ProviderAuthOption<"optional"> & {
export type Settings = ProviderPackage.Settings & { readonly apiKey?: string | false }
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const route = SystemOne.route.with({
provider: id,
providerMetadataKey: "opencode",
@ -29,13 +29,4 @@ export const configure = (input: Config = {}) => {
return { id, decision, configure }
}
export const provider = configure()
export const decision = provider.decision
export const decisionModel = (modelID: string, { apiKey, baseURL, body, headers, ...providerOptions }: Settings = {}) =>
configure({ apiKey, baseURL, headers, http: body === undefined ? undefined : { body } }).decision(
modelID,
providerOptions,
)
export * as OpenCode from "./opencode.js"
export const opencode = configure()

View file

@ -1,2 +1,8 @@
export { decisionModel as model } from "../opencode.js"
import { opencode, type Settings } from "../opencode.js"
export type { Settings } from "../opencode.js"
export const model = (modelID: string, { apiKey, baseURL, body, headers, ...providerOptions }: Settings = {}) =>
opencode
.configure({ apiKey, baseURL, headers, http: body === undefined ? undefined : { body } })
.decision(modelID, providerOptions)

View file

@ -0,0 +1,17 @@
import type { Config, Settings } from "./openrouter.js"
export function config({
apiKey,
baseURL,
body,
headers,
...providerOptions
}: Settings<Config["providerOptions"]> = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}

View file

@ -14,8 +14,9 @@ import { OpenResponses } from "../protocols/open-responses.js"
import { cacheControl } from "../protocols/utils/cache.js"
import { isRecord, JsonObject, lenient, ProviderShared } from "../protocols/shared.js"
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js"
import { config } from "./openrouter-settings.js"
export const id = ProviderID.make("openrouter")
const id = ProviderID.make("openrouter")
const baseURL = "https://openrouter.ai/api/v1"
const ADAPTER = "openrouter"
@ -98,6 +99,8 @@ export type Settings<Options = OpenRouterProviderOptionsInput> = ProviderPackage
readonly baseURL?: string
}
export type ResponsesSettings = Settings<OpenRouterResponsesProviderOptionsInput>
const SharedOptions = Schema.Struct({
models: lenient(Schema.Array(Schema.String)),
provider: lenient(JsonObject),
@ -242,7 +245,7 @@ const responsesRoute = Route.make({
export const routes = [route, responsesRoute]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const auth = AuthOptions.bearer(input, "OPENROUTER_API_KEY")
const options = { ...defaults, endpoint: { baseURL: endpoint ?? baseURL }, auth }
@ -274,46 +277,17 @@ export const configure = (input: Config = {}) => {
})
const chat = (modelID: string | ModelID) =>
chatRoute.model<OpenRouterProviderOptionsInput>({ id: modelID, compatibility: { supportsPromptCacheKey: true } })
return {
return Object.assign(chat, {
id,
model: chat,
chat,
responses: (modelID: string | ModelID) =>
configuredResponses.model<OpenRouterResponsesProviderOptionsInput>({ id: modelID }),
image,
decision,
configure,
}
})
}
export const provider = configure()
export const decision = provider.decision
export const image = provider.image
export const chat = provider.chat
export const responses = provider.responses
export const openrouter = configure()
export const model: ProviderPackage.Model<Settings, OpenRouterProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const responsesModel: ProviderPackage.Model<
Settings<OpenRouterResponsesProviderOptionsInput>,
OpenRouterResponsesProviderOptionsInput
> = (modelID, settings) => configure(config(settings)).responses(modelID)
export const imageModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).image(modelID, input.providerOptions)
}
export const decisionModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).decision(modelID, input.providerOptions)
}
function config({ apiKey, baseURL, body, headers, ...providerOptions }: Settings<Config["providerOptions"]> = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}
export * as OpenRouter from "./openrouter.js"
configure(config(settings))(modelID)

View file

@ -1,2 +1,9 @@
export { decisionModel as model } from "../openrouter.js"
import { openrouter, type Settings } from "../openrouter.js"
import { config } from "../openrouter-settings.js"
export type { Settings } from "../openrouter.js"
export const model = (modelID: string, settings?: Settings) => {
const input = config(settings)
return openrouter.configure(input).decision(modelID, input.providerOptions)
}

View file

@ -1,2 +1,9 @@
export { imageModel as model } from "../openrouter.js"
import { openrouter, type Settings } from "../openrouter.js"
import { config } from "../openrouter-settings.js"
export type { Settings } from "../openrouter.js"
export const model = (modelID: string, settings?: Settings) => {
const input = config(settings)
return openrouter.configure(input).image(modelID, input.providerOptions)
}

View file

@ -1,3 +1,10 @@
import type { OpenRouter } from "../openrouter.js"
export { responsesModel as model } from "../openrouter.js"
export type Settings = OpenRouter.Settings<OpenRouter.OpenRouterResponsesProviderOptionsInput>
import type { ProviderPackage } from "../../provider-package.js"
import { openrouter, type OpenRouterResponsesProviderOptionsInput, type ResponsesSettings } from "../openrouter.js"
import { config } from "../openrouter-settings.js"
export type { ResponsesSettings as Settings } from "../openrouter.js"
export const model: ProviderPackage.Model<ResponsesSettings, OpenRouterResponsesProviderOptionsInput> = (
modelID,
settings,
) => openrouter.configure(config(settings)).responses(modelID)

View file

@ -5,7 +5,7 @@ import { RunwayVideo } from "../protocols/runway-video.js"
export type { RunwayVideoOptions } from "../protocols/runway-video.js"
export const id = ProviderID.make("runway")
const id = ProviderID.make("runway")
export type Config = ProviderAuthOption<"optional"> & {
readonly baseURL?: string
@ -15,15 +15,10 @@ export type Config = ProviderAuthOption<"optional"> & {
const auth = (options: ProviderAuthOption<"optional">) => AuthOptions.bearer(options, "RUNWAYML_API_SECRET")
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const media = MediaRoute.deployment(input, auth(input))
const video = (modelID: string | ModelID) => RunwayVideo.model({ ...media, id: modelID })
return {
id,
video,
configure,
}
return { id, video, configure }
}
export const provider = configure()
export const video = provider.video
export const runway = configure()

View file

@ -6,7 +6,7 @@ import { Endpoint } from "../route/endpoint.js"
import { ProviderID, type ModelID } from "../schema/index.js"
import type { OpenAIProviderOptionsInput } from "./openai-options.js"
export const id = ProviderID.make("togetherai")
const id = ProviderID.make("togetherai")
const baseURL = "https://api.together.xyz/v1"
export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
@ -32,25 +32,24 @@ export const route = Route.make({
export const routes = [route]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const configured = route.with({
...defaults,
endpoint: { baseURL: endpoint ?? baseURL },
auth: AuthOptions.bearer(input, ["TOGETHER_API_KEY", "TOGETHER_AI_API_KEY"]),
})
return {
id,
model: (modelID: string | ModelID) =>
return Object.assign(
(modelID: string | ModelID) =>
configured.model<OpenAIProviderOptionsInput>({
id: modelID,
compatibility: { maxTokensField: "max_tokens", supportsStrictMode: false },
}),
configure,
}
{ id, configure },
)
}
export const provider = configure()
export const togetherai = configure()
export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput> = (
modelID,
@ -62,4 +61,4 @@ export const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}).model(modelID)
})(modelID)

View file

@ -3,7 +3,7 @@ import type { ProviderPackage } from "../provider-package.js"
import { AuthOptions, type ProviderAuthOption } from "../route/auth-options.js"
import { SystemOne } from "../protocols/system-one.js"
export const id = ProviderID.make("typesafe-ai")
const id = ProviderID.make("typesafe-ai")
const baseURL = "https://api.typesafe.ai/v1"
export type Config = ProviderAuthOption<"optional"> & {
@ -14,7 +14,7 @@ export type Config = ProviderAuthOption<"optional"> & {
export type Settings = ProviderPackage.Settings & { readonly apiKey?: string | false }
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const route = SystemOne.route.with({
provider: id,
providerMetadataKey: "typesafe",
@ -29,13 +29,4 @@ export const configure = (input: Config = {}) => {
return { id, decision, configure }
}
export const provider = configure()
export const decision = provider.decision
export const decisionModel = (modelID: string, { apiKey, baseURL, body, headers, ...providerOptions }: Settings = {}) =>
configure({ apiKey, baseURL, headers, http: body === undefined ? undefined : { body } }).decision(
modelID,
providerOptions,
)
export * as TypeSafeAI from "./typesafe-ai.js"
export const typesafeAI = configure()

View file

@ -1,2 +1,8 @@
export { decisionModel as model } from "../typesafe-ai.js"
import { typesafeAI, type Settings } from "../typesafe-ai.js"
export type { Settings } from "../typesafe-ai.js"
export const model = (modelID: string, { apiKey, baseURL, body, headers, ...providerOptions }: Settings = {}) =>
typesafeAI
.configure({ apiKey, baseURL, headers, http: body === undefined ? undefined : { body } })
.decision(modelID, providerOptions)

View file

@ -0,0 +1,19 @@
import type { Config, Settings } from "./venice.js"
export function config({
apiKey,
baseURL,
queryParams,
body,
headers,
...providerOptions
}: Settings<Config["providerOptions"]> = {}) {
return {
apiKey,
baseURL,
queryParams,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}

View file

@ -7,8 +7,9 @@ import { Route, type RouteDefaultsInput } from "../route/client.js"
import { Endpoint } from "../route/endpoint.js"
import { ProviderID, type ModelID } from "../schema/index.js"
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js"
import { config } from "./venice-settings.js"
export const id = ProviderID.make("venice")
const id = ProviderID.make("venice")
export type ChatOptionsInput = VeniceChat.OptionsInput
export type Config = Omit<RouteDefaultsInput, "providerOptions"> &
ProviderAuthOption<"optional"> & {
@ -23,6 +24,8 @@ export type Settings<Options = ChatOptionsInput> = ProviderPackage.Settings &
readonly queryParams?: Readonly<Record<string, string>>
}
export type ResponsesSettings = Settings<OpenResponsesProviderOptionsInput>
const baseURL = "https://api.venice.ai/api/v1"
const route = Route.make({
@ -44,7 +47,7 @@ const responsesRoute = Route.make({
})
export const routes = [route, responsesRoute]
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, queryParams, ...rest } = input
const options = {
...rest,
@ -55,35 +58,9 @@ export const configure = (input: Config = {}) => {
route.with(options).model<ChatOptionsInput>({ id: modelID, compatibility: VeniceChat.compatibility })
const responses = (modelID: string | ModelID) =>
responsesRoute.with(options).model<OpenResponsesProviderOptionsInput>({ id: modelID })
return { id, model: chat, chat, responses, configure }
return Object.assign(chat, { id, chat, responses, configure })
}
export const provider = configure()
export const chat = provider.chat
export const responses = provider.responses
export const venice = configure()
export const model: ProviderPackage.Model<Settings, ChatOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const responsesModel: ProviderPackage.Model<
Settings<OpenResponsesProviderOptionsInput>,
OpenResponsesProviderOptionsInput
> = (modelID, settings) => configure(config(settings)).responses(modelID)
function config({
apiKey,
baseURL,
queryParams,
body,
headers,
...providerOptions
}: Settings<Config["providerOptions"]> = {}) {
return {
apiKey,
baseURL,
queryParams,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}
export * as Venice from "./venice.js"
configure(config(settings))(modelID)

View file

@ -1,4 +1,9 @@
import type { ProviderPackage } from "../../provider-package.js"
import type { OpenResponsesProviderOptionsInput } from "../open-responses-options.js"
import type { Venice } from "../venice.js"
export { responsesModel as model } from "../venice.js"
export type Settings = Venice.Settings<OpenResponsesProviderOptionsInput>
import { venice, type ResponsesSettings } from "../venice.js"
import { config } from "../venice-settings.js"
export type { ResponsesSettings as Settings } from "../venice.js"
export const model: ProviderPackage.Model<ResponsesSettings, OpenResponsesProviderOptionsInput> = (modelID, settings) =>
venice.configure(config(settings)).responses(modelID)

View file

@ -0,0 +1,11 @@
import type { Settings } from "./vercel-ai-gateway.js"
export function config({ apiKey, baseURL, headers, body, ...providerOptions }: Settings = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}

View file

@ -23,8 +23,9 @@ import {
type ProviderOptions,
} from "../schema/index.js"
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js"
import { config } from "./vercel-ai-gateway-settings.js"
export const id = ProviderID.make("vercel-ai-gateway")
const id = ProviderID.make("vercel-ai-gateway")
const baseURL = "https://ai-gateway.vercel.sh/v1"
export interface GatewayOptions {
@ -221,7 +222,7 @@ const imageSizing: OpenAIImageSizing = (request) => {
return { providerOptions: { xai: { aspect_ratio: request.aspect, resolution: XAIImages.resolution(request) } } }
}
export const configure = (input: Config = {}) => {
const configure = (input: Config = {}) => {
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input
const configured = {
...defaults,
@ -258,41 +259,10 @@ export const configure = (input: Config = {}) => {
})
const decision = (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
decisionRoute.model({ id: modelID, providerOptions })
return { id, model, messages, responses, chat, image, decision, configure }
return Object.assign(model, { id, messages, responses, chat, image, decision, configure })
}
export const provider = configure()
export const decision = provider.decision
export const messages = provider.messages
export const responses = provider.responses
export const chat = provider.chat
export const image = provider.image
export const vercelAIGateway = configure()
export const model: ProviderPackage.Model<Settings, ProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).model(modelID)
export const messagesModel: ProviderPackage.Model<Settings, ProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).messages(modelID)
export const responsesModel: ProviderPackage.Model<Settings, ProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).responses(modelID)
export const chatModel: ProviderPackage.Model<Settings, ProviderOptionsInput> = (modelID, settings) =>
configure(config(settings)).chat(modelID)
export const imageModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).image(modelID, input.providerOptions)
}
export const decisionModel = (modelID: string, settings?: Settings) => {
const input = config(settings)
return configure(input).decision(modelID, input.providerOptions)
}
function config({ apiKey, baseURL, headers, body, ...providerOptions }: Settings = {}) {
return {
apiKey,
baseURL,
headers,
http: body === undefined ? undefined : { body },
providerOptions,
}
}
export * as VercelAIGateway from "./vercel-ai-gateway.js"
configure(config(settings))(modelID)

View file

@ -1,2 +1,8 @@
export { chatModel as model } from "../vercel-ai-gateway.js"
import type { ProviderPackage } from "../../provider-package.js"
import { vercelAIGateway, type ProviderOptionsInput, type Settings } from "../vercel-ai-gateway.js"
import { config } from "../vercel-ai-gateway-settings.js"
export type { Settings } from "../vercel-ai-gateway.js"
export const model: ProviderPackage.Model<Settings, ProviderOptionsInput> = (modelID, settings) =>
vercelAIGateway.configure(config(settings)).chat(modelID)

View file

@ -1,2 +1,9 @@
export { decisionModel as model } from "../vercel-ai-gateway.js"
import { vercelAIGateway, type Settings } from "../vercel-ai-gateway.js"
import { config } from "../vercel-ai-gateway-settings.js"
export type { Settings } from "../vercel-ai-gateway.js"
export const model = (modelID: string, settings?: Settings) => {
const input = config(settings)
return vercelAIGateway.configure(input).decision(modelID, input.providerOptions)
}

View file

@ -1,2 +1,9 @@
export { imageModel as model } from "../vercel-ai-gateway.js"
import { vercelAIGateway, type Settings } from "../vercel-ai-gateway.js"
import { config } from "../vercel-ai-gateway-settings.js"
export type { Settings } from "../vercel-ai-gateway.js"
export const model = (modelID: string, settings?: Settings) => {
const input = config(settings)
return vercelAIGateway.configure(input).image(modelID, input.providerOptions)
}

View file

@ -1,2 +1,8 @@
export { messagesModel as model } from "../vercel-ai-gateway.js"
import type { ProviderPackage } from "../../provider-package.js"
import { vercelAIGateway, type ProviderOptionsInput, type Settings } from "../vercel-ai-gateway.js"
import { config } from "../vercel-ai-gateway-settings.js"
export type { Settings } from "../vercel-ai-gateway.js"
export const model: ProviderPackage.Model<Settings, ProviderOptionsInput> = (modelID, settings) =>
vercelAIGateway.configure(config(settings)).messages(modelID)

View file

@ -1,2 +1,8 @@
export { responsesModel as model } from "../vercel-ai-gateway.js"
import type { ProviderPackage } from "../../provider-package.js"
import { vercelAIGateway, type ProviderOptionsInput, type Settings } from "../vercel-ai-gateway.js"
import { config } from "../vercel-ai-gateway-settings.js"
export type { Settings } from "../vercel-ai-gateway.js"
export const model: ProviderPackage.Model<Settings, ProviderOptionsInput> = (modelID, settings) =>
vercelAIGateway.configure(config(settings)).responses(modelID)

Some files were not shown because too many files have changed in this diff Show more