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

# Compute new clusters

> Starts a background task to compute how the data in an [embedded storage bucket](https://developers.telnyx.com/api-reference/embeddings/embed-documents) is clustered. This helps identify common themes and patterns in the data.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/ai/analytics.yml post /ai/clusters
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:
    post:
      tags:
        - Clusters
      summary: Compute new clusters
      description: >-
        Starts a background task to compute how the data in an [embedded storage
        bucket](https://developers.telnyx.com/api-reference/embeddings/embed-documents)
        is clustered. This helps identify common themes and patterns in the
        data.
      operationId: compute_new_cluster_public_text_clusters_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicTextClusteringRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TextClusteringResponseData'
        '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 response = await client.ai.clusters.compute({ bucket: 'bucket'
            });


            console.log(response.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
            )
            response = client.ai.clusters.compute(
                bucket="bucket",
            )
            print(response.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\tresponse, err := client.AI.Clusters.Compute(context.TODO(), telnyx.AIClusterComputeParams{\n\t\tBucket: \"bucket\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.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.ClusterComputeParams;
            import com.telnyx.sdk.models.ai.clusters.ClusterComputeResponse;

            public final class Main {
                private Main() {}

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

                    ClusterComputeParams params = ClusterComputeParams.builder()
                        .bucket("bucket")
                        .build();
                    ClusterComputeResponse response = client.ai().clusters().compute(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

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

            response = telnyx.ai.clusters.compute(bucket: "bucket")

            puts(response)
        - 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 {
              $response = $client->ai->clusters->compute(
                bucket: 'bucket',
                files: ['string'],
                minClusterSize: 0,
                minSubclusterSize: 0,
                prefix: 'prefix',
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:clusters compute \
              --api-key 'My API Key' \
              --bucket bucket
components:
  schemas:
    PublicTextClusteringRequest:
      properties:
        bucket:
          type: string
          description: >-
            The embedded storage bucket to compute the clusters from. The bucket
            must already be
            [embedded](https://developers.telnyx.com/api-reference/embeddings/embed-documents).
        prefix:
          type: string
          description: Prefix to filter whcih files in the buckets are included.
        files:
          items:
            type: string
          type: array
          description: Array of files to filter which are included.
        min_cluster_size:
          type: integer
          description: >-
            Smallest number of related text chunks to qualify as a cluster.
            Top-level clusters should be thought of as identifying broad themes
            in your data.
          default: 25
        min_subcluster_size:
          type: integer
          description: >-
            Smallest number of related text chunks to qualify as a sub-cluster.
            Sub-clusters should be thought of as identifying more specific
            topics within a broader theme.
          default: 5
      type: object
      required:
        - bucket
      title: PublicTextClusteringRequest
    TextClusteringResponseData:
      properties:
        data:
          $ref: '#/components/schemas/TextClusteringResponse'
      type: object
      required:
        - data
      title: TextClusteringResponseData
    HTTPValidationError:
      title: HTTPValidationError
      type: object
      properties:
        detail:
          title: Detail
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    TextClusteringResponse:
      properties:
        task_id:
          type: string
      type: object
      required:
        - task_id
      title: TextClusteringResponse
    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
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````