Trim API key when submitting requests to LLM providers (#37082)
This prevents the common footgun of copy/pasting an API key starting/ending with extra newlines, which would lead to a "bad request" error. Closes #37038 Release Notes: - agent: Support pasting language model API keys that contain newlines.
This commit is contained in:
@@ -13,6 +13,7 @@ pub async fn stream_generate_content(
|
||||
api_key: &str,
|
||||
mut request: GenerateContentRequest,
|
||||
) -> Result<BoxStream<'static, Result<GenerateContentResponse>>> {
|
||||
let api_key = api_key.trim();
|
||||
validate_generate_content_request(&request)?;
|
||||
|
||||
// The `model` field is emptied as it is provided as a path parameter.
|
||||
|
||||
Reference in New Issue
Block a user