# `Jidoka.ContentPart`
[🔗](https://github.com/agentjido/jidoka/blob/v0.9.0/lib/jidoka/content_part.ex#L1)

Provider-neutral text and media content for requests, messages, and results.

Media parts use one source: `{:url, url}`, `{:data, binary}`, or
`{:file_id, id}`. The durable struct keeps the source value. Public
projections omit the value and show only its kind and safe size data.

# `content_type`

```elixir
@type content_type() :: :text | :image | :audio | :video | :document
```

# `input`

```elixir
@type input() :: t() | keyword() | map()
```

# `source`

```elixir
@type source() :: {:url, String.t()} | {:data, binary()} | {:file_id, String.t()}
```

# `t`

```elixir
@type t() :: %Jidoka.ContentPart{
  data: nil | nil | any(),
  file_id: nil | nil | binary(),
  filename: nil | nil | binary(),
  media_type: nil | nil | binary(),
  metadata: map(),
  text: nil | nil | binary(),
  type: (((:text | :image) | :audio) | :video) | :document,
  url: nil | nil | binary()
}
```

# `audio`

```elixir
@spec audio(
  source(),
  keyword()
) :: t()
```

Builds an audio part.

# `document`

```elixir
@spec document(
  source(),
  keyword()
) :: t()
```

Builds a document part.

# `from_input`

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

Normalizes a content part struct, keyword list, or map.

# `from_inputs`

```elixir
@spec from_inputs([input()]) :: {:ok, [t()]} | {:error, term()}
```

Normalizes an ordered content-part list.

# `image`

```elixir
@spec image(
  source(),
  keyword()
) :: t()
```

Builds an image part.

# `new`

```elixir
@spec new(keyword() | map()) :: {:ok, t()} | {:error, term()}
```

Builds a content part from a keyword list or map.

# `new!`

```elixir
@spec new!(keyword() | map()) :: t()
```

Builds a content part and raises if it is not valid.

# `schema`

```elixir
@spec schema() :: Zoi.schema()
```

Returns the Zoi schema for a content part.

# `source_kind`

```elixir
@spec source_kind(t()) :: :text | :url | :data | :file_id
```

Returns the source kind for a media part.

# `summary`

```elixir
@spec summary([t()]) :: String.t()
```

Returns a non-empty text summary for controls, memory, and debugging.

# `text`

```elixir
@spec text(
  String.t(),
  keyword()
) :: t()
```

Builds a text part.

# `text_content`

```elixir
@spec text_content([t()]) :: String.t()
```

Returns the text in an ordered part list.

# `to_map`

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

Converts a part into a complete map for an adapter.

# `types`

```elixir
@spec types() :: [content_type()]
```

Returns the supported content types.

# `video`

```elixir
@spec video(
  source(),
  keyword()
) :: t()
```

Builds a video part.

---

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