Class: Telnyx::Resources::AI::OpenAI::Embeddings

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/ai/openai/embeddings.rb,
sig/telnyx/resources/ai/openai/embeddings.rbs

Overview

OpenAI-compatible embeddings endpoints for generating vector representations of text

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Embeddings

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Embeddings.

Parameters:



69
70
71
# File 'lib/telnyx/resources/ai/openai/embeddings.rb', line 69

def initialize(client:)
  @client = client
end

Instance Method Details

#create_embeddings(input:, model:, dimensions: nil, encoding_format: nil, user: nil, request_options: {}) ⇒ Telnyx::Models::AI::OpenAI::EmbeddingCreateEmbeddingsResponse

Some parameter documentations has been truncated, see Models::AI::OpenAI::EmbeddingCreateEmbeddingsParams for more details.

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.

Parameters:

  • input (String, Array<String>)

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

  • model (String)

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

  • dimensions (Integer)

    The number of dimensions the resulting output embeddings should have. Only suppo

  • encoding_format (Symbol, Telnyx::Models::AI::OpenAI::EmbeddingCreateEmbeddingsParams::EncodingFormat)

    The format to return the embeddings in.

  • user (String)

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

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



36
37
38
39
40
41
42
43
44
45
# File 'lib/telnyx/resources/ai/openai/embeddings.rb', line 36

def create_embeddings(params)
  parsed, options = Telnyx::AI::OpenAI::EmbeddingCreateEmbeddingsParams.dump_request(params)
  @client.request(
    method: :post,
    path: "ai/openai/embeddings",
    body: parsed,
    model: Telnyx::Models::AI::OpenAI::EmbeddingCreateEmbeddingsResponse,
    options: options
  )
end

#list_embedding_models(request_options: {}) ⇒ Telnyx::Models::AI::OpenAI::EmbeddingListEmbeddingModelsResponse

Returns a list of available embedding models. This endpoint is compatible with the OpenAI Models API format.



57
58
59
60
61
62
63
64
# File 'lib/telnyx/resources/ai/openai/embeddings.rb', line 57

def list_embedding_models(params = {})
  @client.request(
    method: :get,
    path: "ai/openai/embeddings/models",
    model: Telnyx::Models::AI::OpenAI::EmbeddingListEmbeddingModelsResponse,
    options: params[:request_options]
  )
end