Sessions
Create a Session
Create a thread for traces.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.sessions.create(external_id="<id>", duration=7329.24, contact_ids=[
"<value 1>",
"<value 2>",
], billing={
"input_cost": 5975.95,
"output_cost": 754.22,
"total_cost": 2965.14,
}, usage={
"prompt_tokens": 424835,
"completion_tokens": 793505,
"total_tokens": 726901,
}, traces_count=451437, tags=[
"<value 1>",
"<value 2>",
"<value 3>",
])
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.sessions.create({
externalId: "<id>",
duration: 7329.24,
contactIds: [
"<value 1>",
"<value 2>",
],
billing: {
inputCost: 5975.95,
outputCost: 754.22,
totalCost: 2965.14,
},
usage: {
promptTokens: 424835,
completionTokens: 793505,
totalTokens: 726901,
},
tracesCount: 451437,
tags: [
"<value 1>",
"<value 2>",
"<value 3>",
],
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"external_id": str, # required
"duration": float, # required
"contact_ids": List[str], # required
"billing": { # required
"input_cost": float, # required
"output_cost": float, # required
"total_cost": float, # required
},
"usage": { # required
"prompt_tokens": int, # required
"completion_tokens": int, # required
"total_tokens": int, # required
},
"traces_count": int, # required
"tags": List[str], # required
"project_id": Optional[str],
"started_at": str, # optional
"updated_at": str, # optional
"title": Optional[str],
"client": Optional[str],
"repo": Optional[str],
"kind": Optional[Literal["THREAD_KIND_UNSPECIFIED", "THREAD_KIND_CONVERSATION", "THREAD_KIND_CODING_AGENT"]],
}
{
externalId: string; // required
duration: number; // required
contactIds: string[]; // required
billing: { // required
inputCost: number; // required
outputCost: number; // required
totalCost: number; // required
};
usage: { // required
promptTokens: number; // required
completionTokens: number; // required
totalTokens: number; // required
};
tracesCount: number; // required
tags: string[]; // required
projectId?: string;
startedAt?: Date;
updatedAt?: Date;
title?: string;
client?: string;
repo?: string;
kind?: "THREAD_KIND_UNSPECIFIED" | "THREAD_KIND_CONVERSATION" | "THREAD_KIND_CODING_AGENT";
}
Show Response
Show Response
{
"id": str,
"external_id": str,
"duration": float,
"contact_ids": List[str],
"billing": {
"input_cost": float,
"output_cost": float,
"total_cost": float,
},
"usage": {
"prompt_tokens": int,
"completion_tokens": int,
"total_tokens": int,
},
"traces_count": int,
"tags": List[str],
"project_id": Optional[str],
"started_at": str, # optional
"updated_at": str, # optional
"title": Optional[str],
"client": Optional[str],
"repo": Optional[str],
"kind": Optional[Literal["THREAD_KIND_UNSPECIFIED", "THREAD_KIND_CONVERSATION", "THREAD_KIND_CODING_AGENT"]],
}
{
id: string;
externalId: string;
duration: number;
contactIds: string[];
billing: {
inputCost: number;
outputCost: number;
totalCost: number;
};
usage: {
promptTokens: number;
completionTokens: number;
totalTokens: number;
};
tracesCount: number;
tags: string[];
projectId?: string;
startedAt?: Date;
updatedAt?: Date;
title?: string;
client?: string;
repo?: string;
kind?: "THREAD_KIND_UNSPECIFIED" | "THREAD_KIND_CONVERSATION" | "THREAD_KIND_CODING_AGENT";
}
Get Count
Get total count of trace threads.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.sessions.get_count(filters={
"interval": "SESSION_INTERVAL_LAST_30_MINUTES",
})
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.sessions.getCount({
filters: {
interval: "SESSION_INTERVAL_LAST_30_MINUTES",
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"filters": { # required
"interval": Literal["SESSION_INTERVAL_UNSPECIFIED", "SESSION_INTERVAL_ALL_TIME", "SESSION_INTERVAL_LAST_30_MINUTES", "SESSION_INTERVAL_LAST_1_HOUR", "SESSION_INTERVAL_LAST_6_HOURS", "SESSION_INTERVAL_LAST_24_HOURS", "SESSION_INTERVAL_LAST_3_DAYS", "SESSION_INTERVAL_LAST_7_DAYS", "SESSION_INTERVAL_LAST_14_DAYS", "SESSION_INTERVAL_LAST_1_MONTH", "SESSION_INTERVAL_LAST_3_MONTHS"], # required
"project_id": Optional[str],
"tags": List[str], # optional
"start_date": Optional[str],
"end_date": Optional[str],
"client": Optional[str],
"repo": Optional[str],
"kind": Optional[Literal["THREAD_KIND_UNSPECIFIED", "THREAD_KIND_CONVERSATION", "THREAD_KIND_CODING_AGENT"]],
},
"limit": Optional[int],
"page": Optional[int],
}
{
filters: { // required
interval: "SESSION_INTERVAL_UNSPECIFIED" | "SESSION_INTERVAL_ALL_TIME" | "SESSION_INTERVAL_LAST_30_MINUTES" | "SESSION_INTERVAL_LAST_1_HOUR" | "SESSION_INTERVAL_LAST_6_HOURS" | "SESSION_INTERVAL_LAST_24_HOURS" | "SESSION_INTERVAL_LAST_3_DAYS" | "SESSION_INTERVAL_LAST_7_DAYS" | "SESSION_INTERVAL_LAST_14_DAYS" | "SESSION_INTERVAL_LAST_1_MONTH" | "SESSION_INTERVAL_LAST_3_MONTHS"; // required
projectId?: string;
tags?: string[];
startDate?: string;
endDate?: string;
client?: string;
repo?: string;
kind?: "THREAD_KIND_UNSPECIFIED" | "THREAD_KIND_CONVERSATION" | "THREAD_KIND_CODING_AGENT";
};
limit?: number;
page?: number;
}
Show Response
Show Response
{
"count": int,
}
{
count: number;
}
List Sessions
List trace threads from your workspace.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.sessions.list(filters={
"interval": "SESSION_INTERVAL_LAST_7_DAYS",
})
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.sessions.list({
filters: {
interval: "SESSION_INTERVAL_LAST_7_DAYS",
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"filters": { # required
"interval": Literal["SESSION_INTERVAL_UNSPECIFIED", "SESSION_INTERVAL_ALL_TIME", "SESSION_INTERVAL_LAST_30_MINUTES", "SESSION_INTERVAL_LAST_1_HOUR", "SESSION_INTERVAL_LAST_6_HOURS", "SESSION_INTERVAL_LAST_24_HOURS", "SESSION_INTERVAL_LAST_3_DAYS", "SESSION_INTERVAL_LAST_7_DAYS", "SESSION_INTERVAL_LAST_14_DAYS", "SESSION_INTERVAL_LAST_1_MONTH", "SESSION_INTERVAL_LAST_3_MONTHS"], # required
"project_id": Optional[str],
"tags": List[str], # optional
"start_date": Optional[str],
"end_date": Optional[str],
"client": Optional[str],
"repo": Optional[str],
"kind": Optional[Literal["THREAD_KIND_UNSPECIFIED", "THREAD_KIND_CONVERSATION", "THREAD_KIND_CODING_AGENT"]],
},
"limit": Optional[int],
"page": Optional[int],
}
{
filters: { // required
interval: "SESSION_INTERVAL_UNSPECIFIED" | "SESSION_INTERVAL_ALL_TIME" | "SESSION_INTERVAL_LAST_30_MINUTES" | "SESSION_INTERVAL_LAST_1_HOUR" | "SESSION_INTERVAL_LAST_6_HOURS" | "SESSION_INTERVAL_LAST_24_HOURS" | "SESSION_INTERVAL_LAST_3_DAYS" | "SESSION_INTERVAL_LAST_7_DAYS" | "SESSION_INTERVAL_LAST_14_DAYS" | "SESSION_INTERVAL_LAST_1_MONTH" | "SESSION_INTERVAL_LAST_3_MONTHS"; // required
projectId?: string;
tags?: string[];
startDate?: string;
endDate?: string;
client?: string;
repo?: string;
kind?: "THREAD_KIND_UNSPECIFIED" | "THREAD_KIND_CONVERSATION" | "THREAD_KIND_CODING_AGENT";
};
limit?: number;
page?: number;
}
Show Response
Show Response
{
"object": str,
"data": [{
"id": str,
"external_id": str,
"duration": float,
"contact_ids": List[str],
"billing": {
"input_cost": float,
"output_cost": float,
"total_cost": float,
},
"usage": {
"prompt_tokens": int,
"completion_tokens": int,
"total_tokens": int,
},
"traces_count": int,
"tags": List[str],
"project_id": Optional[str],
"started_at": str, # optional
"updated_at": str, # optional
"title": Optional[str],
"client": Optional[str],
"repo": Optional[str],
"kind": Optional[Literal["THREAD_KIND_UNSPECIFIED", "THREAD_KIND_CONVERSATION", "THREAD_KIND_CODING_AGENT"]],
}],
"has_more": bool,
}
{
object: string;
data: {
id: string;
externalId: string;
duration: number;
contactIds: string[];
billing: {
inputCost: number;
outputCost: number;
totalCost: number;
};
usage: {
promptTokens: number;
completionTokens: number;
totalTokens: number;
};
tracesCount: number;
tags: string[];
projectId?: string;
startedAt?: Date;
updatedAt?: Date;
title?: string;
client?: string;
repo?: string;
kind?: "THREAD_KIND_UNSPECIFIED" | "THREAD_KIND_CONVERSATION" | "THREAD_KIND_CODING_AGENT";
}[];
hasMore: boolean;
}
List Tags
Retrieves all unique thread tags in the workspace.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.sessions.list_tags()
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.sessions.listTags();
console.log(result);
}
run();
Retrieve a Session
Get a trace thread.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.sessions.get(session_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.sessions.get({
sessionId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"session_id": str, # required
}
{
sessionId: string; // required
}
Show Response
Show Response
{
"id": str,
"external_id": str,
"duration": float,
"contact_ids": List[str],
"billing": {
"input_cost": float,
"output_cost": float,
"total_cost": float,
},
"usage": {
"prompt_tokens": int,
"completion_tokens": int,
"total_tokens": int,
},
"traces_count": int,
"tags": List[str],
"project_id": Optional[str],
"started_at": str, # optional
"updated_at": str, # optional
"title": Optional[str],
"client": Optional[str],
"repo": Optional[str],
"kind": Optional[Literal["THREAD_KIND_UNSPECIFIED", "THREAD_KIND_CONVERSATION", "THREAD_KIND_CODING_AGENT"]],
}
{
id: string;
externalId: string;
duration: number;
contactIds: string[];
billing: {
inputCost: number;
outputCost: number;
totalCost: number;
};
usage: {
promptTokens: number;
completionTokens: number;
totalTokens: number;
};
tracesCount: number;
tags: string[];
projectId?: string;
startedAt?: Date;
updatedAt?: Date;
title?: string;
client?: string;
repo?: string;
kind?: "THREAD_KIND_UNSPECIFIED" | "THREAD_KIND_CONVERSATION" | "THREAD_KIND_CODING_AGENT";
}
Delete a Session
Delete a trace thread.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
orq.sessions.delete(session_id="<id>")
# Use the SDK ...
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
await orq.sessions.delete({
sessionId: "<id>",
});
}
run();
Show Parameters
Show Parameters
{
"session_id": str, # required
}
{
sessionId: string; // required
}
Update a Session
Update a trace thread.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.sessions.update(session_id="<id>", tags=["customer-support"])
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.sessions.update({
sessionId: "<id>",
updateThreadRequest: {
tags: ["customer-support"],
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"session_id": str, # required
"external_id": Optional[str],
"duration": Optional[float],
"contact_ids": List[str], # optional
"billing": { # optional
"input_cost": float, # required
"output_cost": float, # required
"total_cost": float, # required
},
"usage": { # optional
"prompt_tokens": int, # required
"completion_tokens": int, # required
"total_tokens": int, # required
},
"traces_count": Optional[int],
"tags": List[str], # optional
"project_id": Optional[str],
"started_at": str, # optional
"updated_at": str, # optional
"clear_contact_ids": Optional[bool],
"clear_tags": Optional[bool],
"title": Optional[str],
"client": Optional[str],
"repo": Optional[str],
"kind": Optional[Literal["THREAD_KIND_UNSPECIFIED", "THREAD_KIND_CONVERSATION", "THREAD_KIND_CODING_AGENT"]],
}
{
sessionId: string; // required
updateThreadRequest: { // required
externalId?: string;
duration?: number;
contactIds?: string[];
billing?: {
inputCost: number; // required
outputCost: number; // required
totalCost: number; // required
};
usage?: {
promptTokens: number; // required
completionTokens: number; // required
totalTokens: number; // required
};
tracesCount?: number;
tags?: string[];
projectId?: string;
startedAt?: Date;
updatedAt?: Date;
clearContactIds?: boolean;
clearTags?: boolean;
title?: string;
client?: string;
repo?: string;
kind?: "THREAD_KIND_UNSPECIFIED" | "THREAD_KIND_CONVERSATION" | "THREAD_KIND_CODING_AGENT";
};
}
Show Response
Show Response
{
"id": str,
"external_id": str,
"duration": float,
"contact_ids": List[str],
"billing": {
"input_cost": float,
"output_cost": float,
"total_cost": float,
},
"usage": {
"prompt_tokens": int,
"completion_tokens": int,
"total_tokens": int,
},
"traces_count": int,
"tags": List[str],
"project_id": Optional[str],
"started_at": str, # optional
"updated_at": str, # optional
"title": Optional[str],
"client": Optional[str],
"repo": Optional[str],
"kind": Optional[Literal["THREAD_KIND_UNSPECIFIED", "THREAD_KIND_CONVERSATION", "THREAD_KIND_CODING_AGENT"]],
}
{
id: string;
externalId: string;
duration: number;
contactIds: string[];
billing: {
inputCost: number;
outputCost: number;
totalCost: number;
};
usage: {
promptTokens: number;
completionTokens: number;
totalTokens: number;
};
tracesCount: number;
tags: string[];
projectId?: string;
startedAt?: Date;
updatedAt?: Date;
title?: string;
client?: string;
repo?: string;
kind?: "THREAD_KIND_UNSPECIFIED" | "THREAD_KIND_CONVERSATION" | "THREAD_KIND_CODING_AGENT";
}