Python
import os
from qaip import Qaip
client = Qaip(
api_key=os.environ.get("QAIP_API_KEY"), # This is the default and can be omitted
)
agent_run = client.agent.create_run(
input={},
)
print(agent_run.context_start_run_id)curl https://developer.qaip.com/api/v1/agent/runs \
-H 'Content-Type: application/json' \
-H "x-api-key: $QAIP_API_KEY" \
-d '{
"input": {}
}'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input: {
inputHistoryMode: 'legacy_full',
threadId: '<string>',
parentRunId: '<string>',
agentId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
state: {},
messages: [{}],
tools: [{}],
context: [{}],
resume: [{}],
redactionPolicyId: 'pii-standard',
forwardedProps: {}
}
})
};
fetch('https://developer.qaip.com/api/v1/agent/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://developer.qaip.com/api/v1/agent/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([
'input' => [
'inputHistoryMode' => 'legacy_full',
'threadId' => '<string>',
'parentRunId' => '<string>',
'agentId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'state' => [
],
'messages' => [
[
]
],
'tools' => [
[
]
],
'context' => [
[
]
],
'resume' => [
[
]
],
'redactionPolicyId' => 'pii-standard',
'forwardedProps' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://developer.qaip.com/api/v1/agent/runs"
payload := strings.NewReader("{\n \"input\": {\n \"inputHistoryMode\": \"legacy_full\",\n \"threadId\": \"<string>\",\n \"parentRunId\": \"<string>\",\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {},\n \"messages\": [\n {}\n ],\n \"tools\": [\n {}\n ],\n \"context\": [\n {}\n ],\n \"resume\": [\n {}\n ],\n \"redactionPolicyId\": \"pii-standard\",\n \"forwardedProps\": {}\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://developer.qaip.com/api/v1/agent/runs")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"input\": {\n \"inputHistoryMode\": \"legacy_full\",\n \"threadId\": \"<string>\",\n \"parentRunId\": \"<string>\",\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {},\n \"messages\": [\n {}\n ],\n \"tools\": [\n {}\n ],\n \"context\": [\n {}\n ],\n \"resume\": [\n {}\n ],\n \"redactionPolicyId\": \"pii-standard\",\n \"forwardedProps\": {}\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://developer.qaip.com/api/v1/agent/runs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input\": {\n \"inputHistoryMode\": \"legacy_full\",\n \"threadId\": \"<string>\",\n \"parentRunId\": \"<string>\",\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {},\n \"messages\": [\n {}\n ],\n \"tools\": [\n {}\n ],\n \"context\": [\n {}\n ],\n \"resume\": [\n {}\n ],\n \"redactionPolicyId\": \"pii-standard\",\n \"forwardedProps\": {}\n }\n}"
response = http.request(request)
puts response.read_body{
"run_id": "<string>",
"thread_id": "<string>",
"workflow_type": "<string>",
"provider": "ANTHROPIC_DIRECT",
"execution_mode": "LOCAL",
"status": "QUEUED",
"input_history_mode": "legacy_full",
"context_start_run_id": "<string>",
"context_truncated": true,
"runtime_arn": "<string>",
"mcp_session_id": "<string>",
"trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
"request_id": "<string>",
"idempotency_key": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"started_at": "2023-11-07T05:31:56Z",
"finished_at": "2023-11-07T05:31:56Z",
"input": {},
"parent_run_id": "<string>",
"result": {},
"error": {}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"code": "unavailable",
"message": "The upstream service is unavailable.",
"request_id": "019d3200-0000-7000-8000-000000000001",
"retryable": false,
"details": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}References
Create agent run
Create an asynchronous agent run and start execution in the background.
Use inputHistoryMode=delta_v1 to send only newUserMessage and let the server reconstruct a bounded rolling context. A continuation supplies the thread’s authoritative current_run_id as baseRunId.
Required scope: inference:run
POST
/
agent
/
runs
Python
import os
from qaip import Qaip
client = Qaip(
api_key=os.environ.get("QAIP_API_KEY"), # This is the default and can be omitted
)
agent_run = client.agent.create_run(
input={},
)
print(agent_run.context_start_run_id)curl https://developer.qaip.com/api/v1/agent/runs \
-H 'Content-Type: application/json' \
-H "x-api-key: $QAIP_API_KEY" \
-d '{
"input": {}
}'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input: {
inputHistoryMode: 'legacy_full',
threadId: '<string>',
parentRunId: '<string>',
agentId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
state: {},
messages: [{}],
tools: [{}],
context: [{}],
resume: [{}],
redactionPolicyId: 'pii-standard',
forwardedProps: {}
}
})
};
fetch('https://developer.qaip.com/api/v1/agent/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://developer.qaip.com/api/v1/agent/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([
'input' => [
'inputHistoryMode' => 'legacy_full',
'threadId' => '<string>',
'parentRunId' => '<string>',
'agentId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'state' => [
],
'messages' => [
[
]
],
'tools' => [
[
]
],
'context' => [
[
]
],
'resume' => [
[
]
],
'redactionPolicyId' => 'pii-standard',
'forwardedProps' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://developer.qaip.com/api/v1/agent/runs"
payload := strings.NewReader("{\n \"input\": {\n \"inputHistoryMode\": \"legacy_full\",\n \"threadId\": \"<string>\",\n \"parentRunId\": \"<string>\",\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {},\n \"messages\": [\n {}\n ],\n \"tools\": [\n {}\n ],\n \"context\": [\n {}\n ],\n \"resume\": [\n {}\n ],\n \"redactionPolicyId\": \"pii-standard\",\n \"forwardedProps\": {}\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://developer.qaip.com/api/v1/agent/runs")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"input\": {\n \"inputHistoryMode\": \"legacy_full\",\n \"threadId\": \"<string>\",\n \"parentRunId\": \"<string>\",\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {},\n \"messages\": [\n {}\n ],\n \"tools\": [\n {}\n ],\n \"context\": [\n {}\n ],\n \"resume\": [\n {}\n ],\n \"redactionPolicyId\": \"pii-standard\",\n \"forwardedProps\": {}\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://developer.qaip.com/api/v1/agent/runs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input\": {\n \"inputHistoryMode\": \"legacy_full\",\n \"threadId\": \"<string>\",\n \"parentRunId\": \"<string>\",\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"state\": {},\n \"messages\": [\n {}\n ],\n \"tools\": [\n {}\n ],\n \"context\": [\n {}\n ],\n \"resume\": [\n {}\n ],\n \"redactionPolicyId\": \"pii-standard\",\n \"forwardedProps\": {}\n }\n}"
response = http.request(request)
puts response.read_body{
"run_id": "<string>",
"thread_id": "<string>",
"workflow_type": "<string>",
"provider": "ANTHROPIC_DIRECT",
"execution_mode": "LOCAL",
"status": "QUEUED",
"input_history_mode": "legacy_full",
"context_start_run_id": "<string>",
"context_truncated": true,
"runtime_arn": "<string>",
"mcp_session_id": "<string>",
"trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
"request_id": "<string>",
"idempotency_key": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"started_at": "2023-11-07T05:31:56Z",
"finished_at": "2023-11-07T05:31:56Z",
"input": {},
"parent_run_id": "<string>",
"result": {},
"error": {}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}{
"error": {
"code": "unavailable",
"message": "The upstream service is unavailable.",
"request_id": "019d3200-0000-7000-8000-000000000001",
"retryable": false,
"details": {}
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": {},
"retryable": true
}
}Headers
Body
application/json
Response
Agent run accepted
Correlation ID of the first request that created this run. For HTTP creation it matches that request's X-Request-ID. Idempotent retries and later reads preserve this value even though their own HTTP response headers carry different request IDs. Runs created before correlation recording was introduced return null. Direct service callers without an HTTP request receive a generated correlation ID.

