fix: respect ANTHROPIC_BASE_URL in all client instantiations
This commit is contained in:
1
.claude/sessions/session-1775007533836.json
Normal file
1
.claude/sessions/session-1775007533836.json
Normal file
@@ -0,0 +1 @@
|
||||
{"messages":[],"version":1}
|
||||
1
.claude/sessions/session-1775007622154.json
Normal file
1
.claude/sessions/session-1775007622154.json
Normal file
@@ -0,0 +1 @@
|
||||
{"messages":[{"blocks":[{"text":"What is 2+2? Reply with just the number.","type":"text"}],"role":"user"},{"blocks":[{"text":"4","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":19,"output_tokens":5}}],"version":1}
|
||||
1
.claude/sessions/session-1775007632904.json
Normal file
1
.claude/sessions/session-1775007632904.json
Normal file
@@ -0,0 +1 @@
|
||||
{"messages":[{"blocks":[{"text":"Say hello in exactly 3 words","type":"text"}],"role":"user"},{"blocks":[{"text":"Hello there, friend!","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":14,"output_tokens":8}}],"version":1}
|
||||
1
rust/.claude/sessions/session-1775007453382.json
Normal file
1
rust/.claude/sessions/session-1775007453382.json
Normal file
@@ -0,0 +1 @@
|
||||
{"messages":[],"version":1}
|
||||
1
rust/.claude/sessions/session-1775007484031.json
Normal file
1
rust/.claude/sessions/session-1775007484031.json
Normal file
@@ -0,0 +1 @@
|
||||
{"messages":[],"version":1}
|
||||
1
rust/.claude/sessions/session-1775007490104.json
Normal file
1
rust/.claude/sessions/session-1775007490104.json
Normal file
@@ -0,0 +1 @@
|
||||
{"messages":[],"version":1}
|
||||
@@ -520,7 +520,7 @@ fn read_auth_token() -> Option<String> {
|
||||
.and_then(std::convert::identity)
|
||||
}
|
||||
|
||||
fn read_base_url() -> String {
|
||||
pub fn read_base_url() -> String {
|
||||
std::env::var("ANTHROPIC_BASE_URL").unwrap_or_else(|_| DEFAULT_BASE_URL.to_string())
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ mod sse;
|
||||
mod types;
|
||||
|
||||
pub use client::{
|
||||
oauth_token_is_expired, resolve_saved_oauth_token, resolve_startup_auth_source,
|
||||
AnthropicClient, AuthSource, MessageStream, OAuthTokenSet,
|
||||
oauth_token_is_expired, read_base_url, resolve_saved_oauth_token,
|
||||
resolve_startup_auth_source, AnthropicClient, AuthSource, MessageStream, OAuthTokenSet,
|
||||
};
|
||||
pub use error::ApiError;
|
||||
pub use sse::{parse_frame, SseParser};
|
||||
|
||||
@@ -450,7 +450,7 @@ fn run_login() -> Result<(), Box<dyn std::error::Error>> {
|
||||
return Err(io::Error::new(io::ErrorKind::InvalidData, "oauth state mismatch").into());
|
||||
}
|
||||
|
||||
let client = AnthropicClient::from_auth(AuthSource::None);
|
||||
let client = AnthropicClient::from_auth(AuthSource::None).with_base_url(api::read_base_url());
|
||||
let exchange_request =
|
||||
OAuthTokenExchangeRequest::from_config(oauth, code, state, pkce.verifier, redirect_uri);
|
||||
let runtime = tokio::runtime::Runtime::new()?;
|
||||
@@ -1021,7 +1021,7 @@ impl LiveCli {
|
||||
}
|
||||
|
||||
fn run_prompt_json(&mut self, input: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let client = AnthropicClient::from_auth(resolve_cli_auth_source()?);
|
||||
let client = AnthropicClient::from_auth(resolve_cli_auth_source()?).with_base_url(api::read_base_url());
|
||||
let request = MessageRequest {
|
||||
model: self.model.clone(),
|
||||
max_tokens: DEFAULT_MAX_TOKENS,
|
||||
@@ -1922,7 +1922,7 @@ impl AnthropicRuntimeClient {
|
||||
) -> Result<Self, Box<dyn std::error::Error>> {
|
||||
Ok(Self {
|
||||
runtime: tokio::runtime::Runtime::new()?,
|
||||
client: AnthropicClient::from_auth(resolve_cli_auth_source()?),
|
||||
client: AnthropicClient::from_auth(resolve_cli_auth_source()?).with_base_url(api::read_base_url()),
|
||||
model,
|
||||
enable_tools,
|
||||
allowed_tools,
|
||||
|
||||
Reference in New Issue
Block a user