Why My Model Provider Rejected the Word medium

Every request to my new model provider came back refused, with nothing I could use to fix it.

I run OpenCode as my coding agent. I had just added a provider called River and told OpenCode which models it has. The first request came back a 400, and this was the whole response:

{
  "error": {
    "message": "Invalid inference request. Check the model's supported parameters and input limits.",
    "type": "invalid_request_error",
    "code": "invalid_request"
  }
}

Read it twice, the way I did. It says the request is invalid, and that I should check the model’s supported parameters. It does not say which parameter. It does not say which value. One thing is wrong, or everything is, and the error will not tell you which.

This is how I found the answer, and why the answer was never in my code.

The whole thing, in plain words

River did nothing wrong. My request carried a setting it does not accept, and River said so in the only way it could: by refusing to run it.

The setting was reasoning_effort, the value that tells a reasoning model how hard to think. The value being sent was medium.

River’s models do not all take medium. Its DeepSeek model accepts none, high, and max. Its GLM model accepts low, high, and max. medium is in neither list.

So who chose medium? Nobody typed it. OpenCode did. And OpenCode chose it because River is new, too new to be in the catalog OpenCode reads from: models.dev. With no catalog entry to learn from, OpenCode falls back to the default effort levels of an OpenAI-compatible chat API, and those are low, medium, and high.

My request was well formed. The assumption underneath it was wrong. The fix is to tell OpenCode the truth about the models, which takes a few lines of config, or better, one entry in the catalog.

Everything below is how I got there.

Taking the agent out of it

An error that surfaces inside an agent is a bad place to debug. A harness wraps the request, retries it, and adds parameters of its own, and you end up guessing about your own setup.

So the first move was to stop using the agent and send the request myself:

curl https://api.river.ai/v1/chat/completions \
  -H "Authorization: Bearer $RIVER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-ai/DeepSeek-V4.1-Flash",
    "messages": [{"role": "user", "content": "say hi"}],
    "reasoning_effort": "medium"
  }'

Same 400. Good. The error now belonged to a request I could see in full, instead of one a tool had assembled for me.

Finding the one wrong word

I took fields out until the request was smaller than the problem.

The messages and the model stayed. Everything else came off, one at a time, re-sent each time. The request broke only when reasoning_effort was present, and only for certain values:

  • medium: a 400
  • high: works
  • max: works

Then I ran the same test against the provider’s other models and got a different shape:

  • DeepSeek V4.1 Flash takes none, high, max
  • GLM 5.3 Flash takes low, high, max

Two models on one provider, two different sets, and neither one holds the value the agent was sending by default.

Where medium came from

Now the question was not what River accepts. It was why OpenCode offered medium at all.

OpenCode gives every model a set of variants, the extra knobs you can pick per model. For OpenAI-compatible providers, the default set is a constant you can go and read:

// packages/core/src/variant.ts
const EFFORTS = ["low", "medium", "high"]

A model gets its variants from two places. If you define them yourself, OpenCode uses yours. If you do not, OpenCode fills in the default set, but only when it has no catalog entry for the model:

// packages/core/src/config/plugin/provider.ts
if (config.variants === undefined && !source?.base)
  models.update(providerID, id, (model) => {
    model.variants = [...Variant.resolve({ ...model, package: model.package ?? ... })]
  })

River is not in models.dev, so source is empty, so the second branch runs, and the model inherits low, medium, and high. The string OpenCode then writes into the request is reasoning_effort: "medium", and River refuses it.

Nothing was broken. OpenCode was filling a gap with a reasonable guess, and the guess happened to be wrong for this provider.

The fix

Tell OpenCode the variants, so it stops guessing:

{
  "providers": {
    "river": {
      "name": "River AI",
      "package": "@opencode/ai/providers/openai-compatible",
      "settings": {
        "baseURL": "https://api.river.ai/v1",
        "apiKey": "{env:RIVER_API_KEY}"
      },
      "models": {
        "deepseek-ai/DeepSeek-V4.1-Flash": {
          "variants": [
            { "id": "none", "settings": { "reasoningEffort": "none" } },
            { "id": "high", "settings": { "reasoningEffort": "high" } },
            { "id": "max", "settings": { "reasoningEffort": "max" } }
          ]
        }
      }
    }
  }
}

An empty list works too, "variants": [], if you would rather the model expose none.

But that fix only helps me. The reason OpenCode guessed in the first place is that the catalog had nothing to say about River. So the real fix is the catalog: put the provider and its models into models.dev, with their real context limits, prices, and reasoning options. Every tool that reads models.dev then gets it right, not just mine.

What I took from it

Three things.

The error was accurate and useless at the same time. “Check the model’s supported parameters” is true, and it is also the exact work I had to do anyway. A provider that named the offending field would have given me back an afternoon, and it is worth designing our own errors that way.

A default is a guess wearing a suit. OpenCode’s low, medium, high is a fine default for the models it was written for. On a model it has never seen, the same default is a coin flip.

The gap between “my setup” and “everyone else’s setup” is one file. What actually stops this for the next person is not my config, it is an entry in a shared catalog. Small, boring, and worth more than the workaround.

How I found this

One honest note on method, because this post is about AI tooling and it would be odd to hide it.

I found this by running OpenCode with its own agent, and working the problem alongside it: OpenCode’s source on one side, River’s documentation on the other, values tested against the live API. The agent did the digging. I decided what was true, and every claim above is checked against the source rather than recalled. I also sent the two small upstream fixes this deserved, a models.dev entry for River and a note in OpenCode’s docs about the variants it synthesises.

Which is the small joke at the centre of it. An AI agent spent an afternoon working out why an AI provider was rejecting a parameter another AI had chosen for it. Every part behaving correctly, all of them speaking a slightly different language, and the only thing missing was a catalog entry.

Written by . Software engineer from Bangladesh. I ship products end to end, from the browser to the board: code generation, firmware and PCB tooling at IDEEZA, and my own products ProcureIndex, Akhra and Kommercly. Also farms, cycles and fights MMA.

Published

Get new logs by email. No spam, unsubscribe anytime.