Functions · operationId:PostFunction

Create a Function

POST /v1/functions

Description

Creates a new Function. Specify the input modality (Text / Image / Tabular) and output modality (Classification / Detection / Search / Ocr / Localization / Tags / BoxDetect) at creation time — these are immutable.

Query parameters

NameTypeRequiredDescription
waitUntilReady boolean no default false

If true, the request will wait until the function is ready before returning

Request body

Content type: application/json. Body schema: WritableFunction.

Responses

StatusDescriptionBody
200 Success Function

Code samples

curl
curl -X POST \
  -H 'Authorization: Bearer <accessToken>' \
  -H 'Content-Type: application/json' \
  -d '{
  "projectId": "string",
  "name": "my-label",
  "input": "Text",
  "output": "Classification"
}' \
  'https://www.nyckel.com/v1/functions'
Python
import requests

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

body = """{
  "projectId": "string",
  "name": "my-label",
  "input": "Text",
  "output": "Classification"
}"""
response = requests.post(url, headers=headers, data=body)
print(response.json())
JavaScript
fetch('https://www.nyckel.com/v1/functions', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <accessToken>',
    'Content-Type': 'application/json',
  },
  body: `{
  "projectId": "string",
  "name": "my-label",
  "input": "Text",
  "output": "Classification"
}`,
})
  .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');
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'
{
  "projectId": "string",
  "name": "my-label",
  "input": "Text",
  "output": "Classification"
}
NYCKEL_BODY;
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

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