From a400b4776e17bf2250762b76d8a004b3b96039a9 Mon Sep 17 00:00:00 2001 From: 3am Date: Sat, 30 May 2026 05:39:34 +0300 Subject: [PATCH] feat(core): add FreeModel.dev provider plugin --- .../core/src/plugin/provider/freemodel.ts | 21 +++++++++++++++++++ packages/core/src/plugin/provider/index.ts | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 packages/core/src/plugin/provider/freemodel.ts diff --git a/packages/core/src/plugin/provider/freemodel.ts b/packages/core/src/plugin/provider/freemodel.ts new file mode 100644 index 000000000000..0da6d6cc586e --- /dev/null +++ b/packages/core/src/plugin/provider/freemodel.ts @@ -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" + }) + } + }), + } + }), +}) diff --git a/packages/core/src/plugin/provider/index.ts b/packages/core/src/plugin/provider/index.ts index fd02d322a1f9..683d9bfc499c 100644 --- a/packages/core/src/plugin/provider/index.ts +++ b/packages/core/src/plugin/provider/index.ts @@ -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" @@ -47,6 +48,7 @@ export const ProviderPlugins = [ GooglePlugin, GoogleVertexAnthropicPlugin, GoogleVertexPlugin, + FreeModelPlugin, GroqPlugin, KiloPlugin, LLMGatewayPlugin,