Custom baseURL configuration returns "Route /api/messages not found" error
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/@[email protected]+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:950:18)\n at processTicksAndRejections (native:7:39)" process
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:
ProviderInitErrorwith Anthropic - related to Anthropic API configuration issues
Feel free to ignore if none of these address your specific case.
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
Found a workaround.
Appending
/v1to 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