Invoke

Invoke a Function

POST /v1/functions/{functionId}/invoke

Description

Sends an input to a trained Function and returns a FunctionOutput containing the predicted Label, confidence, and (optionally) the full list of LabelConfidences. By default the invocation is captured as a Sample — set capture=false to opt out.

Path parameters

NameTypeRequiredDescription
functionId string yes

The ID of the function to invoke

Query parameters

NameTypeRequiredDescription
labelCount integer no

The number of labels to return in the response

includeMetadata boolean no

Whether to include metadata in the response

modelId string no

The ID of the model to use

capture boolean no default true

Whether to capture the invocation for later review

externalId string no

The externalId of the Sample

Request body

Content type: application/json.

FieldTypeRequiredDescription
data IFunctionInput no

externalId string nullable no

metadata object nullable no

Responses

StatusDescriptionBody
200 Invoke succeeded object
400 Bad Request object
503 Server Error object

Response body fields (200):

FieldTypeRequiredDescription
labelName string nullable no

labelId string nullable no

labelMetadata object nullable no

confidence number no

decisionThreshold number nullable no

labelConfidences array<object> nullable no

externalId string nullable no

Response body fields (400):

FieldTypeRequiredDescription
message string nullable no

Response body fields (503):

FieldTypeRequiredDescription
message string nullable no

Code samples

curl
curl -X POST \
  -H 'Authorization: Bearer <accessToken>' \
  -H 'Content-Type: application/json' \
  -d '{
  "data": {
    "size": 0
  },
  "externalId": "external-123",
  "metadata": {
  }
}' \
  'https://www.nyckel.com/v1/functions/<functionId>/invoke'
Python
import requests

url = 'https://www.nyckel.com/v1/functions/<functionId>/invoke'
headers = {
    'Authorization': 'Bearer <accessToken>',
    'Content-Type': 'application/json',
}

body = """{
  "data": {
    "size": 0
  },
  "externalId": "external-123",
  "metadata": {
  }
}"""
response = requests.post(url, headers=headers, data=body)
print(response.json())
JavaScript
fetch('https://www.nyckel.com/v1/functions/<functionId>/invoke', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <accessToken>',
    'Content-Type': 'application/json',
  },
  body: `{
  "data": {
    "size": 0
  },
  "externalId": "external-123",
  "metadata": {
  }
}`,
})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.nyckel.com/v1/functions/<functionId>/invoke');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

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

$body = <<<'NYCKEL_BODY'
{
  "data": {
    "size": 0
  },
  "externalId": "external-123",
  "metadata": {
  }
}
NYCKEL_BODY;
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

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