# `LangChain.OpenTelemetry.MessageSerializer`
[🔗](https://github.com/brainlid/langchain/blob/v0.13.0/lib/open_telemetry/message_serializer.ex#L1)

Serializes LangChain `Message` structs to JSON strings following the
`gen_ai.input.messages` / `gen_ai.output.messages` GenAI Semantic Convention schema.

The Erlang OpenTelemetry SDK uses flat key-value attributes, so messages are
serialized as a JSON string rather than nested structures.

# `serialize_input`
[🔗](https://github.com/brainlid/langchain/blob/v0.13.0/lib/open_telemetry/message_serializer.ex#L21)

```elixir
@spec serialize_input([LangChain.Message.t()]) :: String.t()
```

Serializes a list of messages to a JSON string for `gen_ai.input.messages`.

Each message is represented as a map with `role` and `content` keys.
Tool calls are included under the `tool_calls` key when present.

# `serialize_output`
[🔗](https://github.com/brainlid/langchain/blob/v0.13.0/lib/open_telemetry/message_serializer.ex#L32)

```elixir
@spec serialize_output(LangChain.Message.t() | [LangChain.Message.t()]) :: String.t()
```

Serializes a result (single message or list of messages) to a JSON string
for `gen_ai.output.messages`.

---

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