1jehuang / 1jehuang/jcode

Support Anthropic-compatible base URLs for direct Anthropic provider

Open
#325 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

autonomous: no enhancement priority: medium triage: needs-decision
Dominant language
Rust
Stars
19.9k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
30

Description

Problem

The direct Anthropic provider currently builds direct Messages and model-catalog requests against the official Anthropic API endpoints. That works for ANTHROPIC_API_KEY, but it prevents Anthropic-compatible gateways/proxies from being used even when a user provides Anthropic-style environment variables such as ANTHROPIC_BASE_URL and a bearer-style ANTHROPIC_AUTH_TOKEN.

This is separate from the Claude OAuth/subscription path: OAuth should keep using the official Anthropic OAuth endpoints because the preflight/bootstrap flow depends on them.

Reproduction

Configure a local or enterprise Anthropic-compatible gateway:

$env:JCODE_RUNTIME_PROVIDER = "anthropic-api"
$env:ANTHROPIC_BASE_URL = "http://127.0.0.1:15721/anthropic/v1"
$env:ANTHROPIC_AUTH_TOKEN = "<redacted>"

Then run a direct Anthropic request, for example:

jcode --provider anthropic-api run --tool-profile none "Reply exactly OK"

Expected behavior:

  • Messages requests go to http://127.0.0.1:15721/anthropic/v1/messages.
  • Bearer-style gateway tokens are sent as Authorization: Bearer <token>.
  • Official ANTHROPIC_API_KEY usage continues to send x-api-key to the default Anthropic API.
  • Claude OAuth continues to use the official OAuth URL and headers.

Actual behavior:

  • The direct Anthropic transport is tied to official Anthropic endpoints/auth behavior, so the gateway cannot be selected through the usual Anthropic-compatible env vars.
Notes

A focused fix should keep OAuth unchanged, preserve the existing direct API-key path, and only apply custom base URL/bearer-token handling to non-OAuth direct Anthropic requests.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the direct Anthropic transport and the separate Claude OAuth/bootstrap path, then run the reproduction command with the shown environment variables. Done means gateway requests use the configured base URL and bearer token, while direct API-key requests and OAuth retain their existing endpoints and headers.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
ai, cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.