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

# Fetch a cluster



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/ai/analytics.yml get /ai/clusters/{task_id}
openapi: 3.1.0
info:
  title: Telnyx AI Analytics API
  version: 2.0.0
  description: API for AI conversations, insights, embeddings, and clusters.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /ai/clusters/{task_id}:
    get:
      tags:
        - Clusters
      summary: Fetch a cluster
      operationId: fetch_cluster_by_task_id_public_text_clusters__task_id__get
      parameters:
        - required: true
          schema:
            type: string
            title: Task Id
          name: task_id
          in: path
        - name: top_n_nodes
          in: query
          description: >-
            The number of nodes in the cluster to return in the response. Nodes
            will be sorted by their centrality within the cluster.
          required: false
          schema:
            type: integer
            default: 0
            title: Top N Nodes
        - name: show_subclusters
          in: query
          description: >-
            Whether or not to include subclusters and their nodes in the
            response.
          required: false
          schema:
            type: boolean
            default: false
            title: Show Subclusters
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClusteringStatusResponseData'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const cluster = await client.ai.clusters.retrieve('task_id');

            console.log(cluster.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            cluster = client.ai.clusters.retrieve(
                task_id="task_id",
            )
            print(cluster.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tcluster, err := client.AI.Clusters.Get(\n\t\tcontext.TODO(),\n\t\t\"task_id\",\n\t\ttelnyx.AIClusterGetParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", cluster.Data)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
            import com.telnyx.sdk.models.ai.clusters.ClusterRetrieveParams;
            import com.telnyx.sdk.models.ai.clusters.ClusterRetrieveResponse;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    ClusterRetrieveResponse cluster = client.ai().clusters().retrieve("task_id");
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            cluster = telnyx.ai.clusters.retrieve("task_id")

            puts(cluster)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $cluster = $client->ai->clusters->retrieve(
                'task_id', showSubclusters: true, topNNodes: 0
              );

              var_dump($cluster);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:clusters retrieve \
              --api-key 'My API Key' \
              --task-id task_id
components:
  schemas:
    ClusteringStatusResponseData:
      properties:
        data:
          $ref: '#/components/schemas/ClusteringStatusResponse'
      type: object
      required:
        - data
      title: ClusteringStatusResponseData
    HTTPValidationError:
      title: HTTPValidationError
      type: object
      properties:
        detail:
          title: Detail
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    ClusteringStatusResponse:
      properties:
        status:
          $ref: '#/components/schemas/TaskStatus'
        bucket:
          type: string
        clusters:
          items:
            $ref: '#/components/schemas/RecursiveCluster'
          type: array
      type: object
      required:
        - status
        - bucket
        - clusters
      title: ClusteringStatusResponse
    ValidationError:
      title: ValidationError
      required:
        - loc
        - msg
        - type
      type: object
      properties:
        loc:
          title: Location
          type: array
          items:
            anyOf:
              - type: string
              - type: integer
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
    TaskStatus:
      type: string
      enum:
        - pending
        - starting
        - running
        - completed
        - failed
      title: TaskStatus
    RecursiveCluster:
      properties:
        cluster_id:
          type: string
        cluster_header:
          type: string
        cluster_summary:
          type: string
        nodes:
          items:
            $ref: '#/components/schemas/ClusterNode'
          type: array
        total_number_of_nodes:
          type: integer
        subclusters:
          items:
            $ref: '#/components/schemas/RecursiveCluster'
          type: array
      type: object
      required:
        - cluster_id
        - cluster_summary
        - total_number_of_nodes
      title: RecursiveCluster
    ClusterNode:
      properties:
        filename:
          type: string
          description: >-
            The corresponding source file of your embedded storage bucket that
            the node is from.
        text:
          type: string
          description: The text of the node.
      type: object
      required:
        - filename
        - text
      title: ClusterNode
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````