Product Recommendations with OpenAI and Saleor
This example shows how to use the OpenAI Embeddings API to find products that are semantically similar based on their overall characteristics — such as attributes, product type, or category.
You can find the source code in the Saleor Examples repository.
How it works
This example uses the OpenAI Embeddings API to find products that are semantically similar based on their characteristics.
- Generate embeddings - Product data (type, attributes, category, description) is converted into 1536-dimensional vectors using the embeddings model.
- Store vectors - The generated vectors are saved along with product metadata.
- Compare vectors - When viewing a product, its vector is compared with others using cosine similarity to find the closest matches.
- Display results - The top matches above a similarity threshold are shown as "similar products".
The demo focuses on the basic logic for semantic similarity. In production, this approach can be extended using, for example, a vector database.