Feat/anthropic custom headers (#6774)
Signed-off-by: TR Jordan <tr@tern.sh> Co-authored-by: TR Jordan <tr@tern.sh> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -91,9 +91,19 @@ impl AnthropicProvider {
|
||||
key: api_key,
|
||||
};
|
||||
|
||||
let api_client = ApiClient::new(config.base_url, auth)?
|
||||
let mut api_client = ApiClient::new(config.base_url, auth)?
|
||||
.with_header("anthropic-version", ANTHROPIC_API_VERSION)?;
|
||||
|
||||
if let Some(headers) = &config.headers {
|
||||
let mut header_map = reqwest::header::HeaderMap::new();
|
||||
for (key, value) in headers {
|
||||
let header_name = reqwest::header::HeaderName::from_bytes(key.as_bytes())?;
|
||||
let header_value = reqwest::header::HeaderValue::from_str(value)?;
|
||||
header_map.insert(header_name, header_value);
|
||||
}
|
||||
api_client = api_client.with_headers(header_map)?;
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
api_client,
|
||||
model,
|
||||
|
||||
@@ -108,9 +108,19 @@ impl OllamaProvider {
|
||||
.map_err(|_| anyhow::anyhow!("Failed to set default port"))?;
|
||||
}
|
||||
|
||||
let api_client =
|
||||
let mut api_client =
|
||||
ApiClient::with_timeout(base_url.to_string(), AuthMethod::NoAuth, timeout)?;
|
||||
|
||||
if let Some(headers) = &config.headers {
|
||||
let mut header_map = reqwest::header::HeaderMap::new();
|
||||
for (key, value) in headers {
|
||||
let header_name = reqwest::header::HeaderName::from_bytes(key.as_bytes())?;
|
||||
let header_value = reqwest::header::HeaderValue::from_str(value)?;
|
||||
header_map.insert(header_name, header_value);
|
||||
}
|
||||
api_client = api_client.with_headers(header_map)?;
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
api_client,
|
||||
model,
|
||||
|
||||
Reference in New Issue
Block a user