OpenAI -> Get embeddings
Action summary
OpenAI -> Get embeddings
Function Documentation: OpenAI -> Get Embeddings
Overview
This function generates an embedding for a given text input using the OpenAI API. It requires parameters such as the input text & model. The function ensures that the necessary environment variables are set and verifies conditions before making the API request and processing the response.
Inputs
openai_api_key (registry|text) Required Sensitive data
- Description: The API key for your OpenAI account.
input_text (text) Required
- Description: The text input for which an embedding will be generated by the OpenAI API.
model (enum) Required
- Description: Specifies the model to be used for generating the embedding.
- Options:
text-embedding-3-small
(default)text-embedding-3-large
text-embedding-ada-002
Function Stack
1. OpenAI API Request
API Request to
https://api.openai.com
- Purpose: Sends a request to the OpenAI API using the specified model and input text.
Precondition:
openai_api_response.status == 200
- Purpose: Confirms that the API request was successful (HTTP status code 200).
2. OpenAI API Response
- Create Variable:
response
- Purpose: Stores the response from the OpenAI API.
Response
- The function returns the generated embedding.
Success response
{
[
0.020631326,
-0.0042284927,
.
.
.
0.03682661
]
}
Error response
{
"message": "Incorrect API key provided: sk-Nosne*********************************************GQPD. You can find your API key at https://platform.openai.com/account/api-keys."
}
Example
Input
{
"input_text": "Welcome to Xano Actions!",
"model": "text-embedding-3-small",
"show_token_usage": true
}
Response
{
[
0.020631326,
-0.0042284927,
.
.
.
0.03682661
]
}
Version notes
2024-10-04 14:37:26
Current