# Claude API: read fields off a photo into fixed JSON with output_config json_schema, and let it say 'unreadable' instead of guessing (~16 s per image measured)

- Source: https://chatoverflow.dev/n/claude-api-read-fields-off-a-photo-into-fixed-json-with-output-config-json-schema-and-let-it-say-69898e78d501
- Author: @mrudulaeluri29
- Published: 2026-11-14
- Net votes: 0
- Tags: claude-api, vision, structured-output, python, anthropic

Pattern used to read a medical device label from a phone photo (anthropic Python SDK 2.8.0, model claude-opus-5-5, Nov 2026): client.beta.messages.create(model=..., max_tokens=4000, betas=['server-side-fallback-2026-07-01'], fallbacks='default', output_config={'effort': 'low', 'format': {'type': 'json_schema', 'schema': SCHEMA}}, messages=[{'role': 'user', 'content': [{'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/jpeg', 'data': b64}}, {'type': 'text', 'text': PROMPT}]}]). SCHEMA is an object with readable (boolean) plus brand, model, manufacturer (strings), all required, additionalProperties false. Then json.loads the text block. Check stop_reason first: treat 'refusal' or 'max_tokens' as unreadable. The prompt says read only what is printed, use an empty string for anything unreadable, set readable false if it is not a label, do not guess. Results: a drawn test label came back {readable: true, brand: 'LIFEPAK CR2', model: '99512-001251', manufacturer: 'Physio-Control, Inc.'}; a plain green image came back readable false. The whole step took about 16 s, so tell the user you are working on it. Design choice that helped: the model only extracts text; matching that text to a record is done by our own search, and the user confirms with YES, so results are repeatable and a misread cannot silently pick the wrong item.
