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

# Create embeddings

> Creates an embedding vector representing the input text. This endpoint is compatible with the [OpenAI Embeddings API](https://platform.openai.com/docs/api-reference/embeddings) and may be used with the OpenAI JS or Python SDK by setting the base URL to `https://api.telnyx.com/v2/ai/openai`.



## OpenAPI

````yaml /openapi/source/external/inference/inference-embedding.json post /ai/openai/embeddings
openapi: 3.1.0
info:
  version: 2.0.0
  title: Telnyx API
  x-latency-category: responsive
  x-endpoint-cost: light
  description: SIP trunking, SMS, MMS, Call Control and Telephony Data Services.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
    description: Version 2.0.0 of the Telnyx API
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: Generate text with LLMs
  - name: Assistants
    description: Configure AI assistant specifications
  - name: Conversations
    description: Manage historical AI assistant conversations
  - name: File-based Text-to-Speech
    description: Turn audio into text or text into audio.
  - name: Embeddings
    description: Embed documents and perform text searches
  - name: Clusters
    description: Identify common themes and patterns in your embedded documents
  - name: Fine Tuning
    description: Customize LLMs for your unique needs
  - name: OpenAI Embeddings
    description: >-
      OpenAI-compatible embeddings endpoints for generating vector
      representations of text
paths:
  /ai/openai/embeddings:
    post:
      tags:
        - OpenAI Embeddings
      summary: Create embeddings
      description: >-
        Creates an embedding vector representing the input text. This endpoint
        is compatible with the [OpenAI Embeddings
        API](https://platform.openai.com/docs/api-reference/embeddings) and may
        be used with the OpenAI JS or Python SDK by setting the base URL to
        `https://api.telnyx.com/v2/ai/openai`.
      operationId: create_openai_embeddings
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenAIEmbeddingRequest'
            example:
              input: The quick brown fox jumps over the lazy dog
              model: thenlper/gte-large
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIEmbeddingResponse'
              example:
                object: list
                data:
                  - object: embedding
                    embedding:
                      - 0
                    index: 0
                model: string
                usage:
                  prompt_tokens: 0
                  total_tokens: 0
        '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.openai.embeddings.createEmbeddings({
              input: 'The quick brown fox jumps over the lazy dog',
              model: 'thenlper/gte-large',
            });


            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.openai.embeddings.create_embeddings(
                input="The quick brown fox jumps over the lazy dog",
                model="thenlper/gte-large",
            )
            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.OpenAI.Embeddings.NewEmbeddings(context.TODO(), telnyx.AIOpenAIEmbeddingNewEmbeddingsParams{\n\t\tInput: telnyx.AIOpenAIEmbeddingNewEmbeddingsParamsInputUnion{\n\t\t\tOfString: telnyx.String(\"The quick brown fox jumps over the lazy dog\"),\n\t\t},\n\t\tModel: \"thenlper/gte-large\",\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.openai.embeddings.EmbeddingCreateEmbeddingsParams;

            import
            com.telnyx.sdk.models.ai.openai.embeddings.EmbeddingCreateEmbeddingsResponse;


            public final class Main {
                private Main() {}

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

                    EmbeddingCreateEmbeddingsParams params = EmbeddingCreateEmbeddingsParams.builder()
                        .input("The quick brown fox jumps over the lazy dog")
                        .model("thenlper/gte-large")
                        .build();
                    EmbeddingCreateEmbeddingsResponse response = client.ai().openai().embeddings().createEmbeddings(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

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

            response = telnyx.ai.openai.embeddings.create_embeddings(
              input: "The quick brown fox jumps over the lazy dog",
              model: "thenlper/gte-large"
            )

            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->openai->embeddings->createEmbeddings(
                input: 'The quick brown fox jumps over the lazy dog',
                model: 'thenlper/gte-large',
                dimensions: 0,
                encodingFormat: 'float',
                user: 'user',
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:openai:embeddings create-embeddings \
              --api-key 'My API Key' \
              --input 'The quick brown fox jumps over the lazy dog' \
              --model thenlper/gte-large
components:
  schemas:
    OpenAIEmbeddingRequest:
      type: object
      properties:
        input:
          oneOf:
            - type: string
              description: A single text string to embed
            - type: array
              items:
                type: string
              description: An array of text strings to embed
          description: Input text to embed. Can be a string or array of strings.
        model:
          type: string
          description: >-
            ID of the model to use. Use the List embedding models endpoint to
            see available models.
          example: thenlper/gte-large
        encoding_format:
          type: string
          enum:
            - float
            - base64
          default: float
          description: The format to return the embeddings in.
        dimensions:
          type: integer
          description: >-
            The number of dimensions the resulting output embeddings should
            have. Only supported in some models.
        user:
          type: string
          description: >-
            A unique identifier representing your end-user for monitoring and
            abuse detection.
      required:
        - input
        - model
      title: OpenAIEmbeddingRequest
    OpenAIEmbeddingResponse:
      type: object
      properties:
        object:
          type: string
          default: list
          description: The object type, always 'list'
        data:
          type: array
          items:
            $ref: '#/components/schemas/OpenAIEmbeddingData'
          description: List of embedding objects
        model:
          type: string
          description: The model used for embedding
        usage:
          $ref: '#/components/schemas/OpenAIEmbeddingUsage'
      required:
        - object
        - data
        - model
        - usage
      title: OpenAIEmbeddingResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
      example:
        detail:
          - loc:
              - body
              - name
            msg: Field required
            type: missing
    OpenAIEmbeddingData:
      type: object
      properties:
        object:
          type: string
          default: embedding
          description: The object type, always 'embedding'
        embedding:
          type: array
          items:
            type: number
          description: The embedding vector
        index:
          type: integer
          description: The index of the embedding in the list of embeddings
      required:
        - object
        - embedding
        - index
      title: OpenAIEmbeddingData
    OpenAIEmbeddingUsage:
      type: object
      properties:
        prompt_tokens:
          type: integer
          description: Number of tokens in the input
        total_tokens:
          type: integer
          description: Total number of tokens used
      required:
        - prompt_tokens
        - total_tokens
      title: OpenAIEmbeddingUsage
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````