Custom baseURL configuration returns "Route /api/messages not found" error #3356

Closed
opened 2026-02-16 17:39:45 -05:00 by yindo · 4 comments
Owner

Originally created by @nicehiro on GitHub (Dec 6, 2025).

Question

Hi, thanks for your great work!

I'm trying to use opencode with Claude via a custom API endpoint. The same configuration works fine with Claude Code, but opencode returns the error: Not Found: Route /api/messages not found.

Environment Variables (working with Claude Code)

export ANTHROPIC_BASE_URL="my_url"
export ANTHROPIC_AUTH_TOKEN="my_key"

opencode Configuration

~/.local/share/opencode/auth.json:

{
  "anthropic": {
    "type": "api",
    "key": "my_key"
  }
}

~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": {
      "options": {
        "baseURL": "my_url"
      }
    }
  }
}

Error logs:

ERROR 2025-12-06T09:45:46 +56ms service=session.prompt error={"error":{"name":"AI_APICallError","url":"my_url","requestBodyValues":{"model":"claude-opus-4-5-20251101","max_tokens":32000, xxx
ERROR 2025-12-06T09:45:46 +0ms service=session.processor error=Not Found stack="AI_APICallError: Not Found\n    at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.18+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:950:18)\n    at processTicksAndRejections (native:7:39)" process
Originally created by @nicehiro on GitHub (Dec 6, 2025). ### Question Hi, thanks for your great work! I'm trying to use opencode with Claude via a custom API endpoint. The same configuration works fine with Claude Code, but opencode returns the error: `Not Found: Route /api/messages not found.` #### Environment Variables (working with Claude Code) ```sh export ANTHROPIC_BASE_URL="my_url" export ANTHROPIC_AUTH_TOKEN="my_key" ``` #### opencode Configuration `~/.local/share/opencode/auth.json`: ```json { "anthropic": { "type": "api", "key": "my_key" } } ``` `~/.config/opencode/opencode.json`: ```json { "$schema": "https://opencode.ai/config.json", "provider": { "anthropic": { "options": { "baseURL": "my_url" } } } } ``` #### Error logs: ``` ERROR 2025-12-06T09:45:46 +56ms service=session.prompt error={"error":{"name":"AI_APICallError","url":"my_url","requestBodyValues":{"model":"claude-opus-4-5-20251101","max_tokens":32000, xxx ERROR 2025-12-06T09:45:46 +0ms service=session.processor error=Not Found stack="AI_APICallError: Not Found\n at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.18+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:950:18)\n at processTicksAndRejections (native:7:39)" process ```
yindo closed this issue 2026-02-16 17:39:45 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 6, 2025):

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

  • #1735: max_tokens defaults to 32000 when using a custom provider - related to custom provider configuration issues
  • #1298: Getting an issue integrating a custom provider: AI_TypeValidationError - related to custom provider integration problems
  • #2915: LiteLLM error: Anthropic doesn't support tool calling without tools= param specified - related to Anthropic-specific configuration with custom providers
  • #1635: ProviderInitError with Anthropic - related to Anthropic API configuration issues

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Dec 6, 2025): This issue might be a duplicate of existing issues. Please check: - #1735: max_tokens defaults to 32000 when using a custom provider - related to custom provider configuration issues - #1298: Getting an issue integrating a custom provider: AI_TypeValidationError - related to custom provider integration problems - #2915: LiteLLM error: Anthropic doesn't support tool calling without tools= param specified - related to Anthropic-specific configuration with custom providers - #1635: `ProviderInitError` with Anthropic - related to Anthropic API configuration issues Feel free to ignore if none of these address your specific case.
Author
Owner

@nicehiro commented on GitHub (Dec 6, 2025):

Found a workaround.

Appending /v1 to the base URL (i.e., my_url/v1) resolves the issue.

I'm leaving this open as it may warrant either:

  • A bug fix to align with how the official Anthropic SDK handles
  • Documentation clarifying that baseURL should include /v1
@nicehiro commented on GitHub (Dec 6, 2025): Found a workaround. Appending `/v1` to the base URL (i.e., `my_url/v1`) resolves the issue. I'm leaving this open as it may warrant either: - A bug fix to align with how the official Anthropic SDK handles - Documentation clarifying that baseURL should include `/v1`
Author
Owner

@yyyfor commented on GitHub (Dec 12, 2025):

Found a workaround.

Appending /v1 to the base URL (i.e., my_url/v1) resolves the issue.

I'm leaving this open as it may warrant either:

  • A bug fix to align with how the official Anthropic SDK handles
  • Documentation clarifying that baseURL should include /v1

fixed my issue. thanks

@yyyfor commented on GitHub (Dec 12, 2025): > Found a workaround. > > Appending `/v1` to the base URL (i.e., `my_url/v1`) resolves the issue. > > I'm leaving this open as it may warrant either: > > * A bug fix to align with how the official Anthropic SDK handles > * Documentation clarifying that baseURL should include `/v1` fixed my issue. thanks
Author
Owner

@douglas commented on GitHub (Jan 23, 2026):

Found a workaround.

Appending /v1 to the base URL (i.e., my_url/v1) resolves the issue.

Solved my issue as well, thanks a lot!

@douglas commented on GitHub (Jan 23, 2026): > Found a workaround. > > Appending `/v1` to the base URL (i.e., `my_url/v1`) resolves the issue. Solved my issue as well, thanks a lot!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3356