> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cosmon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Images from tools

> Decode the data: URIs a tool produces (CAD screenshots) and save them.

Some tools produce images for the user — a CAD screenshot, a plotted result.
They ride the `ToolCall`'s **finish** event as `event.images`, a
`tuple[str, ...]` of image `data:` URIs (empty on the start event, and from apps
too old to send them). Decode each on the finish event:

```python theme={null}
import base64, re
from pathlib import Path
from cosmon_agent_sdk import Client, ToolCall

with Client() as client:
    for i, event in enumerate(client.run("Screenshot the open part", agent="solidworks")):
        if isinstance(event, ToolCall) and event.finished:
            for uri in event.images:                       # () when the tool produced none
                m = re.match(r"^data:image/\w+;base64,(.+)$", uri)
                if m:                                       # http links stay stream-only
                    Path(f"shot-{i}.png").write_bytes(base64.b64decode(m[1]))
```

Each `data:` image is also embedded in the run's final result as a spec-native
MCP image content block, so plain MCP clients see it too. `.text()` is
unaffected — it joins only the text.

<Note>
  Only `data:` URIs are embedded in the final result — a tool that returns an
  `http(s)` image link surfaces it on the stream event but can't embed it, so it
  stays stream-only.
</Note>

<Card title="Reference: ToolCall.images" icon="code" href="/sdk/python-reference">
  The `images` field on the streamed `ToolCall` event.
</Card>
