Files
dev/third_party/pi/packages/ai/src/providers/opencode-go.ts
alexion 6081e3e325 chore(vendor): import pi 1.3.0
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree.

git-subtree-dir: third_party/pi

git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
2026-10-15 17:58:48 -04:00

26 lines
1.2 KiB
TypeScript

import { anthropicMessagesApi } from "../api/anthropic-messages.lazy.ts";
import { googleGenerativeAIApi } from "../api/google-generative-ai.lazy.ts";
import { openAICompletionsApi } from "../api/openai-completions.lazy.ts";
import { openAIResponsesApi } from "../api/openai-responses.lazy.ts";
import { envApiKeyAuth } from "../auth/helpers.ts";
import { createProvider, type Provider } from "../models.ts";
import { OPENCODE_GO_MODELS } from "./opencode-go.models.ts";
import { withOpenCodeSessionHeader } from "./opencode-headers.ts";
type OpenCodeGoApi = "anthropic-messages" | "google-generative-ai" | "openai-completions" | "openai-responses";
export function opencodeGoProvider(): Provider<OpenCodeGoApi> {
return createProvider<OpenCodeGoApi>({
id: "opencode-go",
name: "OpenCode Go",
auth: { apiKey: envApiKeyAuth("OpenCode API key", ["OPENCODE_API_KEY"]) },
models: Object.values(OPENCODE_GO_MODELS),
api: {
"anthropic-messages": withOpenCodeSessionHeader(anthropicMessagesApi()),
"google-generative-ai": withOpenCodeSessionHeader(googleGenerativeAIApi()),
"openai-completions": withOpenCodeSessionHeader(openAICompletionsApi()),
"openai-responses": withOpenCodeSessionHeader(openAIResponsesApi()),
},
});
}