From 325e941289bfe129a76fecca93a3522895b0a853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20L=C3=BCthy?= Date: Fri, 20 Feb 2026 10:47:00 +0100 Subject: [PATCH] anthropic: Support alternative provider SSE formatting (#47847) The issue I ran into was that responses from anthropic compatible providers, like Kimi for Coding, have no space after `data:`. This change just adds a quick check to also allow for those providers to work. Before it just resolved but did not show any output: CleanShot 2026-01-28 at 12 50 31@2x Now it returns the proper result: CleanShot 2026-01-28 at 12 56 30@2x Normal Anthropic models still work as expected: CleanShot 2026-01-28 at 12 58 37@2x Config to test ```json "language_models": { "anthropic": { "api_url": "https://api.kimi.com/coding", "available_models": [ { "name": "kimi-for-coding", "display_name": "Kimi 2.5 Coding", "max_tokens": 262144, "max_output_tokens": 32768, }, ], }, } ``` TLDR: - Accepts SSE data:{...} lines (no space) emitted by some alternative Anthropic providers, in addition to the standard data: {...} format. Release Notes: - Fixed Anthropic streaming for alternative providers by accepting SSE data:{...} (no space) lines. --------- Co-authored-by: Ben Brandt --- crates/anthropic/src/anthropic.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/anthropic/src/anthropic.rs b/crates/anthropic/src/anthropic.rs index bd72fe1ef3db09c97ea853f7691f50a202b7f5ae..bc2516b8b0f53e79a03fca40f6ce4dc5b564efc1 100644 --- a/crates/anthropic/src/anthropic.rs +++ b/crates/anthropic/src/anthropic.rs @@ -781,7 +781,10 @@ pub async fn stream_completion_with_rate_limit_info( .filter_map(|line| async move { match line { Ok(line) => { - let line = line.strip_prefix("data: ")?; + let line = line + .strip_prefix("data: ") + .or_else(|| line.strip_prefix("data:"))?; + match serde_json::from_str(line) { Ok(response) => Some(Ok(response)), Err(error) => Some(Err(AnthropicError::DeserializeResponse(error))),