Skip to content

Commit

Permalink
Merge pull request #19 from mslinnea/anthropic-api-images
Browse files Browse the repository at this point in the history
Remove prefix from base64 inline image data for Anthropic AI integration
  • Loading branch information
felixarntz authored Nov 19, 2024
2 parents 0cfad15 + ef0e615 commit ed35caf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion includes/Anthropic/Anthropic_AI_Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,12 @@ private static function get_content_transformers(): array {
'source' => array(
'type' => 'base64',
'media_type' => $mime_type,
'data' => $part->get_base64_data(),
// The Anthropic AI API expects inlineData blobs to be without the prefix.
'data' => preg_replace(
'/^data:[a-z]+\/[a-z]+;base64,/',
'',
$part->get_base64_data()
),
),
);
} else {
Expand Down

0 comments on commit ed35caf

Please sign in to comment.