# `Raxol.AgentClientProtocol.Schema.ContentBlock`
[🔗](https://github.com/DROOdotFOO/raxol-agent/blob/raxol_agent_client_protocol-v0.1.0/packages/raxol_agent_client_protocol/lib/raxol/agent_client_protocol/schema/content.ex#L675)

Content blocks represent displayable information in ACP: a tagged union
discriminated by a `"type"` wire key (`text` | `image` | `audio` |
`resource_link` | `resource`). Named `ContentBlock` both upstream and
here (all other structs ported from `content.ex` -- `Role`, `Annotations`,
`TextContent`, `ImageContent`, `AudioContent`, `TextResourceContents`,
`BlobResourceContents`, `EmbeddedResourceResource`, `EmbeddedResource`,
`ResourceLink` -- are separate, bare `Schema.*` modules, not nested under
this one).

Ported from the MIT `f1729/agent_client_protocol` (c) 2025 f1729; see NOTICE.md.

# `t`

```elixir
@type t() ::
  {:text, Raxol.AgentClientProtocol.Schema.TextContent.t()}
  | {:image, Raxol.AgentClientProtocol.Schema.ImageContent.t()}
  | {:audio, Raxol.AgentClientProtocol.Schema.AudioContent.t()}
  | {:resource_link, Raxol.AgentClientProtocol.Schema.ResourceLink.t()}
  | {:resource, Raxol.AgentClientProtocol.Schema.EmbeddedResource.t()}
```

# `audio`

```elixir
@spec audio(Raxol.AgentClientProtocol.Schema.AudioContent.t()) :: t()
```

# `from_json`

```elixir
@spec from_json(term()) :: {:ok, t()} | {:error, term()}
```

Total: never raises. An unrecognized/missing `"type"`, or a variant body
that fails to decode, returns `{:error, _}` (a content block has no
documented default variant, unlike e.g. `ToolCall.ToolKind`).

# `from_string`

```elixir
@spec from_string(String.t()) :: t()
```

Convenience: create a text content block from a plain string.

# `image`

```elixir
@spec image(Raxol.AgentClientProtocol.Schema.ImageContent.t()) :: t()
```

# `resource`

```elixir
@spec resource(Raxol.AgentClientProtocol.Schema.EmbeddedResource.t()) :: t()
```

# `resource_link`

```elixir
@spec resource_link(Raxol.AgentClientProtocol.Schema.ResourceLink.t()) :: t()
```

# `text`

```elixir
@spec text(Raxol.AgentClientProtocol.Schema.TextContent.t()) :: t()
```

# `to_json`

```elixir
@spec to_json(t()) :: map()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
