Skip to main content

Deploying to Production

Now that we have the Shaped SDK installed, we're ready to integrate Shaped into your application. Below you'll find code snippets demonstrating how to call the Rank endpoint . For examples on how to use our other endpoints, refer to our Model Inference Guides.

Ranking via SDK

Install
npm install @shaped.ai/client
const shapedai = require('@shaped.ai/client');

async function retrieveRankResults() {
const client = shapedai.Client('your_api_key');
const model_name = 'for_you_feed_v1';
const user_id = '1';
const limit = 5;
const results = await client.rank({model_name, user_id, limit});
console.log(results);
}

Sample Response

The API response includes a list of item IDs and their corresponding relevance scores. This allows you to understand the relevance of each item to the user query.

Example response:

{
"ids":[
"427010",
"182094",
"332874",
"827918",
"403528"
],
"scores":[
0.9,
0.8,
0.7,
0.3,
0.2
],
}

The ids array contains the unique identifiers of the recommended items, while the scores array provides relevance confidence scores for each item.

Ranking via POST Request

You can also make a POST request to the Rank Endpoint. For detailed information about the payload, refer to the API docs.

Ranking via Shaped CLI

To retrieve personalized results using the Shaped CLI, use the following command:

shaped rank --model_name movie_recommendations --user_id 3 --limit 5

This command fetches recommendations for the user with user_id=3 and limits the results to 5 items.