Skip to content

fix(oci): convert image_url to camelCase for OCI vision requests#761

Merged
daniel-cohere merged 2 commits intocohere-ai:mainfrom
fede-kamel:fix/oci-vision-image-url
Apr 13, 2026
Merged

fix(oci): convert image_url to camelCase for OCI vision requests#761
daniel-cohere merged 2 commits intocohere-ai:mainfrom
fede-kamel:fix/oci-vision-image-url

Conversation

@fede-kamel
Copy link
Copy Markdown
Contributor

@fede-kamel fede-kamel commented Apr 11, 2026

Summary

Fixes #760OciClientV2.chat() with image content returns 400 on Command A Vision.

Root Cause

OCI Generative AI expects camelCase field names. The SDK already transforms roles ("user""USER"), content types ("text""TEXT"), and tool types ("function""FUNCTION" in #758), but passes image_url through as snake_case instead of converting to imageUrl.

SDK sent:

{"type": "IMAGE_URL", "image_url": {"url": "data:image/png;base64,..."}}

OCI expects:

{"type": "IMAGE_URL", "imageUrl": {"url": "data:image/png;base64,..."}}

Fix

Convert image_urlimageUrl in content items during request transformation.

Verified

response = client.chat(
    model="command-a-vision",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What color is this image? Reply with one word."},
            {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}},
        ],
    }],
)
# Response: "Red"

Integration test added

test_chat_vision_v2 sends a 1x1 red PNG to Command A Vision and asserts:

  • Response is not None
  • Content is non-empty
  • Model correctly identifies the color as "red"
tests/test_oci_client.py::TestOciClientV2::test_chat_vision_v2 PASSED
================ 46 passed, 13 deselected, 71 warnings in 7.36s ================

Test plan

  • 46/46 non-streaming tests pass
  • New test_chat_vision_v2 passes against OCI us-chicago-1 with command-a-vision
  • Existing content transformation tests unaffected

@daniel-cohere Vision was broken on OCI because image_url wasn't converted to camelCase imageUrl. Same pattern as the tool type issue in #758.


Note

Low Risk
Low risk, localized request-shaping change for OciClientV2.chat() plus a new integration test; primary risk is limited to OCI vision payload compatibility/regression for message content transformation.

Overview
Fixes OciClientV2 chat request transformation to convert vision content items from snake_case image_url to OCI-required camelCase imageUrl, preventing 400s on Command A Vision.

Adds an integration test (test_chat_vision_v2) that sends a tiny inline PNG via image_url content and asserts the model returns a non-empty response that identifies the color.

Reviewed by Cursor Bugbot for commit 537b1eb. Bugbot is set up for automated code reviews on this repo. Configure here.

…ests

OCI Generative AI expects camelCase field names. The SDK transforms
message roles and content types but passed image_url through as-is,
causing 400 errors on Command A Vision with inline images.

Added integration test that sends a 1x1 red PNG to Command A Vision
and verifies the model correctly identifies the color.

Fixes cohere-ai#760
Keep both the vision test (from this branch) and the tool use,
type lowercasing, multi-turn, and safety_mode tests (from upstream).
@fede-kamel
Copy link
Copy Markdown
Contributor Author

@daniel-cohere Conflicts resolved and all 65 integration tests passing against live OCI GenAI (including the new vision test). Ready for merge whenever you are.

@daniel-cohere daniel-cohere merged commit 756b1d8 into cohere-ai:main Apr 13, 2026
1 check passed
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.

fix: OCI vision requests fail — image_url not converted to camelCase

2 participants