Skip to main content

POST /products/

curl -X POST http://localhost:8000/products/ \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Laptop HP Pavilion 15",
    "description": "15.6 inch laptop with Intel Core i5, 8GB RAM, 256GB SSD",
    "category": "Electronics"
  }'
Create a new product in the database. The system automatically generates a 3072-dimensional semantic embedding vector using Google’s Gemini AI model for the product’s name and description.

Request body

name
string
required
The product name
description
string
required
Detailed description of the product. This is used along with the name to generate the semantic embedding for search.
category
string
required
The product category (e.g., “Electronics”, “Clothing”, “Food”)

Response

id
integer
Unique identifier for the created product
name
string
The product name
description
string
The product description
category
string
The product category
{
  "id": 1,
  "name": "Laptop HP Pavilion 15",
  "description": "15.6 inch laptop with Intel Core i5, 8GB RAM, 256GB SSD",
  "category": "Electronics"
}
The embedding vector is generated automatically in the background and stored in the PostgreSQL database with pgvector extension. You don’t need to provide it in the request.

How embeddings work

When you create a product:
  1. The system combines the product’s name and description
  2. Sends the text to Google’s Gemini embedding model
  3. Receives a 3072-dimensional vector representation
  4. Stores the vector in the database for semantic search
This enables intelligent semantic search capabilities where users can search using natural language queries.

Build docs developers (and LLMs) love