AIML Embeddings
AIML Embeddings is a component that turns your text into numerical vectors (embeddings) by sending it to the AIML API. These vectors can then be used for searching, clustering, or feeding into other AI models.
How it Works
When you provide a list of documents or a single query, the component packages each piece of text into a request and sends it to the AIML API endpoint (https://api.aimlapi.com/v1/embeddings
). The API responds with a vector of numbers that represents the meaning of the text. The component collects all these vectors and returns them as a list of lists of floats. It handles multiple requests in parallel to speed up the process and logs any errors that occur.
Inputs
-
embeddings_completion_url: The URL of the AIML API that generates embeddings.
Visible in: All -
api_key: Your secret key that authorises access to the AIML API.
Visible in: All -
model: The name of the embedding model you want to use (e.g.,
"text-embedding-ada-002"
).
Visible in: All
Outputs
- embeddings: A list where each element is a list of floating‑point numbers representing the embedding of the corresponding input text. These vectors can be used for similarity searches, clustering, or as inputs to other AI components.
Usage Example
- Add the component to your workflow and fill in the three inputs.
- Connect a text source (e.g., a list of documents from a database component).
- Run the workflow. The component will return a list of embeddings that you can feed into a similarity search or a downstream model. text Documents → AIML Embeddings → Similarity Search
Related Components
- OpenAI Embeddings – Uses OpenAI’s API to generate embeddings.
- Local Embeddings – Generates embeddings locally using a pre‑trained model.
- Similarity Search – Finds the most similar documents based on embeddings.
Tips and Best Practices
- Keep your api_key secure; store it in an environment variable or a secrets manager.
- Use small batches of text to avoid hitting rate limits.
- Handle errors gracefully by catching exceptions and retrying if necessary.
- Verify the model name matches the one available in your AIML account.
- If you need embeddings for a single query, the component automatically wraps it in a list for you.
Security Considerations
- The api_key is transmitted over HTTPS, but never expose it in logs or UI.
- Store the key in a protected location and restrict access to the component.
- Monitor API usage to detect any unauthorized activity.