Skip to main content
POST
/
ai
/
openai
/
embeddings
JavaScript
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);
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        123
      ],
      "index": 123
    }
  ],
  "model": "<string>",
  "usage": {
    "prompt_tokens": 123,
    "total_tokens": 123
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
input
required

Input text to embed. Can be a string or array of strings.

model
string
required

ID of the model to use. Use the List embedding models endpoint to see available models.

Example:

"thenlper/gte-large"

encoding_format
enum<string>
default:float

The format to return the embeddings in.

Available options:
float,
base64
dimensions
integer

The number of dimensions the resulting output embeddings should have. Only supported in some models.

user
string

A unique identifier representing your end-user for monitoring and abuse detection.

Response

Successful Response

object
string
default:list
required

The object type, always 'list'

data
OpenAIEmbeddingData · object[]
required

List of embedding objects

model
string
required

The model used for embedding

usage
OpenAIEmbeddingUsage · object
required