# `Sycophant.Serializable`

Protocol for converting Sycophant structs to plain maps for JSON serialization.

Every implementation includes a `"__type__"` discriminator key that enables
round-trip decoding via `Sycophant.Serializable.Decoder`.

## Round-trip Example

    response = %Sycophant.Response{...}
    json = Sycophant.Serializable.Decoder.encode(response)
    restored = Sycophant.Serializable.Decoder.decode(json)

All core structs implement this protocol: `Response`, `Context`, `Message`,
`Tool`, `ToolCall`, `Usage`, `Reasoning`, `EmbeddingRequest`,
`EmbeddingResponse`, `EmbeddingParams`, and content parts.

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `to_map`

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

Converts a Sycophant struct into a plain map with a `__type__` discriminator.

---

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