From 3625075dbdd382bbc811dc329f7a959bfff649c6 Mon Sep 17 00:00:00 2001 From: Dalton Alexandre <166029845+dl-alexandre@users.noreply.github.com> Date: Wed, 26 Nov 2025 13:52:52 -0800 Subject: [PATCH] feat: add Ollama Cloud provider support Add support for authenticating and using Ollama Cloud with OpenCode. Users can now: - Run 'opencode auth login' and select 'Ollama Cloud' directly - Get prompted with steps to retrieve their API key from ollama.com - Configure and use Ollama Cloud models through the standard provider system Changes: - Add 'ollama-cloud' as a built-in provider option in auth login flow - Add Ollama Cloud to provider priority list with helpful setup instructions - Create custom loader for ollama-cloud provider with API endpoint configuration - Dynamically register ollama-cloud provider so it appears in model selection This completes the Ollama Cloud integration started in #4693 with documentation. --- packages/opencode/src/cli/cmd/auth.ts | 11 +++++++++++ packages/opencode/src/provider/provider.ts | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/packages/opencode/src/cli/cmd/auth.ts b/packages/opencode/src/cli/cmd/auth.ts index ae24fbef5..19da536b3 100644 --- a/packages/opencode/src/cli/cmd/auth.ts +++ b/packages/opencode/src/cli/cmd/auth.ts @@ -112,6 +112,7 @@ export const AuthLoginCommand = cmd({ google: 4, openrouter: 5, vercel: 6, + "ollama-cloud": 7, } let provider = await prompts.autocomplete({ message: "Select provider", @@ -130,6 +131,10 @@ export const AuthLoginCommand = cmd({ hint: priority[x.id] <= 1 ? "recommended" : undefined, })), ), + { + value: "ollama-cloud", + label: "Ollama Cloud", + }, { value: "other", label: "Other", @@ -300,6 +305,12 @@ export const AuthLoginCommand = cmd({ return } + if (provider === "ollama-cloud") { + prompts.log.info("1. Go to https://ollama.com/ and sign in") + prompts.log.info("2. Navigate to Settings > Keys and generate a new API key") + prompts.log.info("3. Copy the API key and paste it below") + } + if (provider === "opencode") { prompts.log.info("Create an api key at https://opencode.ai/auth") } diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index a4c406c0f..9cea02a56 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -218,6 +218,13 @@ export namespace Provider { }, } }, + "ollama-cloud": async () => { + const hasKey = await Auth.get("ollama-cloud") + return { + autoload: Boolean(hasKey), + options: {}, + } + }, "google-vertex": async () => { const project = process.env["GOOGLE_CLOUD_PROJECT"] ?? process.env["GCP_PROJECT"] ?? process.env["GCLOUD_PROJECT"] const location = process.env["GOOGLE_CLOUD_LOCATION"] ?? process.env["VERTEX_LOCATION"] ?? "us-east5" @@ -329,6 +336,18 @@ export namespace Provider { const configProviders = Object.entries(config.provider ?? {}) + // Add Ollama Cloud provider + if (!database["ollama-cloud"]) { + database["ollama-cloud"] = { + id: "ollama-cloud", + name: "Ollama Cloud", + env: [], + npm: "@ai-sdk/openai-compatible", + api: "https://api.ollama.com/v1", + models: {}, + } + } + // Add GitHub Copilot Enterprise provider that inherits from GitHub Copilot if (database["github-copilot"]) { const githubCopilot = database["github-copilot"]