curl --request POST \
--url https://api.example.com/sop/{sop_id}/runs \
--header 'Content-Type: application/json' \
--header 'x-user-id: <x-user-id>' \
--data '
{
"inputs": [
{
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"created_at": "<string>",
"finished_at": "<string>"
}
],
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_input_tokens": 0,
"cache_creation_input_tokens": 0
},
"finished_at": "<string>",
"structured_output": {},
"error": {
"message": "<string>",
"type": "unknown"
}
}
]
}
'import requests
url = "https://api.example.com/sop/{sop_id}/runs"
payload = { "inputs": [
{
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"created_at": "<string>",
"finished_at": "<string>"
}
],
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_input_tokens": 0,
"cache_creation_input_tokens": 0
},
"finished_at": "<string>",
"structured_output": {},
"error": {
"message": "<string>",
"type": "unknown"
}
}
] }
headers = {
"x-user-id": "<x-user-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-user-id': '<x-user-id>', 'Content-Type': 'application/json'},
body: JSON.stringify({
inputs: [
{
name: '<string>',
content: [
{
text: '<string>',
type: 'text',
id: '<string>',
created_at: '<string>',
finished_at: '<string>'
}
],
id: '<string>',
metadata: {},
created_at: '<string>',
usage: {
input_tokens: 123,
output_tokens: 123,
cache_input_tokens: 0,
cache_creation_input_tokens: 0
},
finished_at: '<string>',
structured_output: {},
error: {message: '<string>', type: 'unknown'}
}
]
})
};
fetch('https://api.example.com/sop/{sop_id}/runs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/sop/{sop_id}/runs",
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([
'inputs' => [
[
'name' => '<string>',
'content' => [
[
'text' => '<string>',
'type' => 'text',
'id' => '<string>',
'created_at' => '<string>',
'finished_at' => '<string>'
]
],
'id' => '<string>',
'metadata' => [
],
'created_at' => '<string>',
'usage' => [
'input_tokens' => 123,
'output_tokens' => 123,
'cache_input_tokens' => 0,
'cache_creation_input_tokens' => 0
],
'finished_at' => '<string>',
'structured_output' => [
],
'error' => [
'message' => '<string>',
'type' => 'unknown'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-user-id: <x-user-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/sop/{sop_id}/runs"
payload := strings.NewReader("{\n \"inputs\": [\n {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\",\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123,\n \"cache_input_tokens\": 0,\n \"cache_creation_input_tokens\": 0\n },\n \"finished_at\": \"<string>\",\n \"structured_output\": {},\n \"error\": {\n \"message\": \"<string>\",\n \"type\": \"unknown\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-user-id", "<x-user-id>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/sop/{sop_id}/runs")
.header("x-user-id", "<x-user-id>")
.header("Content-Type", "application/json")
.body("{\n \"inputs\": [\n {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\",\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123,\n \"cache_input_tokens\": 0,\n \"cache_creation_input_tokens\": 0\n },\n \"finished_at\": \"<string>\",\n \"structured_output\": {},\n \"error\": {\n \"message\": \"<string>\",\n \"type\": \"unknown\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/sop/{sop_id}/runs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-user-id"] = '<x-user-id>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"inputs\": [\n {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\",\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123,\n \"cache_input_tokens\": 0,\n \"cache_creation_input_tokens\": 0\n },\n \"finished_at\": \"<string>\",\n \"structured_output\": {},\n \"error\": {\n \"message\": \"<string>\",\n \"type\": \"unknown\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"user_id": "<string>",
"sop_id": "<string>",
"definition": {
"name": "<string>",
"steps": [
{
"subject": "<string>",
"description": "<string>",
"executor": {
"agent_id": "<string>",
"session_key": "<string>"
},
"version": "v1",
"verifier": {
"agent": {
"agent_id": "<string>",
"session_key": "<string>"
},
"type": "agent",
"criteria": ""
},
"max_attempts": 3
}
],
"description": "",
"workspace_grain": "run",
"session_settings": {}
},
"id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"sessions": {},
"state": {
"phase": "pending",
"id": "<string>",
"inputs": [
{
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"created_at": "<string>",
"finished_at": "<string>"
}
],
"role": "user",
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_input_tokens": 0,
"cache_creation_input_tokens": 0
},
"finished_at": "<string>",
"finished_reason": "completed",
"structured_output": {},
"error": {
"message": "<string>",
"type": "unknown"
}
}
],
"steps": [
{
"phase": "pending",
"given": [
{
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"created_at": "<string>",
"finished_at": "<string>"
}
],
"role": "user",
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_input_tokens": 0,
"cache_creation_input_tokens": 0
},
"finished_at": "<string>",
"finished_reason": "completed",
"structured_output": {},
"error": {
"message": "<string>",
"type": "unknown"
}
}
],
"submission": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"created_at": "<string>",
"finished_at": "<string>"
}
],
"verifications": [
{
"passed": true,
"message": "",
"verifier": "",
"created_at": "<string>"
}
]
}
],
"created_at": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Start a run
Open a run of a procedure and set it going in the background.
Args:
sop_id (str):
The procedure to run.
body (StartSOPRunRequest):
What the run is started with.
user_id (str):
Injected authenticated user id.
service (SOPService):
Injected SOP service.
Returns:
SOPRunRecord:
The opened run, before it has got anywhere.
curl --request POST \
--url https://api.example.com/sop/{sop_id}/runs \
--header 'Content-Type: application/json' \
--header 'x-user-id: <x-user-id>' \
--data '
{
"inputs": [
{
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"created_at": "<string>",
"finished_at": "<string>"
}
],
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_input_tokens": 0,
"cache_creation_input_tokens": 0
},
"finished_at": "<string>",
"structured_output": {},
"error": {
"message": "<string>",
"type": "unknown"
}
}
]
}
'import requests
url = "https://api.example.com/sop/{sop_id}/runs"
payload = { "inputs": [
{
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"created_at": "<string>",
"finished_at": "<string>"
}
],
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_input_tokens": 0,
"cache_creation_input_tokens": 0
},
"finished_at": "<string>",
"structured_output": {},
"error": {
"message": "<string>",
"type": "unknown"
}
}
] }
headers = {
"x-user-id": "<x-user-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-user-id': '<x-user-id>', 'Content-Type': 'application/json'},
body: JSON.stringify({
inputs: [
{
name: '<string>',
content: [
{
text: '<string>',
type: 'text',
id: '<string>',
created_at: '<string>',
finished_at: '<string>'
}
],
id: '<string>',
metadata: {},
created_at: '<string>',
usage: {
input_tokens: 123,
output_tokens: 123,
cache_input_tokens: 0,
cache_creation_input_tokens: 0
},
finished_at: '<string>',
structured_output: {},
error: {message: '<string>', type: 'unknown'}
}
]
})
};
fetch('https://api.example.com/sop/{sop_id}/runs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/sop/{sop_id}/runs",
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([
'inputs' => [
[
'name' => '<string>',
'content' => [
[
'text' => '<string>',
'type' => 'text',
'id' => '<string>',
'created_at' => '<string>',
'finished_at' => '<string>'
]
],
'id' => '<string>',
'metadata' => [
],
'created_at' => '<string>',
'usage' => [
'input_tokens' => 123,
'output_tokens' => 123,
'cache_input_tokens' => 0,
'cache_creation_input_tokens' => 0
],
'finished_at' => '<string>',
'structured_output' => [
],
'error' => [
'message' => '<string>',
'type' => 'unknown'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-user-id: <x-user-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/sop/{sop_id}/runs"
payload := strings.NewReader("{\n \"inputs\": [\n {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\",\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123,\n \"cache_input_tokens\": 0,\n \"cache_creation_input_tokens\": 0\n },\n \"finished_at\": \"<string>\",\n \"structured_output\": {},\n \"error\": {\n \"message\": \"<string>\",\n \"type\": \"unknown\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-user-id", "<x-user-id>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/sop/{sop_id}/runs")
.header("x-user-id", "<x-user-id>")
.header("Content-Type", "application/json")
.body("{\n \"inputs\": [\n {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\",\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123,\n \"cache_input_tokens\": 0,\n \"cache_creation_input_tokens\": 0\n },\n \"finished_at\": \"<string>\",\n \"structured_output\": {},\n \"error\": {\n \"message\": \"<string>\",\n \"type\": \"unknown\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/sop/{sop_id}/runs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-user-id"] = '<x-user-id>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"inputs\": [\n {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\",\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123,\n \"cache_input_tokens\": 0,\n \"cache_creation_input_tokens\": 0\n },\n \"finished_at\": \"<string>\",\n \"structured_output\": {},\n \"error\": {\n \"message\": \"<string>\",\n \"type\": \"unknown\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"user_id": "<string>",
"sop_id": "<string>",
"definition": {
"name": "<string>",
"steps": [
{
"subject": "<string>",
"description": "<string>",
"executor": {
"agent_id": "<string>",
"session_key": "<string>"
},
"version": "v1",
"verifier": {
"agent": {
"agent_id": "<string>",
"session_key": "<string>"
},
"type": "agent",
"criteria": ""
},
"max_attempts": 3
}
],
"description": "",
"workspace_grain": "run",
"session_settings": {}
},
"id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"sessions": {},
"state": {
"phase": "pending",
"id": "<string>",
"inputs": [
{
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"created_at": "<string>",
"finished_at": "<string>"
}
],
"role": "user",
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_input_tokens": 0,
"cache_creation_input_tokens": 0
},
"finished_at": "<string>",
"finished_reason": "completed",
"structured_output": {},
"error": {
"message": "<string>",
"type": "unknown"
}
}
],
"steps": [
{
"phase": "pending",
"given": [
{
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"created_at": "<string>",
"finished_at": "<string>"
}
],
"role": "user",
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_input_tokens": 0,
"cache_creation_input_tokens": 0
},
"finished_at": "<string>",
"finished_reason": "completed",
"structured_output": {},
"error": {
"message": "<string>",
"type": "unknown"
}
}
],
"submission": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"created_at": "<string>",
"finished_at": "<string>"
}
],
"verifications": [
{
"passed": true,
"message": "",
"verifier": "",
"created_at": "<string>"
}
]
}
],
"created_at": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Headers
Caller's user ID. Temporary header-based identity; will be replaced by JWT auth.
Path Parameters
Body
Request body for starting a run.
What the run is started with, read by its first step.
Show child attributes
Show child attributes
Response
Successful Response
One run of a procedure.
A procedure: its milestones, in order.
Show child attributes
Show child attributes
Unique identifier for the credential.
Show child attributes
Show child attributes
One execution of a SOP, and the whole of what is worth saving.
It covers the SOP's own state and nothing below it: an executor that
keeps state of its own (an :class:~..agent.Agent does) is persisted
by whoever built it, the same way it is built.
Show child attributes
Show child attributes