Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.tybritelabs.com/llms.txt

Use this file to discover all available pages before exploring further.

The RecommendationsService class (accessed via client.recommendations) allows you to integrate AI-driven product suggestions into your storefront to increase discovery and conversion.
Secret Key Required. This service requires a Secret Key (sk_live_* / sk_test_*). AI inference is computationally expensive and consumes Gemini API quota — gating to sk prevents abuse from scraped publishable keys. Requests authenticated with a publishable key receive 403 Forbidden.

Methods

getRecommendations

Retrieve curated product suggestions based on various AI models. Use the examples below to see how to implement different recommendation strategies.
// Get products similar in meaning or features to a specific item
const { recommendations } = await client.recommendations.getRecommendations({
  requestBody: {
    type: 'similar',
    productId: 'current-product-uuid',
    limit: 4
  }
});
Recommendation Types Details:
TypeDescriptionRequired Parameters
similarProducts with similar features/meaning (Embedding-based).productId
also-boughtProducts frequently purchased together.productId
trendingGlobal trending products (Velocity-based).-
personalizedSuggestions tailored to a specific user history.customerId
bundleSmart bundle suggestions (Semantic + Co-purchase).productId
Parameters:
ParameterTypeDescription
requestBodyobjectRequired. The configuration for the recommendation request.
requestBody.typestringThe recommendation algorithm to use.
requestBody.productIdstringRequired for similar, also-bought, and bundle.
requestBody.customerIdstringRequired for personalized.
requestBody.limitnumberOptional. Maximum number of suggestions to return.

Recommendation results are often cached for high performance. The response includes a fromCache boolean, a computedAt ISO timestamp, and an optional fallbackUsed string indicating if the system had to use a simpler algorithm due to data scarcity.

Cascading Fallback Chain

When a recommendation type cannot produce results (insufficient data, missing embeddings, cold-start product, etc.), Tybrite degrades gracefully to a simpler algorithm rather than returning an empty array:
Requested TypeFallback Order
bundlebundle → also-bought → similar → trending
also-boughtalso-bought → similar → trending
similarsimilar → trending
personalizedpersonalized → trending
trendingtrending (terminal — no further fallback)
When a fallback is used, the response’s fallbackUsed field contains the name of the algorithm that ultimately produced the results.

Response Codes

This endpoint is POST and requires a Secret Key.
CodeMeaning
200Recommendations returned (possibly via fallback — check fallbackUsed).
400Invalid type enum or missing required field (productId for similar/also-bought/bundle; customerId for personalized).
401Invalid or missing API key.
403Publishable key supplied — recommendations require a Secret Key.
404productId was provided but the product was not found (applies to similar, bundle, and also-bought).
429Rate limit exceeded.
500Internal server error or upstream Gemini failure.