Elffuss BraidHub

kikocis/continue public

fix(cli): extract media type when submitting images in anthropic
Changesetd2b29fd95725246e73f747da2c0fd6555208cf58e20218a33b012011977e5713
Authoruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-08 22:31 +05:30
Committeruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-08 22:31 +05:30
Parentsf679de86c340

Browse the files at this changeset

1 file changed

modified packages/openai-adapters/src/apis/Anthropic.ts +9 −3
@@ -174,13 +174,19 @@
174174 }
175175 return part;
176176 }
177+ const dataUrl =
178+ (part as OpenAI.Chat.Completions.ChatCompletionContentPartImage)
179+ ?.image_url?.url || "";
180+ // Extract media type from data URL (ex. "data:image/png;base64,..." -> "image/png")
181+ const mediaTypeMatch = dataUrl.match(/^data:([^;]+);base64,/);
182+ const mediaType = mediaTypeMatch ? mediaTypeMatch[1] : "image/jpeg";
183+
177184 return {
178185 type: "image",
179186 source: {
180187 type: "base64",
181- media_type: "image/jpeg",
182- // @ts-ignore
183- data: part.image_url.url.split(",")[1],
188+ media_type: mediaType,
189+ data: dataUrl.split(",")[1],
184190 },
185191 };
186192 })