Skip to content

CCAR-F · Domain 4: Prompt Engineering & Structured Output · 20% of the exam

Task 4.5: Design efficient batch processing strategies

When the Message Batches API fits (latency-tolerant work at half the price) and when it does not, custom_id correlation, resubmitting only failed requests, and sizing submission windows to an SLA.

Study it

  • The Message Batches API: when to batch, custom_id and resubmitting failures

    Partly covered by: Message Queues

Sample questions

Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.

Question 1 · choose 1

Every Friday at 6 p.m. your team starts a quality audit of about 20,000 support transcripts with Claude. Results are needed by Monday at 9 a.m., nobody waits on individual results, and the budget for the job was just cut. How should the requests be sent?

  1. AThrough the synchronous API in fast mode to get the whole audit done in one evening
  2. BThrough the Message Batches API with stream set to true so progress can be watched as results arrive
  3. CThrough the Message Batches API, polling for the results and matching them by custom_id
  4. DThrough the synchronous Messages API with as much concurrency as the rate limits allow
Show the answer and why
  • AThrough the synchronous API in fast mode to get the whole audit done in one evening

    Incorrect

    Fast mode is about synchronous latency, not price, and is not available in batches; it works against the budget.

  • BThrough the Message Batches API with stream set to true so progress can be watched as results arrive

    Incorrect

    Streaming is not supported inside batch requests; results come back as a file when processing ends.

  • CThrough the Message Batches API, polling for the results and matching them by custom_id

    Correct

    Batches cost half the standard price and finish within 24 hours, which fits a weekend deadline with no one waiting.

  • DThrough the synchronous Messages API with as much concurrency as the rate limits allow

    Incorrect

    This finishes sooner than needed but costs twice as much as a batch for latency nobody uses.

Latency-tolerant, non-blocking workloads such as weekend audits fit the Message Batches API: 50 percent lower cost and up to 24 hours of processing, with results correlated through custom_id.

Question 2 · choose 1

A Message Batches job over 10,000 documents ends with 9,860 succeeded and 140 errored results. The errors show that some documents were too long for a single request, plus a few invalid requests. Each request's custom_id is the document ID. What should you resubmit?

  1. AThe whole batch again, so that every document is processed under the same conditions
  2. BOnly the errored custom_ids, with the oversized documents split into chunks and the invalid requests fixed
  3. CThe errored documents through the synchronous API without changes so that you can watch each one finish
  4. DOnly the errored custom_ids, unchanged, since errored requests are not billed and may succeed on a second try
Show the answer and why
  • AThe whole batch again, so that every document is processed under the same conditions

    Incorrect

    Rerunning the successes doubles the cost for results you already have.

  • BOnly the errored custom_ids, with the oversized documents split into chunks and the invalid requests fixed

    Correct

    Resubmitting just the failures, changed so that they can succeed, avoids paying again for 9,860 good results.

  • CThe errored documents through the synchronous API without changes so that you can watch each one finish

    Incorrect

    A different endpoint does not make an oversized document fit or an invalid request valid.

  • DOnly the errored custom_ids, unchanged, since errored requests are not billed and may succeed on a second try

    Incorrect

    Oversized documents and invalid requests fail the same way again unless the requests are changed.

Handle batch failures by custom_id: resubmit only the failed requests, modified to remove the cause, for example by chunking documents that exceeded the context limit.

Question 3 · choose 1

Your team wants to move a pre-merge check, which developers wait on before they can merge, to the Message Batches API to halve its cost. What is the problem?

  1. ABatches always cost more for small jobs
  2. BBatches do not support code review prompts
  3. CBatches can take up to 24 hours to finish
  4. DBatches return results in random order, so they cannot be used
Show the answer and why
  • ABatches always cost more for small jobs

    Incorrect

    Batch usage is half the standard price.

  • BBatches do not support code review prompts

    Incorrect

    Almost any Messages request can be batched.

  • CBatches can take up to 24 hours to finish

    Correct

    A batch can take up to a day to return, and developers cannot merge until the check finishes.

  • DBatches return results in random order, so they cannot be used

    Incorrect

    Ordering is not what rules batches out here; the wait for results is.

A blocking pre-merge check needs the synchronous API, because a batch can take up to 24 hours to finish.

Question 4 · choose 1

An auditor asks for the raw outputs of a Message Batches job you ran 35 days ago. Your pipeline kept only the totals it parsed from them. What will you find when you try to retrieve the results?

  1. AThey are still downloadable from the Console, since the batch is still listed there
  2. BThey are gone: batch results are available for 29 days after the batch was created
  3. CThey can be regenerated by resubmitting the same batch ID
  4. DThey are available from the results URL saved when the batch ended, which stays valid
Show the answer and why
  • AThey are still downloadable from the Console, since the batch is still listed there

    Incorrect

    You may still view the batch, but its results are no longer available for download.

  • BThey are gone: batch results are available for 29 days after the batch was created

    Correct

    Results can be downloaded for 29 days from creation; after that only the batch record remains.

  • CThey can be regenerated by resubmitting the same batch ID

    Incorrect

    Submitting again creates a new batch with new processing and new costs, not the original outputs.

  • DThey are available from the results URL saved when the batch ended, which stays valid

    Incorrect

    The results expire 29 days after creation, whatever URL you saved.

Batch results are available for 29 days after the batch is created. Keep the raw outputs yourself if you may need them later, for example for audits.

Question 5 · choose 1

Every request in your batch shares the same long system prompt with a cache breakpoint, but the cache hit rate is lower than in your synchronous jobs. Is that expected?

  1. ANo; the batch must be split into batches of ten
  2. BNo; caching is guaranteed to hit for every request after the first
  3. CYes; prompt caching is not supported in batches
  4. DYes; cache hits in batches are best-effort
Show the answer and why
  • ANo; the batch must be split into batches of ten

    Incorrect

    Batch size is not the cause.

  • BNo; caching is guaranteed to hit for every request after the first

    Incorrect

    Concurrency makes hits best-effort.

  • CYes; prompt caching is not supported in batches

    Incorrect

    It is supported, on a best-effort basis.

  • DYes; cache hits in batches are best-effort

    Correct

    Caching works with batches, but hits are not guaranteed.

Prompt caching can be used with the Message Batches API, but because requests may be processed concurrently and in any order, cache hits are best-effort.

Question 6 · choose 2

You are moving a nightly job from the synchronous Messages API to the Message Batches API. Your code builds each batched request by copying the synchronous request, which sets stream: true and uses fast mode. Which TWO steps should you take before submitting 40,000 requests? (Choose TWO.)

  1. ARemove stream and the fast-mode speed setting from each request, since a batch rejects them
  2. BDry run one request of the new shape through the Messages API first
  3. CKeep stream so that results arrive as each request finishes
  4. DSplit the batch so that every request in it uses the same model
  5. EAdd requests with max_tokens set to 0 to warm the cache for the rest of the batch
Show the answer and why
  • ARemove stream and the fast-mode speed setting from each request, since a batch rejects them

    Correct

    Batch results come back as a file rather than a stream, and fast mode tunes synchronous latency; both parameters return a validation error.

  • BDry run one request of the new shape through the Messages API first

    Correct

    A single dry run of the request shape catches validation errors before they hit the whole batch.

  • CKeep stream so that results arrive as each request finishes

    Incorrect

    stream is not supported inside a batch; results are retrieved once processing ends.

  • DSplit the batch so that every request in it uses the same model

    Incorrect

    Each request is processed independently, so different kinds of requests can be mixed in one batch.

  • EAdd requests with max_tokens set to 0 to warm the cache for the rest of the batch

    Incorrect

    max_tokens 0 is not supported in a batch, because a cache entry written there would likely expire before the follow-up runs.

Almost any Messages API request can be batched, but a few parameters are rejected: stream, the fast-mode speed setting and max_tokens 0. Strip them, and dry run one request of the new shape with the Messages API before submitting the batch.

Question 7 · choose 1

In a batch of 5,000 requests, 30 come back errored because of invalid parameters. The rest succeeded. What do the docs say about the other requests and about billing?

  1. AOthers are unaffected; errored ones are not billed
  2. BErrored requests are billed at the batch rate
  3. CThe batch must be resubmitted entirely to recover the 30
  4. DThe whole batch failed and is billed in full
Show the answer and why
  • AOthers are unaffected; errored ones are not billed

    Correct

    Each request is processed independently, and errored ones are free.

  • BErrored requests are billed at the batch rate

    Incorrect

    Errored requests are not billed.

  • CThe batch must be resubmitted entirely to recover the 30

    Incorrect

    Requests are processed independently, so the succeeded results stand.

  • DThe whole batch failed and is billed in full

    Incorrect

    One request's failure does not affect others.

Batch requests are independent: a failure in one does not affect the others, and errored requests are not billed.

Practise domain 4 →Practise all domains →