Skip to content

baseURL ignored in recent versions #56064

Closed

Description

@mariuszste

Description

Doesn't work as documented here: https://opencode.ai/v2/docs/providers/#endpoint

This used to work a couple versions ago just fine.

Plugins

none

OpenCode version

2.0.31

Steps to reproduce

  1. set ~/.config/opencode/opencode.jsonc to:
{
  "providers": {
    "opencode-go": {
      "settings": {
        "baseURL": "https://ai.example.com/v1"
      }
    }
  }
}
  1. re-connect with the API key from the gateway
  2. say "hi"
  3. Observe "Error: Upstream request failed: Invalid credential" and no access logs on the ai gateway

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    Thanks for the report, I can reproduce this.

    I put {"providers":{"opencode-go":{"settings":{"baseURL":"http://127.0.0.1:18931/v1"}}}} in ~/.config/opencode/opencode.jsonc, set a dummy key in OPENCODE_API_KEY, and ran opencode run --model opencode-go/<model> hi with a local server logging every request. opencode debug config showed the setting was loaded. Still, every run failed with Upstream request failed: Invalid credential from opencode.ai, and the local server got no requests. I tried deepseek-v4.1-flash, minimax-m3 and gpt-5.6-luna on 2.0.31, and it happens the same way on the latest dev (83c5abbbe).

    It also happens on 2.0.25. The likely reason (not yet confirmed) is a change in the model catalog OpenCode downloads, not in OpenCode itself. The catalog now gives each Go model its own endpoint, and that overrides the provider-level baseURL from your config. That would explain why it used to work.

    The script below reproduces it. Note that it writes to your global opencode.jsonc and saves any existing one as opencode.jsonc.bak.

    Related (not the same problem): #54370, #55984, #54833.

    Reproduction script (repro.sh)
    #!/usr/bin/env bash
    # Reproduces #56064: providers.opencode-go.settings.baseURL is ignored.
    # Usage: ./repro.sh [model...]   (OC_DEV=/path/to/repo to run from source)
    set -uo pipefail
    DIR=${DIR:-/tmp/opencode/go-baseurl}; PORT=${PORT:-18931}
    rm -rf "$DIR"; mkdir -p "$DIR/proj"
    # The global config, as in the report (~/.config/opencode/opencode.jsonc). Back yours up first!
    CFG=$(opencode debug paths 2>/dev/null | awk '$1=="config"{print $2}'); CFG=${CFG:-$HOME/.config/opencode}; mkdir -p "$CFG"
    [ -f "$CFG/opencode.jsonc" ] && cp "$CFG/opencode.jsonc" "$CFG/opencode.jsonc.bak"
    cat > "$CFG/opencode.jsonc" <<JSON
    { "providers": { "opencode-go": { "settings": { "baseURL": "http://127.0.0.1:$PORT/v1" } } } }
    JSON
    SRV=$(dirname "$(readlink -f "$0")")/server.py
    python3 "$SRV" $PORT > "$DIR/server.log" 2>&1 & SP=$!; sleep 1
    export OPENCODE_API_KEY=sk-dummy-gateway-key
    cd "$DIR/proj"; git init -q .
    if [ -n "${OC_DEV:-}" ]; then
      echo "preload = [\"$OC_DEV/packages/tui/node_modules/@opentui/solid/scripts/preload.js\"]" > bunfig.toml
      OC=(bun --conditions=browser --preload="$OC_DEV/packages/tui/node_modules/@opentui/solid/scripts/preload.js" "$OC_DEV/packages/cli/src/index.ts")
    else OC=(opencode); fi
    "${OC[@]}" --version
    for m in ${@:-deepseek-v4.1-flash minimax-m3 gpt-5.6-luna}; do
      echo "=== opencode-go/$m"
      timeout 60 "${OC[@]}" run --standalone --model "opencode-go/$m" hi 2>&1 | grep -iE "error|credential|LOCAL" | head -3
    done
    kill $SP
    echo "=== requests seen by local gateway:"; cat "$DIR/server.log"

    Run it: bash repro.sh

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions