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

# Artifact Builders

> Framework-agnostic helpers for constructing A2A artifacts.

Artifact builders live in `aion-core` and are shared across all frameworks. Use them to construct
`a2a.types.Artifact` objects before passing them to `emit_artifact()` or `thread.post()`.

```python theme={null}
from aion.core.a2a import url_artifact, file_artifact, data_artifact
```

## `url_artifact`

```python theme={null}
url_artifact(
    url: str,
    *,
    mime_type: str,
    name: str | None = None,
    artifact_id: str | None = None,
) -> Artifact
```

Build an artifact referencing a remote file by URL.

| Parameter     | Description                                                      |
| ------------- | ---------------------------------------------------------------- |
| `url`         | Remote file URL (e.g. `"https://cdn.example.com/report.pdf"`).   |
| `mime_type`   | MIME type of the file (e.g. `"application/pdf"`, `"image/png"`). |
| `name`        | Human-readable artifact name. Defaults to `"file"`.              |
| `artifact_id` | Explicit artifact ID. Auto-generated if not provided.            |

**Returns:** `a2a.types.Artifact` with a single `FilePart` (`FileWithUri`).

```python theme={null}
url_artifact("https://example.com/report.pdf", mime_type="application/pdf", name="report")
```

## `file_artifact`

```python theme={null}
file_artifact(
    data: bytes,
    *,
    mime_type: str,
    name: str | None = None,
    artifact_id: str | None = None,
) -> Artifact
```

Build an artifact carrying inline file content as bytes.

| Parameter     | Description                                                 |
| ------------- | ----------------------------------------------------------- |
| `data`        | File content as `bytes`.                                    |
| `mime_type`   | MIME type of the file (e.g. `"text/plain"`, `"image/png"`). |
| `name`        | Human-readable artifact name. Defaults to `"file"`.         |
| `artifact_id` | Explicit artifact ID. Auto-generated if not provided.       |

**Returns:** `a2a.types.Artifact` with a single `FilePart` (`FileWithBytes`).

**Raises:** `TypeError` if `data` is not `bytes`.

```python theme={null}
file_artifact(pdf_bytes, mime_type="application/pdf", name="report")
```

## `data_artifact`

```python theme={null}
data_artifact(
    data: dict,
    *,
    name: str | None = None,
    artifact_id: str | None = None,
) -> Artifact
```

Build an artifact carrying structured JSON data.

| Parameter     | Description                                           |
| ------------- | ----------------------------------------------------- |
| `data`        | JSON-serializable dict.                               |
| `name`        | Human-readable artifact name. Defaults to `"data"`.   |
| `artifact_id` | Explicit artifact ID. Auto-generated if not provided. |

**Returns:** `a2a.types.Artifact` with a single `DataPart` (Protobuf `Value`).

```python theme={null}
data_artifact({"status": "ok", "score": 0.95}, name="result")
```

## Full Example

```python theme={null}
from aion.core.a2a import data_artifact, file_artifact, url_artifact

# Remote file
report = url_artifact("https://example.com/report.pdf", mime_type="application/pdf", name="report")

# Inline bytes
thumbnail = file_artifact(image_bytes, mime_type="image/png", name="thumbnail")

# Structured data
metrics = data_artifact({"accuracy": 0.95, "latency_ms": 120}, name="metrics")
```

## Related Pages

* [LangGraph Streaming API](/sdk/langgraph/streaming-api)
* [ADK Streaming API](/sdk/python/frameworks/adk/streaming-api)
* [Card](/sdk/python/messaging/card)
