> ## 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.OpenAIRealtimeClient

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

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

```python theme={null}
OpenAIRealtimeClient(
    *,
    llm_config: LLMConfig | dict[str, Any],
    logger: Logger | None = None
)
```

(Experimental) Client for OpenAI Realtime API.<br />(Experimental) Client for OpenAI Realtime API.<br />

<b>Parameters:</b>

| Name         | Description                                                                                       |
| ------------ | ------------------------------------------------------------------------------------------------- |
| `llm_config` | **Type:** [LLMConfig](/docs/api-reference/autogen/llm_config/LLMConfig) \| dict\[str, typing.Any] |
| `logger`     | **Type:** logging.Logger \| None<br /><br />**Default:** None                                     |

### 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
) -> 
```

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`   | **Type:** Any                                                                                                                           |

<br />

### Instance Attributes

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

#### connection

<br />

Get the OpenAI WebSocket connection.

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

#### logger

<br />

Get the logger for the OpenAI Realtime API.

### Instance Methods

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

#### add\_event

```python theme={null}
add_event(self, event: RealtimeEvent | None) -> 
```

<b>Parameters:</b>

| Name    | Description                                                                                                                  |
| ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `event` | **Type:** [RealtimeEvent](/docs/api-reference/autogen/agentchat/realtime/experimental/realtime_events/RealtimeEvent) \| None |

<br />

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

#### connect

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

Connect to the OpenAI Realtime API.

<br />

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

#### get\_event

```python theme={null}
get_event(self) -> RealtimeEvent | None
```

<br />

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

#### queue\_input\_audio\_buffer\_delta

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

queue InputAudioBufferDelta.<br />

<b>Parameters:</b>

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

<br />

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

#### read\_events

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

Read messages from the OpenAI Realtime API.

<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 the OpenAI 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 the OpenAI 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 the OpenAI 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 the OpenAI 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 the OpenAI 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 />
