Query traces with OQL
Run an OQL trace query. OQL is validated against the trace field registry and compiled through the trace planner.
POST
/
v2
/
traces
/
query
Query traces with OQL
curl --request POST \
--url https://api.orq.ai/v2/traces/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from": "2023-11-07T05:31:56Z",
"to": "2023-11-07T05:31:56Z",
"oql": "<string>",
"limit": 123,
"page_token": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '2023-11-07T05:31:56Z',
to: '2023-11-07T05:31:56Z',
oql: '<string>',
limit: 123,
page_token: '<string>'
})
};
fetch('https://api.orq.ai/v2/traces/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.orq.ai/v2/traces/query"
payload = {
"from": "2023-11-07T05:31:56Z",
"to": "2023-11-07T05:31:56Z",
"oql": "<string>",
"limit": 123,
"page_token": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"object": "<string>",
"search": {
"object": "list",
"data": [
{
"object": "trace",
"trace_id": "<string>",
"root_span_id": "<string>",
"leading_span_id": "<string>",
"name": "<string>",
"operation": "<string>",
"status": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"ended_at": "2023-11-07T05:31:56Z",
"duration_ms": 123,
"project_id": "<string>",
"identity_id": "<string>",
"session_id": "<string>",
"thread_id": "<string>",
"product": "<string>",
"providers": [
"<string>"
],
"models": [
"<string>"
],
"agent": {
"id": "<string>",
"name": "<string>"
},
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"prompt_cached_tokens": 123,
"prompt_audio_tokens": 123,
"completion_reasoning_tokens": 123,
"completion_audio_tokens": 123,
"completion_accepted_prediction_tokens": 123,
"completion_rejected_prediction_tokens": 123
},
"cost": {
"input": 123,
"output": 123,
"cache_read": 123,
"cache_write": 123,
"reasoning": 123,
"web_search": 123,
"total": 123,
"currency": "<string>",
"cached": 123,
"audio_input": 123,
"audio_output": 123,
"accepted_prediction": 123,
"rejected_prediction": 123,
"billable": true,
"pricing_tier": "<string>",
"threshold_exceeded": true,
"integration_id": "<string>"
},
"id": "<string>",
"span_id": "<string>",
"parent_id": "<string>",
"type": "<string>",
"context": {
"trace_id": "<string>",
"span_id": "<string>"
},
"attributes": {},
"start_time": "2023-11-07T05:31:56Z",
"end_time": "2023-11-07T05:31:56Z",
"duration": 123
}
],
"has_more": true,
"next_page_token": "<string>",
"meta": {
"request_id": "<string>",
"from": "2023-11-07T05:31:56Z",
"to": "2023-11-07T05:31:56Z",
"row_count": 123
}
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Was this page helpful?
⌘I
Query traces with OQL
curl --request POST \
--url https://api.orq.ai/v2/traces/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from": "2023-11-07T05:31:56Z",
"to": "2023-11-07T05:31:56Z",
"oql": "<string>",
"limit": 123,
"page_token": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '2023-11-07T05:31:56Z',
to: '2023-11-07T05:31:56Z',
oql: '<string>',
limit: 123,
page_token: '<string>'
})
};
fetch('https://api.orq.ai/v2/traces/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.orq.ai/v2/traces/query"
payload = {
"from": "2023-11-07T05:31:56Z",
"to": "2023-11-07T05:31:56Z",
"oql": "<string>",
"limit": 123,
"page_token": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"object": "<string>",
"search": {
"object": "list",
"data": [
{
"object": "trace",
"trace_id": "<string>",
"root_span_id": "<string>",
"leading_span_id": "<string>",
"name": "<string>",
"operation": "<string>",
"status": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"ended_at": "2023-11-07T05:31:56Z",
"duration_ms": 123,
"project_id": "<string>",
"identity_id": "<string>",
"session_id": "<string>",
"thread_id": "<string>",
"product": "<string>",
"providers": [
"<string>"
],
"models": [
"<string>"
],
"agent": {
"id": "<string>",
"name": "<string>"
},
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"prompt_cached_tokens": 123,
"prompt_audio_tokens": 123,
"completion_reasoning_tokens": 123,
"completion_audio_tokens": 123,
"completion_accepted_prediction_tokens": 123,
"completion_rejected_prediction_tokens": 123
},
"cost": {
"input": 123,
"output": 123,
"cache_read": 123,
"cache_write": 123,
"reasoning": 123,
"web_search": 123,
"total": 123,
"currency": "<string>",
"cached": 123,
"audio_input": 123,
"audio_output": 123,
"accepted_prediction": 123,
"rejected_prediction": 123,
"billable": true,
"pricing_tier": "<string>",
"threshold_exceeded": true,
"integration_id": "<string>"
},
"id": "<string>",
"span_id": "<string>",
"parent_id": "<string>",
"type": "<string>",
"context": {
"trace_id": "<string>",
"span_id": "<string>"
},
"attributes": {},
"start_time": "2023-11-07T05:31:56Z",
"end_time": "2023-11-07T05:31:56Z",
"duration": 123
}
],
"has_more": true,
"next_page_token": "<string>",
"meta": {
"request_id": "<string>",
"from": "2023-11-07T05:31:56Z",
"to": "2023-11-07T05:31:56Z",
"row_count": 123
}
}
}