Skip to main content
POST
/
invocations
JavaScript
import Kernel from '@onkernel/sdk';

const client = new Kernel({
  apiKey: process.env['KERNEL_API_KEY'], // This is the default and can be omitted
});

const invocation = await client.invocations.create({
  action_name: 'analyze',
  app_name: 'my-app',
  version: '1.0.0',
});

console.log(invocation.id);
import os
from kernel import Kernel

client = Kernel(
api_key=os.environ.get("KERNEL_API_KEY"), # This is the default and can be omitted
)
invocation = client.invocations.create(
action_name="analyze",
app_name="my-app",
version="1.0.0",
)
print(invocation.id)
package main

import (
"context"
"fmt"

"github.com/kernel/kernel-go-sdk"
"github.com/kernel/kernel-go-sdk/option"
)

func main() {
client := kernel.NewClient(
option.WithAPIKey("My API Key"),
)
invocation, err := client.Invocations.New(context.TODO(), kernel.InvocationNewParams{
ActionName: "analyze",
AppName: "my-app",
Version: "1.0.0",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", invocation.ID)
}
curl --request POST \
--url https://api.onkernel.com/invocations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"app_name": "my-app",
"version": "1.0.0",
"action_name": "analyze",
"payload": "{\"data\":\"example input\"}",
"async": true,
"async_timeout_seconds": 600
}
'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.onkernel.com/invocations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'app_name' => 'my-app',
'version' => '1.0.0',
'action_name' => 'analyze',
'payload' => '{"data":"example input"}',
'async' => true,
'async_timeout_seconds' => 600
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.post("https://api.onkernel.com/invocations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"app_name\": \"my-app\",\n \"version\": \"1.0.0\",\n \"action_name\": \"analyze\",\n \"payload\": \"{\\\"data\\\":\\\"example input\\\"}\",\n \"async\": true,\n \"async_timeout_seconds\": 600\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.onkernel.com/invocations")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"app_name\": \"my-app\",\n \"version\": \"1.0.0\",\n \"action_name\": \"analyze\",\n \"payload\": \"{\\\"data\\\":\\\"example input\\\"}\",\n \"async\": true,\n \"async_timeout_seconds\": 600\n}"

response = http.request(request)
puts response.read_body
{
  "id": "rr33xuugxj9h0bkf1rdt2bet",
  "action_name": "analyze",
  "status": "queued",
  "status_reason": "Invocation queued for execution",
  "output": "{\"result\":\"success\",\"data\":\"processed input\"}"
}
{
"id": "rr33xuugxj9h0bkf1rdt2bet",
"action_name": "analyze",
"status": "queued",
"status_reason": "Invocation queued for execution",
"output": "{\"result\":\"success\",\"data\":\"processed input\"}"
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Invocation parameters

app_name
string
required

Name of the application

Example:

"my-app"

version
string
default:latest
required

Version of the application

Example:

"1.0.0"

action_name
string
required

Name of the action to invoke

Example:

"analyze"

payload
string

Input data for the action, sent as a JSON string.

Example:

"{\"data\":\"example input\"}"

async
boolean
default:false

If true, invoke asynchronously. When set, the API responds 202 Accepted with status "queued".

Example:

true

async_timeout_seconds
integer
default:900

Timeout in seconds for async invocations (min 10, max 3600). Only applies when async is true.

Required range: 10 <= x <= 3600
Example:

600

Response

Invocation created successfully

id
string
required

ID of the invocation

Example:

"rr33xuugxj9h0bkf1rdt2bet"

action_name
string
required

Name of the action invoked

Example:

"analyze"

status
enum<string>
required

Status of the invocation

Available options:
queued,
running,
succeeded,
failed
Example:

"queued"

status_reason
string

Status reason

Example:

"Invocation queued for execution"

output
string

The return value of the action that was invoked, rendered as a JSON string. This could be: string, number, boolean, array, object, or null.

Example:

"{\"result\":\"success\",\"data\":\"processed input\"}"