TsgcHTTP_API_OpenAI › Methods › CreateEmbeddings
Creates vector embeddings for one or more input strings using an OpenAI embedding model
function CreateEmbeddings(const aRequest : TsgcOpenAIClass_Request_Embeddings) : TsgcOpenAIClass_Response_Embeddings;
| Name | Type | Description |
|---|---|---|
aRequest | const TsgcOpenAIClass_Request_Embeddings | Embeddings request specifying the model, input text(s) and optional encoding format |
Embeddings response containing the generated vectors and token usage (TsgcOpenAIClass_Response_Embeddings)
Calls the POST /v1/embeddings endpoint. Embeddings are dense vector representations of text that can be used for semantic search, clustering, classification and retrieval-augmented generation. Recommended models include text-embedding-3-small and text-embedding-3-large. The response contains one vector per input string, in the same order as provided.
oRequest := TsgcOpenAIClass_Request_Embeddings.Create;
oRequest.Model := 'text-embedding-3-small';
oRequest.Input.Add('The quick brown fox jumps over the lazy dog');
oResponse := oAPI.CreateEmbeddings(oRequest);
ShowMessage(IntToStr(Length(oResponse.Data[0].Embedding)));