Create embeddings
Creates an embedding vector representing the input text. This endpoint is compatible with the OpenAI Embeddings API and may be used with the OpenAI JS or Python SDK by setting the base URL to https://api.telnyx.com/v2/ai/openai.
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);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)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.AI.OpenAI.Embeddings.NewEmbeddings(context.TODO(), telnyx.AIOpenAIEmbeddingNewEmbeddingsParams{
Input: telnyx.AIOpenAIEmbeddingNewEmbeddingsParamsInputUnion{
OfString: telnyx.String("The quick brown fox jumps over the lazy dog"),
},
Model: "thenlper/gte-large",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
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);
}
}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)<?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();
}telnyx ai:openai:embeddings create-embeddings \
--api-key 'My API Key' \
--input 'The quick brown fox jumps over the lazy dog' \
--model thenlper/gte-largecurl --request POST \
--url https://api.telnyx.com/v2/ai/openai/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "The quick brown fox jumps over the lazy dog",
"model": "thenlper/gte-large"
}
'{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
0
],
"index": 0
}
],
"model": "string",
"usage": {
"prompt_tokens": 0,
"total_tokens": 0
}
}{
"detail": [
{
"loc": [
"body",
"name"
],
"msg": "Field required",
"type": "missing"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Input text to embed. Can be a string or array of strings.
ID of the model to use. Use the List embedding models endpoint to see available models.
Example:
"thenlper/gte-large"
The format to return the embeddings in.
Available options:
float, base64 The number of dimensions the resulting output embeddings should have. Only supported in some models.
A unique identifier representing your end-user for monitoring and abuse detection.
Was this page helpful?
⌘I
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);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)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.AI.OpenAI.Embeddings.NewEmbeddings(context.TODO(), telnyx.AIOpenAIEmbeddingNewEmbeddingsParams{
Input: telnyx.AIOpenAIEmbeddingNewEmbeddingsParamsInputUnion{
OfString: telnyx.String("The quick brown fox jumps over the lazy dog"),
},
Model: "thenlper/gte-large",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
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);
}
}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)<?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();
}telnyx ai:openai:embeddings create-embeddings \
--api-key 'My API Key' \
--input 'The quick brown fox jumps over the lazy dog' \
--model thenlper/gte-largecurl --request POST \
--url https://api.telnyx.com/v2/ai/openai/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "The quick brown fox jumps over the lazy dog",
"model": "thenlper/gte-large"
}
'{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
0
],
"index": 0
}
],
"model": "string",
"usage": {
"prompt_tokens": 0,
"total_tokens": 0
}
}{
"detail": [
{
"loc": [
"body",
"name"
],
"msg": "Field required",
"type": "missing"
}
]
}