# Query conversation turn information (/en/api-reference/api-ref/conversational-ai/turns)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

Retrieves conversation turn information and performance metrics.

- OpenAPI: /openapi/conversational-ai/rest-api.en.yaml
- Operation ID: get-turns
- Method: GET
- Path: /v2/projects/{appid}/agents/{agentId}/turns

## Servers

- https://api.agora.io/api/conversational-ai-agent

## Parameters

- `appid` (path, required) - The App ID of the project.
- `agentId` (path, required) - The agent instance ID you obtained after successfully calling `join` to [Start a conversational AI agent](/en/api-reference/api-ref/conversational-ai/join).
- `page_index` (query, optional) - The page number. Starts from 1.
- `page_size` (query, optional) - The number of dialogue turns returned per page.

## Request body

No request body.

## Responses

### 200

The request was successful. The response body contains the result of the request.

- `agent_id` (string) - The unique identifier of the agent.
No schema.
- `name` (string) - The name of the agent.
No schema.
- `channel` (string) - The name of the RTC channel the agent joined.
No schema.
- `total_turn_count` (integer) - The total number of dialogue turns in the current session.
No schema.
- `pagination` (object) - Pagination information.
  - `pagination.page_index` (integer) - The current page number; starts from 1.
No schema.
  - `pagination.total_pages` (integer) - The total number of pages.
No schema.
  - `pagination.is_last_page` (boolean) - True if the current page is the last page.
No schema.
- `turns` (array) - A list of conversation turns for the agent session.
  - `turns.items` (object)
    - `turns.items.agent_id` (string) - The unique identifier of the agent.
No schema.
    - `turns.items.channel` (string) - The name of the RTC channel the agent joined.
No schema.
    - `turns.items.turn_id` (number) - The sequential index of the turn within the session. Starts at `1`.
No schema.
    - `turns.items.start` (object) - Details about the start of the turn.
      - `turns.items.start.start_at` (number) - The Unix timestamp in milliseconds (UTC time) when the turn started.
No schema.
      - `turns.items.start.type` (string) - The type of event that initiated the turn.

- `voice_input`: The turn was initiated by user voice input.
- `greeting`: The turn was initiated by an agent greeting.
- `silence_timeout`: The turn was initiated due to a silence timeout.
- `api_speak`: The turn was initiated by a call to the speak API.
No schema.
      - `turns.items.start.metadata` (object) - Additional context about the turn start event. Included fields depend on the value of the `type` field.
        - `turns.items.start.metadata.speech_duration_ms` (integer) - The duration of the user's voice input in milliseconds. Included only when `type` is `voice_input`.
No schema.
        - `turns.items.start.metadata.interrupt_duration_ms` (integer) - The minimum voice duration in milliseconds required to trigger an interruption. Included only when `type` is `voice_input`.
No schema.
        - `turns.items.start.metadata.greeting_nth` (integer) - The index of the current greeting occurrence. Included only when `type` is `greeting`.
No schema.
        - `turns.items.start.metadata.action` (string) - The action taken in response to the silence timeout. Included only when `type` is `silence_timeout`.

- `speak`: Plays the silence prompt message to the user.
- `think`: Appends the silence message to the conversation context and passes it to the LLM.
No schema.
        - `turns.items.start.metadata.transport` (string) - The transport protocol used to deliver the speak request. Included only when `type` is `api_speak`.

- `http`: Delivered over HTTP.
- `rtm`: Delivered through the RTM Presence channel.
No schema.
    - `turns.items.end` (object) - Details about the end of the turn.
      - `turns.items.end.end_at` (number) - The Unix timestamp in milliseconds (UTC time) when the turn ended.
No schema.
      - `turns.items.end.type` (string) - The type of event that ended the turn.

- `ok`: The turn ended normally.
- `interrupted`: The turn was interrupted.
- `ignored`: The turn was ignored.
- `error`: The turn ended due to an error.
No schema.
      - `turns.items.end.metadata` (object) - Additional context about the turn end event. Included fields depend on the value of the `type` field.
        - `turns.items.end.metadata.playback_duration_ms` (integer) - The audio playback duration in milliseconds. Included only when `type` is `ok`.
No schema.
        - `turns.items.end.metadata.caused_by` (string) - The cause of the turn ending.

When `type` is `interrupted`, possible values are:
- `start_of_speech`: A new voice input interrupted the turn.
- `api_speak`: The turn was interrupted by a call to the speak API.
- `api_interrupt`: The turn was interrupted by a call to the interrupt API.
- `api_leave`: The turn was interrupted because the agent left the channel.

When `type` is `ignored`, possible values are:
- `semantic`: The turn was ignored because semantic end-of-speech detection determined no response was required. Applies when [`turn_detection.config.end_of_speech.mode`](/en/api-reference/api-ref/conversational-ai/join#properties-turn-detection-config-end-of-speech-mode) is set to `semantic`.
- `keywords`: The turn was ignored because the start keyword was not detected. Applies when [`turn_detection.config.start_of_speech.mode`](/en/api-reference/api-ref/conversational-ai/join#properties-turn-detection-config-start-of-speech-mode) is set to `keywords`.
- `disable`: The turn was ignored because interruption is disabled for this turn.
No schema.
        - `turns.items.end.metadata.transport` (string) - The transport protocol used to deliver the request. Included only when `caused_by` is `api_speak` or `api_interrupt`.

- `http`: Delivered over HTTP.
- `rtm`: Delivered through the RTM Presence channel.
No schema.
        - `turns.items.end.metadata.reason` (string) - The error type. Included only when `type` is `error`.

- `LLM_REQUEST_ERR`: LLM request error.
- `INTERNAL_ERR`: Internal error.
No schema.
        - `turns.items.end.metadata.details` (string) - Additional error details. Included only when `type` is `error`.
No schema.
    - `turns.items.metrics` (object) - Latency metrics for the turn.
      - `turns.items.metrics.e2e_latency_ms` (integer) - The end-to-end latency in milliseconds for the turn.
No schema.
      - `turns.items.metrics.segmented_latency_ms` (array) - A breakdown of latency by segment.
        - `turns.items.metrics.segmented_latency_ms.items` (object)
          - `turns.items.metrics.segmented_latency_ms.items.name` (string) - The name of the latency segment.

When the LLM input modality is `text`, the returned segments are:

- `algorithm_processing`: Algorithm processing delay.
- `asr_ttlw`: The ASR Time To Last Word (TTLW) in milliseconds. Represents the delay from when the user finishes speaking to when the ASR module outputs the last word.
- `llm_ttft`: The LLM Time To First Token (TTFT) in milliseconds. Represents the delay from when the LLM receives the request to when it outputs the first token.
- `llm_ftfs`: The LLM First Token To First Sentence (FTFS) in milliseconds. Represents the delay from when the LLM outputs the first token to when it outputs the first complete sentence.
- `tts_ttfb`: The TTS Time To First Byte (TTFB) in milliseconds. Represents the delay from when the TTS module receives a text request to when it outputs the first audio byte.
- `transport`: Network transmission delay in milliseconds. Not returned when the user is connected using the RTC Web SDK.

When the LLM input modality is `audio`, the returned segments are:

- `algorithm_processing`: Algorithm processing delay.
- `asr_ttlw`: The ASR Time To Last Word (TTLW) in milliseconds. Represents the delay from when the user finishes speaking to when the ASR module outputs the last word.
- `llm_ttfa`: The LLM Time To First Audio Byte (TTFA) in milliseconds. Represents the delay from when the LLM receives a request until it outputs the first audio byte.
- `transport`: Network transmission delay in milliseconds. Not returned when the user is connected using the RTC Web SDK.
No schema.
          - `turns.items.metrics.segmented_latency_ms.items.latency` (number) - The latency in milliseconds for the segment.
No schema.
### default

The request failed. The response body includes the error details.

- `detail` (string) - Detailed error information.
No schema.
- `reason` (string) - The reason for the failure.
No schema.
