-
Notifications
You must be signed in to change notification settings - Fork 93
feat: add image recognition support for anthropic #1445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
teamdandelion
merged 1 commit into
v2
from
10-20-feat_add_image_recognition_support_for_anthropic
Oct 24, 2025
+361
−16
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 112 additions & 4 deletions
116
...n/tests/e2e/input/cassettes/test_call_with_image_content/anthropic_claude_sonnet_4_0.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
110 changes: 110 additions & 0 deletions
110
python/tests/e2e/input/cassettes/test_call_with_image_url/anthropic_claude_sonnet_4_0.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| interactions: | ||
| - request: | ||
| body: '{"max_tokens":16000,"messages":[{"role":"user","content":[{"type":"text","text":"Describe | ||
| the following image in one sentence"},{"type":"image","source":{"type":"url","url":"https://en.wikipedia.org/static/images/icons/wikipedia.png"}}]}],"model":"claude-sonnet-4-0"}' | ||
| headers: | ||
| accept: | ||
| - application/json | ||
| accept-encoding: | ||
| - gzip, deflate | ||
| anthropic-version: | ||
| - '2023-06-01' | ||
| connection: | ||
| - keep-alive | ||
| content-length: | ||
| - '267' | ||
| content-type: | ||
| - application/json | ||
| host: | ||
| - api.anthropic.com | ||
| user-agent: | ||
| - Anthropic/Python 0.64.0 | ||
| x-stainless-arch: | ||
| - arm64 | ||
| x-stainless-async: | ||
| - 'false' | ||
| x-stainless-lang: | ||
| - python | ||
| x-stainless-os: | ||
| - MacOS | ||
| x-stainless-package-version: | ||
| - 0.64.0 | ||
| x-stainless-read-timeout: | ||
| - '600' | ||
| x-stainless-retry-count: | ||
| - '0' | ||
| x-stainless-runtime: | ||
| - CPython | ||
| x-stainless-runtime-version: | ||
| - 3.10.16 | ||
| x-stainless-timeout: | ||
| - '600' | ||
| method: POST | ||
| uri: https://api.anthropic.com/v1/messages | ||
| response: | ||
| body: | ||
| string: !!binary | | ||
| H4sIAAAAAAAAA3SR34sTQQyA/5WQ5620Z/uyryIUFEERFUSWOJPuxpvNjJPMtV7p/y5bLOLJPQXy | ||
| fflBcsY5R07YY0jUIq8sq7Kvtqu79d1uvdtssUOJ2ONs47DefHj/6cfptG17svxl//rN21e2f+fY | ||
| of8qvFhsRiNjhzWnJUFmYk66OCGrszr2X8833/l0rV5Cjx8nMRADnxgkZJUAn+VeCkchSHnMHRyY | ||
| vFXREQisTFwlUILSHh8Tw5jyd4aZIkMrkA9wnMT5RotwYIOj+ATLQBCFB6qSm0EiHRuNbEAawUKV | ||
| 4gaHmmegmpvG607HXFN8gZdvHZrnMlQmy4o9ssbBW1X8A4x/NtbA2GtLqcN2PUp/RtHSfPB8z2rY | ||
| v9x2GChMPITK5JJ1+FdY33hlis+xW+3Sn8vEM1dKw27+3/9LN9NTeukwN3+6nXF9kMCDC1fscflk | ||
| pBrxcvkNAAD//wMAZHCFKjoCAAA= | ||
| headers: | ||
| CF-RAY: | ||
| - 991d76f70ef049b2-SEA | ||
| Connection: | ||
| - keep-alive | ||
| Content-Encoding: | ||
| - gzip | ||
| Content-Type: | ||
| - application/json | ||
| Date: | ||
| - Tue, 21 Oct 2025 02:53:30 GMT | ||
| Server: | ||
| - cloudflare | ||
| Transfer-Encoding: | ||
| - chunked | ||
| X-Robots-Tag: | ||
| - none | ||
| anthropic-organization-id: | ||
| - 217a607f-ed5e-40af-8a7d-f83ed52d59d6 | ||
| anthropic-ratelimit-input-tokens-limit: | ||
| - '2000000' | ||
| anthropic-ratelimit-input-tokens-remaining: | ||
| - '2000000' | ||
| anthropic-ratelimit-input-tokens-reset: | ||
| - '2025-10-21T02:53:29Z' | ||
| anthropic-ratelimit-output-tokens-limit: | ||
| - '400000' | ||
| anthropic-ratelimit-output-tokens-remaining: | ||
| - '400000' | ||
| anthropic-ratelimit-output-tokens-reset: | ||
| - '2025-10-21T02:53:30Z' | ||
| anthropic-ratelimit-requests-limit: | ||
| - '4000' | ||
| anthropic-ratelimit-requests-remaining: | ||
| - '3999' | ||
| anthropic-ratelimit-requests-reset: | ||
| - '2025-10-21T02:53:27Z' | ||
| anthropic-ratelimit-tokens-limit: | ||
| - '2400000' | ||
| anthropic-ratelimit-tokens-remaining: | ||
| - '2400000' | ||
| anthropic-ratelimit-tokens-reset: | ||
| - '2025-10-21T02:53:29Z' | ||
| cf-cache-status: | ||
| - DYNAMIC | ||
| request-id: | ||
| - req_011CUKb3QTvJnQoJcS9GAnS8 | ||
| strict-transport-security: | ||
| - max-age=31536000; includeSubDomains; preload | ||
| via: | ||
| - 1.1 google | ||
| x-envoy-upstream-service-time: | ||
| - '2797' | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
51 changes: 48 additions & 3 deletions
51
...e2e/input/snapshots/test_call_with_image_content/anthropic_claude_sonnet_4_0_snapshots.py
Large diffs are not rendered by default.
Oops, something went wrong.
50 changes: 47 additions & 3 deletions
50
...sts/e2e/input/snapshots/test_call_with_image_url/anthropic_claude_sonnet_4_0_snapshots.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,54 @@ | ||
| from inline_snapshot import snapshot | ||
|
|
||
| from mirascope.llm import ( | ||
| AssistantMessage, | ||
| Image, | ||
| Text, | ||
| URLImageSource, | ||
| UserMessage, | ||
| ) | ||
|
|
||
| test_snapshot = snapshot( | ||
| { | ||
| "exception": { | ||
| "type": "NotImplementedError", | ||
| "args": "('Content type image not supported',)", | ||
| "response": { | ||
| "provider": "anthropic", | ||
| "model_id": "claude-sonnet-4-0", | ||
| "params": {}, | ||
| "finish_reason": None, | ||
| "messages": [ | ||
| UserMessage( | ||
| content=[ | ||
| Text(text="Describe the following image in one sentence"), | ||
| Image( | ||
| source=URLImageSource( | ||
| type="url_image_source", | ||
| url="https://en.wikipedia.org/static/images/icons/wikipedia.png", | ||
| ) | ||
| ), | ||
| ] | ||
| ), | ||
| AssistantMessage( | ||
| content=[ | ||
| Text( | ||
| text="This is the iconic Wikipedia logo, featuring a spherical puzzle globe made up of white puzzle pieces with text in various languages and scripts from around the world." | ||
| ) | ||
| ], | ||
| provider="anthropic", | ||
| model_id="claude-sonnet-4-0", | ||
| raw_message={ | ||
| "role": "assistant", | ||
| "content": [ | ||
| { | ||
| "citations": None, | ||
| "text": "This is the iconic Wikipedia logo, featuring a spherical puzzle globe made up of white puzzle pieces with text in various languages and scripts from around the world.", | ||
| "type": "text", | ||
| } | ||
| ], | ||
| }, | ||
| ), | ||
| ], | ||
| "format": None, | ||
| "tools": [], | ||
| } | ||
| } | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.