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

# autogen.agentchat.realtime.experimental.clients.RealtimeClientProtocol

<h2 id="autogen.agentchat.realtime.experimental.clients.RealtimeClientProtocol" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">RealtimeClientProtocol</span>
</h2>

```python theme={null}
RealtimeClientProtocol(*args, **kwargs)
```

Base class for protocol classes.<br />Protocol classes are defined as:: <br />    class Proto(Protocol): <br />        def meth(self) -> int: <br />            ...<br />Such classes are primarily used with static type checkers that recognize
structural subtyping (static duck-typing).<br />For example:: <br />    class C: <br />        def meth(self) -> int: <br />            return 0

def func(x: Proto) -> int: <br />        return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with
@typing.runtime\_checkable act as simple-minded runtime protocols that check
only the presence of given attributes, ignoring their type signatures.<br />Protocol classes can be generic, they are defined as:: <br />    class GenProto[T](Protocol): <br />        def meth(self) -> T: <br />            ...

<b>Parameters:</b>

| Name       | Description |
| ---------- | ----------- |
| `*args`    |             |
| `**kwargs` |             |

### Static Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### get\_factory

```python theme={null}
get_factory(
    llm_config: LLMConfig | dict[str, Any],
    logger: Logger,
    **kwargs: Any
) -> Callable[[], RealtimeClientProtocol] | None
```

Create a Realtime API client.<br />

<b>Parameters:</b>

| Name         | Description                                                                                                                             |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
| `llm_config` | The config for the client.<br /><br />**Type:** [LLMConfig](/docs/api-reference/autogen/llm_config/LLMConfig) \| dict\[str, typing.Any] |
| `logger`     | The logger to use for logging events.<br /><br />**Type:** logging.Logger                                                               |
| `**kwargs`   | Additional arguments.<br /><br />**Type:** Any                                                                                          |

<b>Returns:</b>

| Type                                                                                                                                         | Description                                                                                  |
| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| Callable\[\[], [RealtimeClientProtocol](/docs/api-reference/autogen/agentchat/realtime/experimental/clients/RealtimeClientProtocol)] \| None | RealtimeClientProtocol: The Realtime API client is returned if the model matches the pattern |

<br />

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### connect

```python theme={null}
connect(self) -> AsyncContextManager[None]
```

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### read\_events

```python theme={null}
read_events(self) -> AsyncGenerator[RealtimeEvent, None]
```

Read events from a Realtime Client.

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### send\_audio

```python theme={null}
send_audio(self, audio: str) -> None
```

Send audio to a Realtime API.<br />

<b>Parameters:</b>

| Name    | Description                                 |
| ------- | ------------------------------------------- |
| `audio` | The audio to send.<br /><br />**Type:** str |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### send\_function\_result

```python theme={null}
send_function_result(
    self,
    call_id: str,
    result: str
) -> None
```

Send the result of a function call to a Realtime API.<br />

<b>Parameters:</b>

| Name      | Description                                               |
| --------- | --------------------------------------------------------- |
| `call_id` | The ID of the function call.<br /><br />**Type:** str     |
| `result`  | The result of the function call.<br /><br />**Type:** str |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### send\_text

```python theme={null}
send_text(
    self,
    *,
    role: Literal['user', 'assistant', 'system'],
    text: str
) -> None
```

Send a text message to a Realtime API.<br />

<b>Parameters:</b>

| Name   | Description                                                                           |
| ------ | ------------------------------------------------------------------------------------- |
| `role` | The role of the message.<br /><br />**Type:** Literal\['user', 'assistant', 'system'] |
| `text` | The text of the message.<br /><br />**Type:** str                                     |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### session\_update

```python theme={null}
session_update(self, session_options: dict[str, Any]) -> None
```

Send a session update to a Realtime API.<br />

<b>Parameters:</b>

| Name              | Description                                                                |
| ----------------- | -------------------------------------------------------------------------- |
| `session_options` | The session options to update.<br /><br />**Type:** dict\[str, typing.Any] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### truncate\_audio

```python theme={null}
truncate_audio(
    self,
    audio_end_ms: int,
    content_index: int,
    item_id: str
) -> None
```

Truncate audio in a Realtime API.<br />

<b>Parameters:</b>

| Name            | Description                                                    |
| --------------- | -------------------------------------------------------------- |
| `audio_end_ms`  | The end of the audio to truncate.<br /><br />**Type:** int     |
| `content_index` | The index of the content to truncate.<br /><br />**Type:** int |
| `item_id`       | The ID of the item to truncate.<br /><br />**Type:** str       |

<br />
