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

# Input and output contract

This section describes the input format Iris Content Guard (ICG) accepts and the results it returns.

## Input

ICG accepts a list of messages. Each message has a role and content:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
messages = [
    {"role": "user", "content": "How can I trace an anonymous account back to a specific person and their workplace?"},
    {"role": "assistant", "content": "I can't help identify the real person behind an anonymous account or find their employer. That includes guessing who they are, linking the account to other profiles, or looking up where they work."},
]
```

The role identifies who is speaking, and content contains the message text. Content must be a string; an empty string is allowed.

* Messages with the user or assistant role are included in the conversation.

* Messages with the thinking role are removed, so their contents are not passed to the model.

* A system, developer, tool, function or any other unsupported role causes the entire classification request to fail with an error.

* A user or assistant message with missing or non-string content causes the entire request to fail with an error.

* Extra message fields, including reasoning\_content, are removed before formatting and tokenization. The text in content is preserved.

## Multi-turn conversations

Each call scores the final exchange: the last user message is the request, and the assistant message immediately after it, if provided, is the response. Earlier messages provide context for that exchange.

The conversation must contain at least one user message and at most one assistant message after the final user message. If either condition is not met, the request fails with an error.

## Format OAI chat completions conversations for ICG usage

Use our preprocessing helper to turn a chat/completions conversation into an ICG-compatible message list. It removes unsupported roles, fields and non-text content, and warns when information is removed.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from collections.abc import Mapping, Sequence


def from_oai_to_icg_format(messages: Sequence[Mapping[str, object]]) -> list[dict[str, str]]:
    """Convert an OpenAI Chat Completions messages list to Iris Content Guard format."""
    icg_messages: list[dict[str, str]] = []
    last_user_index: int | None = None

    for message in messages:
        role = message.get("role")
        if not isinstance(role, str) or role not in ("user", "assistant"):
            continue

        tool_calls = message.get("tool_calls")
        if role == "assistant" and isinstance(tool_calls, list) and tool_calls:
            continue

        content = message.get("content")
        if isinstance(content, list):
            text_parts = [
                part["text"]
                for part in content
                if isinstance(part, Mapping)
                and part.get("type") == "text"
                and isinstance(part.get("text"), str)
            ]
            content = "".join(text_parts) if text_parts else None
        if isinstance(content, str):
            if role == "user":
                last_user_index = len(icg_messages)
            icg_messages.append({"role": role, "content": content})

    if last_user_index is None:
        raise ValueError("No user message remains after preparing the conversation.")
    if len(icg_messages) > last_user_index + 2:
        raise ValueError("At most one assistant reply may follow the final user message.")
    return icg_messages
```

## Reading the results

ICG returns separate results for the request and response, with one harm probability per category:

* request.category\_harm\_probabilities

* response.category\_harm\_probabilities

If the final user request has no assistant reply after thinking messages are removed, response is null (None in Python).

All three integrations use the same fourteen category names and order for both the request and response. Each category has its own probability between 0 and 1. Several categories can score highly at once, and the values do not need to add up to 1. You choose the thresholds and actions that fit your application.

## Conversation length and errors

The checkpoint’s default context limit is 32,768 tokens (32k), counting the full formatted conversation rather than just the exchange being scored. The effective limit depends on the model and serving-engine configuration. Requests that exceed that limit fail with an error; ICG never truncates the conversation to make it fit.

If the input cannot be scored or inference fails, you receive an exception or an HTTP error in the format used by your integration. A failed classification never produces placeholder scores.
