opencode icon indicating copy to clipboard operation
opencode copied to clipboard

400 Bad Request for every openrouter prompt for 0.2.22

Open eaSyMaxSU opened this issue 1 year ago • 7 comments

The following error appears for openrouter promts.

ERROR 2025-07-10T15:54:07 +0ms service=tui failed to send message: POST "http://127.0.0.1:56639/session/ses_80af4d182ffe4EJ3Nw2XR5s0yS/message": 400 Bad Request {"name":"ProviderInitError","data":{"providerID":"openrouter"}} Image

And the opencode auth. Image

eaSyMaxSU avatar Jul 10 '25 16:07 eaSyMaxSU

same issue here... any idea anyone?

Pranav-Official avatar Jul 10 '25 16:07 Pranav-Official

Same issue Image

The issue is gone when I disable my config.json file + removing ~/.cache/opencode folder

Image

My config.json

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "openrouter": {
      "npm": "@openrouter/ai-sdk-provider",
      "name": "OpenRouter",
      "options": {},
      "models": {
        "mistralai/devstral-medium": {
          "name": "Mistral: Devstral Medium"
        },
        "mistralai/devstral-small": {
          "name": "Mistral: Devstral Small 1.1"
        },
        "inception/mercury": {
          "name": "Inception: Mercury"
        }
      }
    }
  }
}

DenzelVH avatar Jul 10 '25 16:07 DenzelVH

Still having this issue after removing config.json and clearing cache/opencode.

eaSyMaxSU avatar Jul 10 '25 16:07 eaSyMaxSU

same issue on my side

damianpdr avatar Jul 10 '25 17:07 damianpdr

@openrouter/ai-sdk-provider does not work with ai sdk v5 which we use. remove the npm field you don't need it. also we added devstral to models.dev so you can probably get rid of the whole config

thdxr avatar Jul 10 '25 19:07 thdxr

Removing the config do not solve the issue for me.

eaSyMaxSU avatar Jul 11 '25 00:07 eaSyMaxSU

@openrouter/ai-sdk-provider does not work with ai sdk v5 which we use. remove the npm field you don't need it. also we added devstral to models.dev so you can probably get rid of the whole config

Is it only available via the Mistral provider?

Image

Edit: nvm, I use this setup for Devstral Openrouter and it works

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "openrouter": {
      "name": "OpenRouter",
      "options": {},
      "models": {
        "mistralai/devstral-medium": {
          "name": "Devstral Medium",
          "attachment": false,
          "reasoning": false,
          "temperature": true,
          "tool_call": true,
          "release_date": "2025-07-10",
          "cost": { "input": 0.4, "output": 2 },
          "limit": { "context": 128000, "output": 128000 }
        },
        "mistralai/devstral-small": {
          "name": "Devstral Small",
          "attachment": false,
          "reasoning": false,
          "temperature": true,
          "tool_call": true,
          "release_date": "2025-05-07",
          "cost": { "input": 0.1, "output": 0.3 },
          "limit": { "context": 128000, "output": 128000 }
        }
      }
    }
  }
}

DenzelVH avatar Jul 11 '25 02:07 DenzelVH