Skip to content

fix: convert OAI ImageUrl to Claude Image format in CC proxy#121

Open
DragonFSKY wants to merge 1 commit intoXerxes-2:masterfrom
DragonFSKY:fix/cc-openai-image-conversion
Open

fix: convert OAI ImageUrl to Claude Image format in CC proxy#121
DragonFSKY wants to merge 1 commit intoXerxes-2:masterfrom
DragonFSKY:fix/cc-openai-image-conversion

Conversation

@DragonFSKY
Copy link
Contributor

Summary

  • Fix image conversion in Claude Code proxy's OpenAI-compatible endpoint (/code/v1)
  • Convert OpenAI's image_url format to Claude's native image format with source block
  • Add normalize_block() function to handle the format transformation
  • Includes 10 unit tests covering various image format scenarios

Problem

The /code/v1 endpoint was not properly converting OpenAI's image format to Claude's expected format, causing image content to be ignored.

Changes

  • Add normalize_block() function in src/types/oai.rs to convert:
    • image_url with data:image/xxx;base64,... URL → Claude image with source.type = "base64"
    • Preserve text blocks unchanged
    • Filter out unsupported block types

Test Results

Tested with various image sizes (50x50, 100x100, 200x200, 500x500) - all correctly identified colors.

Test plan

  • Unit tests pass (cargo test)
  • Manual testing with PNG images of various sizes
  • Manual testing with JPEG images

@LeenHawk LeenHawk force-pushed the master branch 4 times, most recently from c74ffd6 to 61aef16 Compare February 2, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant