PrepGenAICerts

Streaming, Tool Use & Vision

Core

Work with the Messages API's core request/response mechanics · Difficulty 2/5

0%
streamingtool-usevisionmultimodal

Explanation

Streaming

Setting stream=True delivers the response as server-sent events as the model generates it, rather than waiting for the full response. The integration code consumes events (message_start, content_block_delta, message_stop) and assembles the text incrementally. This lowers perceived latency for interactive UIs -- it changes *when* tokens arrive, not how many tokens are generated or billed.

Tool Use

Pass a tools array of JSON-schema tool definitions. When Claude decides to use one:

  1. The response's stop_reason is `tool_use`
  2. The response content contains a `tool_use` block (tool name and arguments)
  3. Your code executes the tool
  4. You send the result back as a `tool_result block inside a new user` message

This loop is the foundation of every agent built on the Messages API (full treatment in the tool-design/MCP domain).

Vision (Multimodal Input)

Content blocks can include images (base64-encoded or by URL) alongside text, so Claude can read screenshots, charts, and documents in the same request as a text instruction. This is the "multi-format input" capability referenced across the exam blueprint.

Common exam traps

  • **"Streaming reduces cost."** It does not -- it reduces perceived latency only; total tokens and total cost are unchanged.
  • Treating a tool_use stop_reason as a final answer rather than a signal that the loop must continue: execute the tool, then send a `tool_result` block back.
  • Assuming vision requires a separate API -- it is the same Messages API, with image content blocks alongside text in the same message.

Key Takeaways

  • Streaming delivers server-sent events as generation happens, lowering perceived latency without changing total tokens or cost
  • A tool_use stop_reason means Claude wants to call a tool: execute it, then return a tool_result block in a new user message
  • Vision content blocks (base64 or URL images) sit alongside text in the same Messages API request
  • "Streaming saves money" is a common exam trap -- it only changes delivery timing

Glossary Terms

Related Concepts

PrepGenAICerts.com is an independent third-party exam-prep platform for the Claude Certified Architect (CCA-F) certification. We are not affiliated with, endorsed by, or acting on behalf of Anthropic PBC.

Note: New premium upgrades are temporarily paused while we resolve an issue with our payment provider. Existing premium members retain full access.