[PR #202] [MERGED] feat: forward provider options from model config #9560

Closed
opened 2026-02-16 18:13:46 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/202
Author: @0ximjosh
Created: 6/19/2025
Status: Merged
Merged: 6/20/2025
Merged by: @thdxr

Base: devHead: feat/provider-options


📝 Commits (3)

  • 2e576e0 feat: forward provider options from model config
  • f1eb472 ref: use options field for extra model requests options
  • 3168865 match models.dev tool_call

📊 Changes

3 files changed (+18 additions, -10 deletions)

View changed files

📝 packages/opencode/src/provider/models.ts (+2 -0)
📝 packages/opencode/src/provider/provider.ts (+13 -7)
📝 packages/opencode/src/session/index.ts (+3 -3)

📄 Description

Allows users to forward providerOptions to Vercel's ai package. This is
particularly useful for openrouter when needing to select specific providers.

This allows the user to follow the documentation on providerOptions 1:1 with a
given providers sdk.

Example

Following this documentation for adding provider options to the body of a request, we can use
the following opencode.json to select a specific provider

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "openrouter": {
      "npm": "@openrouter/ai-sdk-provider",
      "name": "OpenRouter",
      "options": {},
      "models": {
        "deepseek/deepseek-r1:free": {
          "tools": false,
          "id": "deepseek/deepseek-r1:free",
          "name": "DeepSeek: R1 (free)",
          "providerOptions": {
            "openrouter": {
              "provider": {
                "allow_fallbacks": false,
                "only": [
                  "targon"
                ]
              }
            }
          }
        }
      }
    }
  }
}

Notes

I added the tools field to the model info as an optional bool, since
openrouter providers may or may not support tools (in my case, Targon does not
yet support tool calling), so this needs to be dynamic per model. Maybe it makes
sense to name this something closer to disableTools?

Closes #186


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/202 **Author:** [@0ximjosh](https://github.com/0ximjosh) **Created:** 6/19/2025 **Status:** ✅ Merged **Merged:** 6/20/2025 **Merged by:** [@thdxr](https://github.com/thdxr) **Base:** `dev` ← **Head:** `feat/provider-options` --- ### 📝 Commits (3) - [`2e576e0`](https://github.com/anomalyco/opencode/commit/2e576e09ce4dd154813fbea21e88d96960460a29) feat: forward provider options from model config - [`f1eb472`](https://github.com/anomalyco/opencode/commit/f1eb472320b9c4688b5b1cdc0d1282a772f324aa) ref: use `options` field for extra model requests options - [`3168865`](https://github.com/anomalyco/opencode/commit/316886521e415c178b0d4e42ca97837892c51e26) match models.dev tool_call ### 📊 Changes **3 files changed** (+18 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/provider/models.ts` (+2 -0) 📝 `packages/opencode/src/provider/provider.ts` (+13 -7) 📝 `packages/opencode/src/session/index.ts` (+3 -3) </details> ### 📄 Description Allows users to forward `providerOptions` to Vercel's `ai` package. This is particularly useful for `openrouter` when needing to select specific providers. This allows the user to follow the documentation on `providerOptions` 1:1 with a given providers sdk. ### Example Following [this](https://openrouter.ai/docs/features/provider-routing) documentation for adding `provider` options to the body of a request, we can use the following `opencode.json` to select a specific provider ```json { "$schema": "https://opencode.ai/config.json", "provider": { "openrouter": { "npm": "@openrouter/ai-sdk-provider", "name": "OpenRouter", "options": {}, "models": { "deepseek/deepseek-r1:free": { "tools": false, "id": "deepseek/deepseek-r1:free", "name": "DeepSeek: R1 (free)", "providerOptions": { "openrouter": { "provider": { "allow_fallbacks": false, "only": [ "targon" ] } } } } } } } } ``` ### Notes I added the `tools` field to the model info as an optional bool, since openrouter providers may or may not support tools (in my case, Targon does not yet support tool calling), so this needs to be dynamic per model. Maybe it makes sense to name this something closer to `disableTools`? Closes #186 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:13:46 -05:00
yindo closed this issue 2026-02-16 18:13:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9560