MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / route_headers_for_route

Function route_headers_for_route

crates/openshell-core/src/inference.rs:289–304  ·  view source on GitHub ↗

Derive routing header policy for a specific resolved route. Most providers only need their provider type. Vertex AI is special because Claude routes should forward `anthropic-beta`, while Gemini/OpenAI-compatible routes should not inherit Anthropic passthrough headers.

(
    provider_type: &str,
    protocols: &[String],
)

Source from the content-addressed store, hash-verified

287/// Claude routes should forward `anthropic-beta`, while Gemini/OpenAI-compatible
288/// routes should not inherit Anthropic passthrough headers.
289pub fn route_headers_for_route(
290 provider_type: &str,
291 protocols: &[String],
292) -> (AuthHeader, Vec<(String, String)>, Vec<String>) {
293 let (auth, headers, mut passthrough_headers) = route_headers_for_provider_type(provider_type);
294 if profile_for(provider_type).is_some_and(|profile| profile.provider_type == "google-vertex-ai")
295 {
296 let is_vertex_anthropic = protocols
297 .iter()
298 .any(|protocol| protocol == "anthropic_messages");
299 if is_vertex_anthropic && !passthrough_headers.iter().any(|h| h == "anthropic-beta") {
300 passthrough_headers.push("anthropic-beta".to_string());
301 }
302 }
303 (auth, headers, passthrough_headers)
304}
305
306// ---------------------------------------------------------------------------
307// Protocol normalization

Calls 3

profile_forFunction · 0.85
pushMethod · 0.80