Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config/plano_config_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ properties:
passthrough_auth:
type: boolean
description: "When true, forwards the client's Authorization header to upstream instead of using the configured access_key. Useful for routing to services like LiteLLM that validate their own virtual keys."
http_headers:
type: object
description: "Custom HTTP headers to include in requests to this LLM provider. Useful for providers requiring non-standard authentication or telemetry headers."
additionalProperties:
type: string
http_host:
type: string
provider_interface:
Expand Down Expand Up @@ -224,6 +229,11 @@ properties:
passthrough_auth:
type: boolean
description: "When true, forwards the client's Authorization header to upstream instead of using the configured access_key. Useful for routing to services like LiteLLM that validate their own virtual keys."
http_headers:
type: object
description: "Custom HTTP headers to include in requests to this LLM provider. Useful for providers requiring non-standard authentication or telemetry headers."
additionalProperties:
type: string
http_host:
type: string
provider_interface:
Expand Down
2 changes: 2 additions & 0 deletions crates/common/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ pub struct LlmProvider {
pub base_url_path_prefix: Option<String>,
pub internal: Option<bool>,
pub passthrough_auth: Option<bool>,
pub http_headers: Option<HashMap<String, String>>,
}

pub trait IntoModels {
Expand Down Expand Up @@ -488,6 +489,7 @@ impl Default for LlmProvider {
base_url_path_prefix: None,
internal: None,
passthrough_auth: None,
http_headers: None,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/common/src/llm_providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ mod tests {
internal: None,
stream: None,
passthrough_auth: None,
http_headers: None,
}
}

Expand Down
9 changes: 9 additions & 0 deletions crates/llm_gateway/src/stream_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ impl StreamContext {
Ok(())
}

fn set_custom_provider_headers(&mut self) {
if let Some(http_headers) = self.llm_provider().http_headers.clone() {
for (key, value) in &http_headers {
self.set_http_request_header(key.as_str(), Some(value.as_str()));
}
}
}

fn delete_content_length_header(&mut self) {
// Remove the Content-Length header because further body manipulations in the gateway logic will invalidate it.
// Server's generally throw away requests whose body length do not match the Content-Length header.
Expand Down Expand Up @@ -879,6 +887,7 @@ impl HttpContext for StreamContext {
self.send_server_error(error, Some(StatusCode::BAD_REQUEST));
}
}
self.set_custom_provider_headers();
}

self.delete_content_length_header();
Expand Down