Skip to content

Search products from a prompt

POST
/api/products/search
curl --request POST \
--url https://example.com/api/products/search \
--header 'Content-Type: application/json' \
--cookie better-auth.session_token=<better-auth.session_token> \
--data '{ "prompt": "Need a battery-ready photovoltaic setup for a small office.", "limit": 1 }'

Prompt used for semantic product matching against embedded products.

Media type application/json

Prompt used for semantic product matching.

object
prompt
required
string
>= 1 characters
limit
integer
> 0 <= 10

Semantic matches from the products table with an AI summary.

Media type application/json

Semantic product matches plus an agent summary.

object
prompt
required
string
answer
required
string
products
required
Array<object>

A database product matched semantically against the prompt.

object
id
required
string
sku
required
string
name
required
string
description
required
string
similarity
required
number
>= -1 <= 1
Example generated
{
"prompt": "example",
"answer": "example",
"products": [
{
"id": "example",
"sku": "example",
"name": "example",
"description": "example",
"similarity": 1
}
]
}

The request body could not be parsed or validated.

Media type application/json

Standard API error payload.

object
error
required
object
code
required
string
message
required
string
issues
Array<string>
Example generated
{
"error": {
"code": "example",
"message": "example",
"issues": [
"example"
]
}
}

No valid Better Auth session was present.

Media type application/json

Returned when no valid Better Auth session is present.

object
error
required
string
Example generated
{
"error": "example"
}

The server could not complete the semantic product search.

Media type application/json

Standard API error payload.

object
error
required
object
code
required
string
message
required
string
issues
Array<string>
Example generated
{
"error": {
"code": "example",
"message": "example",
"issues": [
"example"
]
}
}