CCAO-F Using the Claude API Practice Question
A developer is building a document summarization service that calls the Claude Messages API. The service must always respond in valid JSON containing exactly two fields: "summary" and "confidence". The developer wants to maximize the chance of receiving a valid JSON object without writing a custom parser. Which approach should the developer take?
⚠ Common exam trap
The trap here is assuming that telling Claude to "respond in JSON" in a prompt is equivalent to schema-enforced structured output, when only a tool definition with an input_schema actually constrains the response shape.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use the Messages API with a tool definition whose input_schema describes the two required fields, and require the tool to be called.
Tool use with a JSON Schema input_schema is the Messages API's structured-output mechanism. By declaring the two fields as required properties and forcing the tool call, the developer makes Claude return arguments that conform to the schema, eliminating custom parsing. Instruction-only approaches and temperature tuning reduce but do not remove the risk of malformed or extra output, so they are less reliable for a strict two-field contract.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Send the request with temperature set to 0 and count the number of braces in the response to validate the JSON.
Why it's wrong here
Temperature 0 reduces randomness but does not constrain output to a schema, so Claude can still emit non-JSON text. Counting braces is a fragile heuristic that does not validate field names or types and can be fooled by braces inside strings. This does not provide the structured, schema-validated output the summarization service requires.
- ✓
Use the Messages API with a tool definition whose input_schema describes the two required fields, and require the tool to be called.
Why this is correct
Defining a tool whose input_schema is a JSON Schema with "summary" and "confidence", then requiring tool use, constrains Claude's output to arguments that conform to that schema. The API returns a structured tool_use block, so the developer receives a validated JSON object without building a custom parser, which directly satisfies the reliability requirement.
- ✗
Set the system prompt to instruct Claude to reply only with JSON, and include a single example of the desired JSON structure.
Why it's wrong here
A system prompt instructing JSON output plus one example is a reasonable prompt-engineering technique and often works, but it does not guarantee a valid JSON object. Claude may still add prose, omit a field, or produce malformed output. The Messages API offers a stronger, schema-enforced mechanism, so relying on instruction and one example is not the most reliable choice for this requirement.
- ✗
Append the word "JSON" to the end of the user message and set max_tokens to a value large enough for the expected output.
Why it's wrong here
Appending "JSON" to the user message is a weak prompt hint and does not enforce a schema or guarantee valid JSON. Setting max_tokens only caps output length; it does not shape structure. This approach can easily yield prose around the JSON or missing fields, so it fails to meet the requirement of reliably receiving a two-field JSON object.
About these practice questions
This CCAO-F question is part of Courseiva's 259-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Anthropic exam blueprint
This CCAO-F practice question is part of Courseiva's free Anthropic certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CCAO-F exam.