mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-17 05:26:47 +03:00
fix(core): send the Cloudflare AI Gateway gatewayApiKey
This commit is contained in:
@@ -548,9 +548,12 @@ export const layer = Layer.effect(
|
||||
)
|
||||
|
||||
function hasConfiguredAuth(model: RuntimeInfo) {
|
||||
return [model.settings?.apiKey, model.settings?.authToken, model.settings?.accessToken].some(
|
||||
(value) => typeof value === "string" && value !== "",
|
||||
)
|
||||
return [
|
||||
model.settings?.apiKey,
|
||||
model.settings?.gatewayApiKey,
|
||||
model.settings?.authToken,
|
||||
model.settings?.accessToken,
|
||||
].some((value) => typeof value === "string" && value !== "")
|
||||
}
|
||||
|
||||
const API_KEY_AUTH_PACKAGES: ReadonlySet<string> = new Set([
|
||||
|
||||
@@ -423,6 +423,21 @@ describe("ModelResolver", () => {
|
||||
expect(headers["x-goog-api-key"]).toBeUndefined()
|
||||
}),
|
||||
)
|
||||
|
||||
const gateway = yield* resolver.resolveModel(
|
||||
model("@opencode/ai/providers/cloudflare-ai-gateway", {
|
||||
providerID: Provider.ID.make("gateway"),
|
||||
settings: { baseURL: "https://gateway.example.com/v1/compat", gatewayApiKey: "gateway-fixture" },
|
||||
}),
|
||||
)
|
||||
const headers = yield* gateway.model.route.auth.apply({
|
||||
request: ai.request({ model: gateway.model, prompt: "Hello" }),
|
||||
method: "POST",
|
||||
url: gateway.model.route.endpoint.baseURL ?? "",
|
||||
body: "{}",
|
||||
headers: Headers.fromInput(gateway.model.options?.headers),
|
||||
})
|
||||
expect(headers.authorization).toBe("Bearer gateway-fixture")
|
||||
}).pipe(Effect.provide(layer)),
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user