Create Your Own Function

Goal
Build a prediction endpoint trained on your own labeled examples — from function setup through to a live API call. Bring your own use case; this guide gives you the right choices at each step.
Time
~15 minutes (plus however long it takes to gather your first examples)

1. Create the function

Go to the Nyckel console and sign in. Click New function.

Input type — choose based on what your application will send:

Function type — choose Classification. This guide covers classification: each input is assigned to one of the labels you define.

Name — use a short, descriptive name that reflects what the function classifies. Lowercase and hyphens work well for API use. A good name describes the input and the decision, for example:

Click Create. Your function is live immediately.


2. Define your labels

Open the Labels tab. Labels are the possible predictions your function can return — they map directly to the decisions your application makes.

A few principles for naming labels well:

You need at least 2 labels to create a classifier. Nyckel needs at least 2 confirmed examples per label before it begins training a private model.


3. Add training samples

Open the Samples tab. This is where you give Nyckel examples to learn from.

Two ways to add samples:

Upload a file — if you have existing labeled data, click Import and upload a CSV or JSONL file. Each row should include the input and the correct label. This is the fastest way to bootstrap if you already have labeled examples.

Paste examples one by one — if you’re starting from scratch, add examples directly in the console. Paste or type an input, assign it a label, and repeat.

How many examples to start:

Aim for 5–10 per label to get an initial trained model with meaningful accuracy. The more varied and representative your examples, the better — a model trained on 10 diverse examples usually outperforms one trained on 50 very similar ones.

What makes a good example:

TipIf you're not sure your labels are right, start with a small batch of examples and test early. It's easier to rename or restructure labels before you've built up a large sample set.

4. Test and refine

Once you have examples, Nyckel trains automatically — no button to press. You’ll see a training indicator in the console while it builds your model.

Test with new inputs:

Open the Invoke tab and test with inputs you have not used as training examples. Fresh inputs give you a realistic signal of how the model performs on unseen data.

Review predictions:

In the Test or Review tab, confirm if the predicted label is correct, or change it if it’s wrong. Each annotation feeds back into the training pipeline — Nyckel retrains in the background and benchmarks the new model against the previous one. If it improves, the endpoint switches automatically.

If the model isn’t performing well:


5. Call it from the API

Open your function in the console and click the Integrate tab. It shows your exact endpoint URL, a ready-to-copy access token, and code snippets for your language — no manual configuration needed.

The request structure looks like this (exact URL and token are in the Integrate tab):

POST https://www.nyckel.com/v1/functions/{functionId}/invoke
Authorization: Bearer {your_access_token}
Content-Type: application/json

{
  "data": "your input here"
}

And the response:

{
  "labelName": "your-label",
  "confidence": 0.91,
  "sampleId": "smp_abc123"
}

Read labelName to route the input and confidence to decide whether to act automatically or hold it for human review. Every invoke that reaches the endpoint will appear in the Annotations tab — the more you review, the better your model becomes over time.


What you just did

Step What happened
Created a function Chose input type, function type, and a descriptive name
Defined labels Set up the decision categories your application needs
Added training samples Gave Nyckel labeled examples to learn from
Tested and refined Reviewed predictions and fed corrections back into training
Called the API Connected the function to your application

Next: Read Review and improve predictions to learn how to build a steady annotation workflow, or go to the Developer Platform to see how this fits into a production integration.