Skip to content
Closed
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
21 changes: 21 additions & 0 deletions packages/core/src/plugin/provider/freemodel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Effect } from "effect"
import { PluginV2 } from "../../plugin"

export const FreeModelPlugin = PluginV2.define({
id: PluginV2.ID.make("freemodel"),
effect: Effect.gen(function* () {
return {
"catalog.transform": Effect.fn(function* (evt) {
for (const item of evt.data) {
if (item.provider.endpoint.type !== "aisdk") continue
if (item.provider.endpoint.package !== "@ai-sdk/openai-compatible") continue
if (item.provider.endpoint.url !== "https://api.freemodel.dev/v1") continue
evt.provider.update(item.provider.id, (provider) => {
provider.options.headers["HTTP-Referer"] = "https://opencode.ai/"
provider.options.headers["X-Title"] = "opencode"
})
}
}),
}
}),
})
2 changes: 2 additions & 0 deletions packages/core/src/plugin/provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CloudflareWorkersAIPlugin } from "./cloudflare-workers-ai"
import { CoherePlugin } from "./cohere"
import { DeepInfraPlugin } from "./deepinfra"
import { DynamicProviderPlugin } from "./dynamic"
import { FreeModelPlugin } from "./freemodel"
import { GatewayPlugin } from "./gateway"
import { GithubCopilotPlugin } from "./github-copilot"
import { GitLabPlugin } from "./gitlab"
Expand Down Expand Up @@ -47,6 +48,7 @@ export const ProviderPlugins = [
GooglePlugin,
GoogleVertexAnthropicPlugin,
GoogleVertexPlugin,
FreeModelPlugin,
GroqPlugin,
KiloPlugin,
LLMGatewayPlugin,
Expand Down
Loading