Invoke · operationId:InvokeFunction

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 (int32) 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. Body schema: InvokeInput.

Responses

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

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;