diff --git a/src/agent.rs b/src/agent.rs index 923a36e..955a005 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -61,7 +61,7 @@ pub async fn run(cli: &Cli) -> Result<()> { // Init clients let swym = SwymClient::new(&cli.swym_url)?; - let claude = ClaudeClient::new(&cli.anthropic_key, &cli.model); + let claude = ClaudeClient::new(&cli.anthropic_key, &cli.anthropic_url, &cli.model); // Check candle coverage for all instruments info!( diff --git a/src/claude.rs b/src/claude.rs index eb37414..cef64a9 100644 --- a/src/claude.rs +++ b/src/claude.rs @@ -6,6 +6,7 @@ use serde_json::Value; pub struct ClaudeClient { client: Client, api_key: String, + api_url: String, model: String, } @@ -41,7 +42,7 @@ pub struct Usage { } impl ClaudeClient { - pub fn new(api_key: &str, model: &str) -> Self { + pub fn new(api_key: &str, api_url: &str, model: &str) -> Self { let client = Client::builder() .timeout(std::time::Duration::from_secs(120)) .build() @@ -49,6 +50,7 @@ impl ClaudeClient { Self { client, api_key: api_key.to_string(), + api_url: api_url.to_string(), model: model.to_string(), } } @@ -66,9 +68,10 @@ impl ClaudeClient { messages: messages.to_vec(), }; + let url = format!("{}/v1/messages", self.api_url.trim_end_matches('/')); let resp = self .client - .post("https://api.anthropic.com/v1/messages") + .post(&url) .header("x-api-key", &self.api_key) .header("anthropic-version", "2023-06-01") .header("content-type", "application/json") diff --git a/src/config.rs b/src/config.rs index d14c854..b314bdb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -17,6 +17,10 @@ pub struct Cli { #[arg(long)] pub anthropic_key: String, + /// Anthropic API base URL. + #[arg(long, default_value = "https://api.anthropic.com")] + pub anthropic_url: String, + /// Claude model to use for strategy generation. #[arg(long, default_value = "claude-sonnet-4-20250514")] pub model: String, diff --git a/src/main.rs b/src/main.rs index 065c1f3..fed38e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,7 @@ async fn main() -> anyhow::Result<()> { tracing::info!("scout starting"); tracing::info!(" swym API: {}", cli.swym_url); + tracing::info!(" claude API: {}", cli.anthropic_url); tracing::info!(" model: {}", cli.model); tracing::info!(" iterations: {}", cli.max_iterations); tracing::info!(" instruments: {:?}", cli.instruments);