Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ const layer = Layer.effect(
if (!apiKey) continue
mergeProvider(providerID, {
source: "env",
key: provider.env.length === 1 ? apiKey : undefined,
key: apiKey,
})
}

Expand Down
10 changes: 10 additions & 0 deletions packages/opencode/src/session/llm/native-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ import type { ModelMessage } from "ai"
import type { Provider } from "@/provider/provider"
import { isRecord } from "@/util/record"

export const SUPPORTED_NPM_PACKAGES = new Set([
"@ai-sdk/openai",
"@ai-sdk/azure",
"@ai-sdk/anthropic",
"@ai-sdk/google",
"@ai-sdk/amazon-bedrock",
"@ai-sdk/openai-compatible",
"@openrouter/ai-sdk-provider",
])

type ToolInput = {
readonly description?: string
readonly inputSchema?: unknown
Expand Down
7 changes: 2 additions & 5 deletions packages/opencode/src/session/llm/native-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@ function statusWithFetch(
input: Pick<StreamInput, "model" | "provider" | "auth">,
fetch: typeof globalThis.fetch | undefined,
): RuntimeStatus {
const providerID = input.model.providerID
if (providerID !== "openai" && providerID !== "anthropic" && !providerID.startsWith("opencode"))
return { type: "unsupported", reason: "provider is not openai, opencode, or anthropic" }
const npm = input.model.api.npm
if (npm !== "@ai-sdk/openai" && npm !== "@ai-sdk/openai-compatible" && npm !== "@ai-sdk/anthropic")
return { type: "unsupported", reason: "provider package is not OpenAI, OpenAI-compatible, or Anthropic" }
if (!LLMNative.SUPPORTED_NPM_PACKAGES.has(npm))
return { type: "unsupported", reason: `provider package ${npm} is not supported by native runtime` }
if (input.auth?.type === "oauth" && !(input.provider.id === "openai" && fetch)) {
return { type: "unsupported", reason: "OAuth auth requires a provider fetch override" }
}
Expand Down
Loading