Skip to content

undefined: The provided model identifier is invalid #11037

Closed

Description

@LeeWong

Description

opencode cannot identify AWS bedrock: Deepseek v3.1 and Qwen3-Coder-480B

Plugins

No response

OpenCode version

1.1.39

Steps to reproduce

  1. Use AWS bedrock api key and select two models
  2. Run any prompt.

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. added
    bug
    on Jan 28, 2026
  2. github-actions commented on Jan 28, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if your specific case involves different model configurations.

  3. cravenceiling commented on Jan 28, 2026

    @cravenceiling
    Contributor
  4. LeeWong commented on Jan 28, 2026

    @LeeWong
    Author

    They are in model.dev database:

    qwen.qwen3-coder-480b-a35b-v1:0

    deepseek.v3-v1:0

  5. cravenceiling commented on Jan 28, 2026

    @cravenceiling
    Contributor

    What is the output when you run with opencode --print-logs?

  6. LeeWong commented on Jan 28, 2026

    @LeeWong
    Author

    undefined: The provided model identifier is invalid.

  7. LeeWong commented on Jan 28, 2026

    @LeeWong
    Author

    from the log file:

    ERROR 2026-01-28T19:10:26 +7ms service=session.processor error=undefined: The provided model identifier is invalid. stack="AI_APICallError: undefined: The provided model identifier is invalid.\n at (../../node_modules/.bun/@ai-sdk[email protected]+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:936:18)\n at processTicksAndRejections (native:7:39)" process

  8. Solidsilver commented on Jan 29, 2026

    @Solidsilver

    I'm getting the same error - at least with DeepSeek v3.1 on Amazon Bedrock. The region is set to us-west-2 in my opencode config

    Here is a truncated version of the logs I'm seeing:

    INFO  2026-01-29T15:52:44 +1ms service=llm providerID=amazon-bedrock modelID=deepseek.v3-v1:0 sessionID=ses_3f58b041fffeqa4doq4EzNEXGm small=false agent=build mode=primary stream
    INFO  2026-01-29T15:52:44 +0ms service=llm providerID=amazon-bedrock modelID=deepseek.v3-v1:0 sessionID=ses_3f58b041fffeqa4doq4EzNEXGm small=false agent=build mode=primary tokens=32000 modelOptions={} outputLimit=81920 max_output_tokens
    sessionID=ses_3f58b041fffeqa4doq4EzNEXGm small=true agent=title mode=primary error={"error":{"name":"AI_APICallError","url":"https://bedrock-runtime.us-west-2.amazonaws.com/model/us.deepseek.v3-v1%3A0/converse-stream","requestBodyValues":{"system"... <prompts>
    "statusCode":400,"responseHeaders":{"connection":"keep-alive","content-length":"55","content-type":"application/json","date":"Thu, 29 Jan 2026 15:52:45 GMT","x-amzn-errortype":"ValidationException:http://internal.amazon.com/coral/com.amazon.bedrock/","x-amzn-requestid":"<redact>"},"responseBody":"{\"message\":\"The provided model identifier is invalid.\"}","isRetryable":false,"data":{"message":"The provided model identifier is invalid."}}} stream error
    
  9. removed
    zen
    on Jan 29, 2026
  10. Solidsilver commented on Jan 29, 2026

    @Solidsilver

    I think I figured out the issue. deepseek.v3-v1 is an on-demand model (unlike R1) - so it should not have the us. prefix when calling the api. For context, this is on opencode tag v1.1.42.
    packages/opencode/src/provider/provider.ts:311, I commented out "deepseek" in the modelRequiresPrefix array, then re-built opencode and deepseek.v3-v1 worked perfectly.
    Hope this helps.

  11. rekram1-node commented on Jan 29, 2026

    @rekram1-node
    Member

    Thx @Solidsilver will look

  12. neshreve commented on Feb 4, 2026

    @neshreve

    I also just started encountering this behavior today. every Anthropic model we have access to via our corporate AWS is flagged as invalid in opencode.

    macOS Sequoia 15.6.1
    opencode 1.1.50, installed via homebrew

    This behavior was not present yesterday (2026-02-03); I did not manually upgrade before encountering, and upgrading from 1.1.30 -> 1.1.50 did not change behavior.

    Full log output on a failed prompt:

    $ AWS_PROFILE=default opencode --print-logs
    INFO  2026-02-04T13:06:24 +242ms service=default version=1.1.50 args=["--print-logs"] opencode
    INFO  2026-02-04T13:06:24 +1ms service=config path=/Users/nshreve/.config/opencode/config.json loading
    INFO  2026-02-04T13:06:24 +0ms service=config path=/Users/nshreve/.config/opencode/opencode.json loading
    INFO  2026-02-04T13:06:24 +1ms service=config path=/Users/nshreve/.config/opencode/opencode.jsonc loading
    
      █▀▀█  New session - 2026-02-04T13:06:31.922Z
      █  █  opencode -s ses_3d73d088dffeW8hv7UBg3aMQ84
      ▀▀▀▀
  13. R44VC0RP commented on Feb 4, 2026

    @R44VC0RP
    Contributor

    @neshreve where did you see the message showing it as invalid?

    was that in the session?

  14. neshreve commented on Feb 4, 2026

    @neshreve

    @R44VC0RP yes, my conversations look like this:

    # New session - 2026-02-04T13:24:35.018Z
    test
    undefined: The provided model identifier is invalid.
    ▣  Build · us.anthropic.claude-sonnet-4-5-20250929-v1:0
    

    I know my model identifiers are valid as far as AWS is concerned:

    $ aws bedrock-runtime invoke-model \
        --model-id us.anthropic.claude-sonnet-4-5-20250929-v1:0 \
        --body '{"anthropic_version": "bedrock-2023-05-31","messages":[{"role":"user","content":"Tell me a joke."}],"max_tokens":200}' \
        --cli-binary-format raw-in-base64-out \
        /dev/stdout | jq -r '.content[]?.text?'
    Why don't scientists trust atoms?
    
    Because they make up everything!
  15. R44VC0RP commented on Feb 4, 2026

    @R44VC0RP
    Contributor

    can you run opencode export > session.json after you open a new session in TUI and try again, want to see if it can provide any other information

  16. neshreve commented on Feb 4, 2026

    @neshreve

    absolutely, does the session have to be open at the time of export or is the workflow open oc -> failed prompt -> close oc -> export ?

  17. R44VC0RP commented on Feb 4, 2026

    @R44VC0RP
    Contributor

    nah, you can

    1. opencode
    2. fail a session
    3. opencode export >session.json
    4. profit
  18. neshreve commented on Feb 4, 2026

    @neshreve

    ready for profit

    {
      "info": {
        "id": "ses_3d72c81b5ffeNjisPvsJ7jNjcE",
        "slug": "mighty-planet",
        "version": "1.1.50",
        "projectID": "64266c7adf47bf10de2a7a4974d6497447962c15",
        "directory": "/Users/nshreve/.dotfiles/opencode",
        "title": "New session - 2026-02-04T13:24:35.018Z",
        "time": {
          "created": 1770211475018,
          "updated": 1770212290712
        },
        "summary": {
          "additions": 0,
          "deletions": 0,
          "files": 0
        }
      },
      "messages": [
        {
          "info": {
            "id": "msg_c28d37e51001Gpipk7y2FmZ5Dd",
            "sessionID": "ses_3d72c81b5ffeNjisPvsJ7jNjcE",
            "role": "user",
            "time": {
              "created": 1770211475037
            },
            "summary": {
              "diffs": []
            },
            "agent": "build",
            "model": {
              "providerID": "amazon-bedrock",
              "modelID": "us.anthropic.claude-sonnet-4-5-20250929-v1:0"
            }
          },
          "parts": [
            {
              "id": "prt_c28d37e52001nersXvPHuuuIEl",
              "sessionID": "ses_3d72c81b5ffeNjisPvsJ7jNjcE",
              "messageID": "msg_c28d37e51001Gpipk7y2FmZ5Dd",
              "type": "text",
              "text": "test"
            }
          ]
        },
        {
          "info": {
            "id": "msg_c28d37e6d001glVV7Xe8TtHM05",
            "sessionID": "ses_3d72c81b5ffeNjisPvsJ7jNjcE",
            "role": "assistant",
            "time": {
              "created": 1770211475053,
              "completed": 1770211477048
            },
            "error": {
              "name": "APIError",
              "data": {
                "message": "undefined: The provided model identifier is invalid.",
                "statusCode": 400,
                "isRetryable": false,
                "responseHeaders": {
                  "connection": "keep-alive",
                  "content-length": "55",
                  "content-type": "application/json",
                  "date": "Wed, 04 Feb 2026 13:24:37 GMT",
                  "x-amzn-errortype": "ValidationException:http://internal.amazon.com/coral/com.amazon.bedrock/",
                  "x-amzn-requestid": "42ef7a7e-9172-4f8f-8629-8732ffccb1cd"
                },
                "responseBody": "{\"message\":\"The provided model identifier is invalid.\"}",
                "metadata": {
                  "url": "https://bedrock-runtime.us-east-1.amazonaws.com/model/us.us.anthropic.claude-sonnet-4-5-20250929-v1%3A0/converse-stream"
                }
              }
            },
            "parentID": "msg_c28d37e51001Gpipk7y2FmZ5Dd",
            "modelID": "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
            "providerID": "amazon-bedrock",
            "mode": "build",
            "agent": "build",
            "path": {
              "cwd": "/Users/nshreve/.dotfiles/opencode",
              "root": "/Users/nshreve/.dotfiles"
            },
            "cost": 0,
            "tokens": {
              "input": 0,
              "output": 0,
              "reasoning": 0,
              "cache": {
                "read": 0,
                "write": 0
              }
            }
          },
          "parts": []
        },
        {
          "info": {
            "id": "msg_c28dff014001AXWA6OICj5xUXK",
            "sessionID": "ses_3d72c81b5ffeNjisPvsJ7jNjcE",
            "role": "user",
            "time": {
              "created": 1770212290599
            },
            "summary": {
              "diffs": []
            },
            "agent": "build",
            "model": {
              "providerID": "amazon-bedrock",
              "modelID": "us.anthropic.claude-sonnet-4-5-20250929-v1:0"
            }
          },
          "parts": [
            {
              "id": "prt_c28dff014002U1Av1R32QeGQDw",
              "sessionID": "ses_3d72c81b5ffeNjisPvsJ7jNjcE",
              "messageID": "msg_c28dff014001AXWA6OICj5xUXK",
              "type": "text",
              "text": "test"
            }
          ]
        },
        {
          "info": {
            "id": "msg_c28dff03d001MSfboHggUnGyu4",
            "sessionID": "ses_3d72c81b5ffeNjisPvsJ7jNjcE",
            "role": "assistant",
            "time": {
              "created": 1770212290621,
              "completed": 1770212292627
            },
            "error": {
              "name": "APIError",
              "data": {
                "message": "undefined: The provided model identifier is invalid.",
                "statusCode": 400,
                "isRetryable": false,
                "responseHeaders": {
                  "connection": "keep-alive",
                  "content-length": "55",
                  "content-type": "application/json",
                  "date": "Wed, 04 Feb 2026 13:38:12 GMT",
                  "x-amzn-errortype": "ValidationException:http://internal.amazon.com/coral/com.amazon.bedrock/",
                  "x-amzn-requestid": "664fb90d-9188-4628-8d4b-e4d39ade3a8d"
                },
                "responseBody": "{\"message\":\"The provided model identifier is invalid.\"}",
                "metadata": {
                  "url": "https://bedrock-runtime.us-east-1.amazonaws.com/model/us.us.anthropic.claude-sonnet-4-5-20250929-v1%3A0/converse-stream"
                }
              }
            },
            "parentID": "msg_c28dff014001AXWA6OICj5xUXK",
            "modelID": "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
            "providerID": "amazon-bedrock",
            "mode": "build",
            "agent": "build",
            "path": {
              "cwd": "/Users/nshreve/.dotfiles/opencode",
              "root": "/Users/nshreve/.dotfiles"
            },
            "cost": 0,
            "tokens": {
              "input": 0,
              "output": 0,
              "reasoning": 0,
              "cache": {
                "read": 0,
                "write": 0
              }
            }
          },
          "parts": []
        }
      ]
    }
  19. neshreve commented on Feb 4, 2026

    @neshreve

    @R44VC0RP this is probably related, in the metadata of the error, the model designation in the url has us.us. at the beginning

                "metadata": {
                  "url": "https://bedrock-runtime.us-east-1.amazonaws.com/model/us.us.anthropic.claude-sonnet-4-5-20250929-v1%3A0/converse-stream"
                }
  20. R44VC0RP commented on Feb 4, 2026

    @R44VC0RP
    Contributor

    Yeah saw that, investigating now

  21. R44VC0RP commented on Feb 4, 2026

    @R44VC0RP
    Contributor

    Thanks for the detailed debug info @neshreve! You correctly identified the issue - the us.us. in the URL shows the region prefix was being added twice.

    Good news: This was already fixed in v1.1.51 (commit b942e0b - "fix: prevent double-prefixing of Bedrock cross-region inference models").

    The fix adds us., eu., jp., apac., and au. to the list of cross-region prefixes that are checked before adding a region prefix. If the model ID already starts with one of these prefixes, it skips adding another one.

    Resolution: Update to v1.1.51 or later and the issue should be resolved. You can update with:

    npm install -g opencode-ai@latest
    # or
    bun install -g opencode-ai@latest

    Let us know if you still experience issues after updating!

  22. neshreve commented on Feb 4, 2026

    @neshreve

    thank you so much for your help @R44VC0RP!

    for what it's worth, npm install failed with the below error, but brew install anomalyco/tap/opencode got me where I needed to be.

    very much appreciate your swift responses <3

    $ npm install -g opencode@latest
    npm error code E404
    npm error 404 Not Found - GET https://registry.npmjs.org/opencode@latest - Not found
    npm error 404
    npm error 404  The requested resource 'opencode@latest' could not be found or you do not have permission to access it.
    ...
  23. R44VC0RP commented on Feb 4, 2026

    @R44VC0RP
    Contributor

    That was a typo on my end, our npm namespace is opencode-ai

  24. igor-elbert commented on Feb 5, 2026

    @igor-elbert

    @R44VC0RP, I'm getting the same error in v1.1.51 with any model. I'm in EU AWS region.

    session.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions