Free model support with OpenRouter #749

Closed
opened 2026-02-16 17:28:08 -05:00 by yindo · 5 comments
Owner

Originally created by @aixoio on GitHub (Jul 16, 2025).

Originally assigned to: @thdxr on GitHub.

When using OpenRouter as a provider I can't use the free models provided on OR with opencode. I might be doing it wrong I just started using opencode but in the docs it says with -m it will use the model I provide but it does not work with free models and when in opencode there is no way to select the free version of a model when using OpenRouter with the /model command.

Originally created by @aixoio on GitHub (Jul 16, 2025). Originally assigned to: @thdxr on GitHub. When using OpenRouter as a provider I can't use the free models provided on OR with opencode. I might be doing it wrong I just started using opencode but in the docs it says with `-m` it will use the model I provide but it does not work with free models and when in opencode there is no way to select the free version of a model when using OpenRouter with the `/model` command.
yindo closed this issue 2026-02-16 17:28:08 -05:00
Author
Owner

@sentienthouseplant commented on GitHub (Jul 16, 2025):

Using /models on version v0.3.13 and searching free listed many free models on Openrouter for me.

Image

Although, looking at recent issues it appears that a new update might of stopped opencode from responding in general. Might be worth checking that it works at all.

@sentienthouseplant commented on GitHub (Jul 16, 2025): Using `/models` on version `v0.3.13` and searching `free` listed many free models on Openrouter for me. <img width="682" height="483" alt="Image" src="https://github.com/user-attachments/assets/8b731c9a-2aae-4a7b-be75-24f14f376cbe" /> Although, looking at recent issues it appears that a new update might of stopped opencode from responding in general. Might be worth checking that it works at all.
Author
Owner

@nathabonfim59 commented on GitHub (Jul 16, 2025):

It works for me as well (0.3.13).

If you wanna "pinpoint" some models/providers, you can also create a opencode.json file in the root of the project or in the global config file.

In the "provider.order" list, put the provider identifier from the OpenRouter "free dropdown".

Image
// opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "openrouter": {
      "models": {
        "moonshotai/kimi-k2:free": {
          "tool_call": false,
          "name": "KIMI K2 Free",
          "options": {
            "tools": false,
            "OpenRouter": {
              "provider": {
                "order": [
                  "chutes/fp8",
                  "parasail/fp8"
                ],
                "allow_fallbacks": false
              }
            }
          }
        }
      }
    }
  }
}

Be careful with the tool_call in the model, some providers might not support it. If that's the case, you'll get a toast informing an error.

Image
@nathabonfim59 commented on GitHub (Jul 16, 2025): It works for me as well (0.3.13). If you wanna "pinpoint" some models/providers, you can also create a `opencode.json` file in the root of the project or in the global config file. In the "provider.order" list, put the provider identifier from the OpenRouter "free dropdown". <img width="1136" height="819" alt="Image" src="https://github.com/user-attachments/assets/3f2e5146-c28b-405d-884f-ccabeede8bb5" /> ```json // opencode.json { "$schema": "https://opencode.ai/config.json", "provider": { "openrouter": { "models": { "moonshotai/kimi-k2:free": { "tool_call": false, "name": "KIMI K2 Free", "options": { "tools": false, "OpenRouter": { "provider": { "order": [ "chutes/fp8", "parasail/fp8" ], "allow_fallbacks": false } } } } } } } } ``` > Be careful with the `tool_call` in the model, some providers might not support it. If that's the case, you'll get a toast informing an error. <img width="1914" height="998" alt="Image" src="https://github.com/user-attachments/assets/7de704e3-c4dc-4247-8ae4-0bdb68d2296f" />
Author
Owner

@thdxr commented on GitHub (Jul 16, 2025):

sounds like it works? you can always config extra models. also free models don't work well generally in opencode

@thdxr commented on GitHub (Jul 16, 2025): sounds like it works? you can always config extra models. also free models don't work well generally in opencode
Author
Owner

@aixoio commented on GitHub (Jul 16, 2025):

yes it works now i just had to update opencode, thank you for the help

@aixoio commented on GitHub (Jul 16, 2025): yes it works now i just had to update opencode, thank you for the help
Author
Owner

@Dema commented on GitHub (Jul 26, 2025):

It actually doesn't work properly. It doesn't fail with an error, but it also doesn't make any tool calls. I've seen DeepSeek write things like <write_to_file> ZZZ.md ......</write_to_file> and Kimi K2 write shell commands that never execute. Is it possible to somehow mimic the way Roo Code handles tool calls for models that don't support native tool calls by using XML syntax for defining tools?

If I set tool_call: false but tools: true, it generates the following:

I'll create a Python file with a Fibonacci function for you.<|tool_calls_section_begin|><|tool_call_begin|>functions.write_file:0<|tool_call_argument_begin|>{"path": "test.py", "content": "def fibonacci(n):\n    if n <= 0:\n        return 0\n    elif n == 1:\n        return 1\n    else:\n        return fibonacci(n - 1) + fibonacci(n -
2)\n\nif name == \"main\":\n    for i in range(10):\n        print(f\"F({i}) = {fibonacci(i)}\")"}<|tool_call_end|><|tool_calls_section_end|>

Does it make sense to make opencode parse this "manually"?

@Dema commented on GitHub (Jul 26, 2025): It actually doesn't work properly. It doesn't fail with an error, but it also doesn't make any tool calls. I've seen DeepSeek write things like `<write_to_file> ZZZ.md ......</write_to_file>` and Kimi K2 write shell commands that never execute. Is it possible to somehow mimic the way Roo Code handles tool calls for models that don't support native tool calls by using XML syntax for defining tools? If I set `tool_call: false` but `tools: true`, it generates the following: ``` I'll create a Python file with a Fibonacci function for you.<|tool_calls_section_begin|><|tool_call_begin|>functions.write_file:0<|tool_call_argument_begin|>{"path": "test.py", "content": "def fibonacci(n):\n if n <= 0:\n return 0\n elif n == 1:\n return 1\n else:\n return fibonacci(n - 1) + fibonacci(n - 2)\n\nif name == \"main\":\n for i in range(10):\n print(f\"F({i}) = {fibonacci(i)}\")"}<|tool_call_end|><|tool_calls_section_end|> ``` Does it make sense to make opencode parse this "manually"?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#749