Courseiva
Claude API Mechanics →hardMultiple Choice

CCDV-F Claude API Mechanics Practice Question

A developer wants to implement 'pre-filling' to guide Claude's output toward a specific format. How should the 'messages' array be structured to accomplish this?

⚠ Common exam trap

Candidates often attempt to pre-fill by appending to the 'user' message or adding a new field, violating the API's structural requirement that the final role must be an 'assistant'.

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

✓

End the 'messages' array with an 'assistant' message containing the desired starting text.

Pre-filling is a powerful technique where the developer provides the beginning of the assistant's response. This forces Claude to continue from that point, which is highly effective for ensuring specific output formats like JSON or XML. It requires a specific message order that deviates from the typical user-only or user-assistant-user pattern.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    End the 'messages' array with a 'user' message containing the desired starting text.

    Why it's wrong here

    Putting the pre-fill text in a 'user' message will cause Claude to treat it as a request to include that text in its next answer, rather than actually starting its answer with that text. This often results in Claude repeating the text or acknowledging it rather than continuing it.

  • ✓

    End the 'messages' array with an 'assistant' message containing the desired starting text.

    Why this is correct

    By ending the array with an 'assistant' message, the developer provides the initial tokens of the response. Claude will then continue generating from where that message left off. This is the standard and recommended way to steer the model's behavior and response format effectively.

  • ✗

    Include the desired starting text in the 'system' parameter with a 'prefix' label.

    Why it's wrong here

    The 'system' parameter is for high-level instructions and does not support a 'prefix' label for pre-filling the assistant's response. While you can describe the desired start in the system prompt, it is not as reliable or direct as providing the actual assistant message prefix.

  • ✗

    Add a 'prefill' field to the top-level API request object.

    Why it's wrong here

    There is no 'prefill' field in the Anthropic Messages API schema. Attempting to add extra top-level fields that are not part of the official specification will result in a validation error. The API is strict about its JSON structure to ensure consistent behavior across all clients.

About these practice questions

Courseiva writes every CCDV-F question from scratch — 257 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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 CCDV-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 CCDV-F exam.