diff --git a/crates/openai/src/serve/proxy/mod.rs b/crates/openai/src/serve/proxy/mod.rs index 334af02b9..ee2eb4849 100644 --- a/crates/openai/src/serve/proxy/mod.rs +++ b/crates/openai/src/serve/proxy/mod.rs @@ -18,6 +18,15 @@ pub(crate) fn header_convert( origin: &'static str, ) -> Result { let mut headers = HeaderMap::new(); + let mut cookies = Vec::new(); + + // Support for team accounts. + // The chat will be sent to the team account if the header is present, otherwise + // it will be sent to the personal account. + h.get("Chatgpt-Account-Id").map(|h| { + headers.insert("Chatgpt-Account-Id", h.clone()); + cookies.push(format!("{}={}", "_account", h.to_str().unwrap())); + }); h.get("Access-Control-Request-Headers") .map(|h| headers.insert("Access-Control-Request-Headers", h.clone())); @@ -76,8 +85,6 @@ pub(crate) fn header_convert( headers.insert(header::ORIGIN, header::HeaderValue::from_static(origin)); headers.insert(header::REFERER, header::HeaderValue::from_static(origin)); - let mut cookies = Vec::new(); - jar.iter() .filter(|c| { let name = c.name().to_lowercase();