Model Pinning

Given new training data, Nyckel automatically re-trains and re-deploys your function. This ensures that the /invoke endpoint always uses the most recent model. However, there are times when this behavior is undesirable. For example, you may want to do some integration testing or other checks before switching to a new function version.

In this guide we show you how to pin your invoke endpoint to a particular model version.

Locate your functions modelId

Projects that are enabled for model pinning have a "Model Info" panel on function-specific pages. This panel is located at the bottom of the right-hand column, below the label bars. Copy the value labeld "Model Id" for your modelId.

Invoke using a pinned model

To invoke using a pinned model, use the modelId query parameter. Like so:

curl -X POST \
  -H 'Authorization: Bearer <accessToken>' \
  -H 'Content-Type: application/json' \
  -d '{"data":"@<fileName>"}' \
  'https://www.nyckel.com/v1/functions/<functionId>/invoke?modelId=<modelId>'
import requests

url = 'https://www.nyckel.com/v1/functions/<functionId>/invoke?modelId=<modelId>'
headers = {
    'Authorization': 'Bearer ' + '<accessToken>',
}

result = requests.post(url, headers=headers, json={"data":"@<fileName>"})
print(result.text)
fetch('https://www.nyckel.com/v1/functions/<functionId>/invoke?modelId=<modelId>', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer ' + '<accessToken>',
        'Content-Type': 'application/json',
    },
    body: JSON.stringify(
        {"data":"@<fileName>"}
    )
})
.then(response => response.json())
.then(data => console.log(data));
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.nyckel.com/v1/functions/<functionId>/invoke?modelId=<modelId>');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"data":"@<fileName>"}');

$headers = array();
$headers[] = 'Authorization: Bearer ' . '<accessToken>';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
curl_close($ch);
echo $result;