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

# Embed documents

> Perform embedding on a Telnyx Storage Bucket using the a embedding model.
The current supported file types are:
- PDF
- HTML
- txt/unstructured text files
- json
- csv
- audio / video (mp3, mp4, mpeg, mpga, m4a, wav, or webm ) - Max of 100mb file size.

Any files not matching the above types will be attempted to be embedded as unstructured text.

This process can be slow, so it runs in the background and the user can check
the status of the task using the endpoint `/ai/embeddings/{task_id}`.

 **Important Note**: When you update documents in a Telnyx Storage bucket, their associated embeddings are automatically kept up to date. If you add or update a file, it is automatically embedded. If you delete a file, the embeddings are deleted for that particular file.

You can also specify a custom `loader` param. Currently the only supported loader value is
`intercom` which loads Intercom article jsons as specified by [the Intercom article API](https://developers.intercom.com/docs/references/rest-api/api.intercom.io/Articles/article/)
This loader will split each article into paragraphs and save additional parameters relevant to Intercom docs, such as
`article_url` and `heading`. These values will be returned by the `/v2/ai/embeddings/similarity-search` endpoint in the `loader_metadata` field.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/ai/analytics.yml post /ai/embeddings
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/embeddings:
    post:
      tags:
        - Embeddings
      summary: Embed documents
      description: >-
        Perform embedding on a Telnyx Storage Bucket using the a embedding
        model.

        The current supported file types are:

        - PDF

        - HTML

        - txt/unstructured text files

        - json

        - csv

        - audio / video (mp3, mp4, mpeg, mpga, m4a, wav, or webm ) - Max of
        100mb file size.


        Any files not matching the above types will be attempted to be embedded
        as unstructured text.


        This process can be slow, so it runs in the background and the user can
        check

        the status of the task using the endpoint `/ai/embeddings/{task_id}`.

         **Important Note**: When you update documents in a Telnyx Storage bucket, their associated embeddings are automatically kept up to date. If you add or update a file, it is automatically embedded. If you delete a file, the embeddings are deleted for that particular file.

        You can also specify a custom `loader` param. Currently the only
        supported loader value is

        `intercom` which loads Intercom article jsons as specified by [the
        Intercom article
        API](https://developers.intercom.com/docs/references/rest-api/api.intercom.io/Articles/article/)

        This loader will split each article into paragraphs and save additional
        parameters relevant to Intercom docs, such as

        `article_url` and `heading`. These values will be returned by the
        `/v2/ai/embeddings/similarity-search` endpoint in the `loader_metadata`
        field.
      operationId: PostEmbedding
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingBucketRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingResponse'
        '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 embeddingResponse = await client.ai.embeddings.create({
            bucket_name: 'bucket_name' });


            console.log(embeddingResponse.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
            )
            embedding_response = client.ai.embeddings.create(
                bucket_name="bucket_name",
            )
            print(embedding_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\tembeddingResponse, err := client.AI.Embeddings.New(context.TODO(), telnyx.AIEmbeddingNewParams{\n\t\tBucketName: \"bucket_name\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", embeddingResponse.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.embeddings.EmbeddingCreateParams;
            import com.telnyx.sdk.models.ai.embeddings.EmbeddingResponse;

            public final class Main {
                private Main() {}

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

                    EmbeddingCreateParams params = EmbeddingCreateParams.builder()
                        .bucketName("bucket_name")
                        .build();
                    EmbeddingResponse embeddingResponse = client.ai().embeddings().create(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


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


            embedding_response = telnyx.ai.embeddings.create(bucket_name:
            "bucket_name")


            puts(embedding_response)
        - lang: CLI
          source: |-
            telnyx ai:embeddings create \
              --api-key 'My API Key' \
              --bucket-name bucket_name
components:
  schemas:
    EmbeddingBucketRequest:
      properties:
        bucket_name:
          type: string
          title: Bucket Name
        document_chunk_size:
          type: integer
          title: Document Chunk Size
          default: 1024
        document_chunk_overlap_size:
          type: integer
          title: Document Chunk Overlap Size
          default: 512
        embedding_model:
          allOf:
            - $ref: '#/components/schemas/SupportedEmbeddingModels'
          default: thenlper/gte-large
        loader:
          allOf:
            - $ref: '#/components/schemas/SupportedEmbeddingLoaders'
          default: default
      type: object
      required:
        - bucket_name
      title: EmbeddingBucketRequest
    EmbeddingResponse:
      properties:
        data:
          type: object
          properties:
            task_id:
              type: string
              format: uuid
              title: Task ID
            task_name:
              type: string
              title: Task Name
            status:
              type: string
              title: Status
            created_at:
              type: string
              title: Created At
            finished_at:
              type:
                - string
                - 'null'
              title: Finished At
            user_id:
              type: string
              format: uuid
              title: User ID
      type: object
      required:
        - data
      title: EmbeddingResponse
    HTTPValidationError:
      title: HTTPValidationError
      type: object
      properties:
        detail:
          title: Detail
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    SupportedEmbeddingModels:
      type: string
      enum:
        - thenlper/gte-large
        - intfloat/multilingual-e5-large
      title: SupportedEmbeddingModels
      description: Supported models to vectorize and embed documents.
    SupportedEmbeddingLoaders:
      type: string
      enum:
        - default
        - intercom
      title: SupportedEmbeddingLoaders
      description: Supported types of custom document loaders for embeddings.
    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

````