Integration methods
Threads
Prompt versions
Multimodal integrations
Model
Log list
url = "https://api.keywordsai.co/api/request-logs/?page=1&sort_by=-id&is_test=false&all_envs=false&fetch_filters=false&page_size=1"
from urllib.parse import urlencode
params = {
"page": 1,
"sort_by": "-id",
"is_test": "false",
"all_envs": "false",
"fetch_filters": "false",
"page_size": 1
}
url = f"https://api.keywordsai.co/api/request-logs/?{urlencode(params)}"
headers = {
"Authorization": f"Api-Key {YOUR_KEYWORDS_AI_API_KEY}",
}
data = {
"filters": {}
}
response = requests.post(url, headers=headers, json=data)
{
"results": [
{
"unique_id": "xxxxx",
"organization_key__name": "Keywords AI Default",
"organization": "Keywords AI",
"user": "hendrix@keywordsai.co",
"is_example": false,
"status": "success",
"prompt_tokens": 452,
"completion_tokens": 89,
"cost": 0.0005869,
"prompt_messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "What is Keywords AI?"
}
],
"completion_message": {
"role": "assistant",
"content": "Keywords AI is a unified DevOps platform for AI products."
},
"latency": 1.2114145755767822,
"model": "gpt-3.5-turbo",
"foundation_model": "gpt-3.5-turbo",
"provider_id": "openai",
"tool_choice": null,
"tools": null,
"tool_calls": null,
"timestamp": "2024-06-24T21:33:06.601353Z",
"failed": false,
"time_to_first_token": null,
"routing_time": 0.0,
"metadata": {
// any params you want to pass in the request
},
"stream": false,
"status_code": 200,
"customer_identifier": "123456",
"customer_email": "",
"used_custom_credential": false,
// ... other models ...
},
]
}
The Logs List endpoint allows you to get the past logs with specified filters.
Query params
You can add these params to the URL params. For example:
"https://api.keywordsai.co/api/request-logs/?page=1&sort_by=-id&is_test=false&all_envs=false&fetch_filters=false&page_size=1"
The field to sort by. Default is -id
(same as sort by -timestamp
, but with better performance).
-
is for descending order, if not provided, it will be in ascending order.
Sort by the ID of each request.
Sort by the cost of each request.
TTFT - useful for Voice AI applications
Generation time of each request.
Input / prompt tokens of each request.
Output / completion tokens of each request.
Total tokens of each request.
{
"sort_by": "cost" //sort by cost in ascending order.
}
Whether to include logs from all environments. is_test
parameter will override this parameter.
Options: true
, false
.
Whether the log is a test call or not. This parameter will override the all_envs
parameter.
Options: true
, false
.
Whether to retrieve the available filtering options. Enabling this could slow down the response time.
Options: true
, false
.
The number of logs to return per page. Maximum is 1000.
The page number of the current logs.
POST params
You can add these params to the body:
url = "https://api.keywordsai.co/api/request-logs/"
headers = {
"Authorization": f"Api-Key {YOUR_KEYWORDS_AI_API_KEY}",
}
data = {
"filters": {
"cost": {
"operator": "gt",
"value": [0.01]
},
}
}
response = requests.post(url, headers=headers, json=data)
The filters be applied to the logs. For available options in the response body, use the fetch_filters
parameter.
{
"name_of_metric": {
"operator": "gt",
"value": [100]
},
}
Default is "" (equal).
Equal
{
"name_of_metric": {
"operator": "", // equal
"value": [100]
},
}
case insensitive equal
Less than
Less than or equal
Greater than
Greater than or equal
Can be used in arrays or text
Check if the field is null
Case insensitive contains
url = "https://api.keywordsai.co/api/request-logs/?page=1&sort_by=-id&is_test=false&all_envs=false&fetch_filters=false&page_size=1"
from urllib.parse import urlencode
params = {
"page": 1,
"sort_by": "-id",
"is_test": "false",
"all_envs": "false",
"fetch_filters": "false",
"page_size": 1
}
url = f"https://api.keywordsai.co/api/request-logs/?{urlencode(params)}"
headers = {
"Authorization": f"Api-Key {YOUR_KEYWORDS_AI_API_KEY}",
}
data = {
"filters": {}
}
response = requests.post(url, headers=headers, json=data)
{
"results": [
{
"unique_id": "xxxxx",
"organization_key__name": "Keywords AI Default",
"organization": "Keywords AI",
"user": "hendrix@keywordsai.co",
"is_example": false,
"status": "success",
"prompt_tokens": 452,
"completion_tokens": 89,
"cost": 0.0005869,
"prompt_messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "What is Keywords AI?"
}
],
"completion_message": {
"role": "assistant",
"content": "Keywords AI is a unified DevOps platform for AI products."
},
"latency": 1.2114145755767822,
"model": "gpt-3.5-turbo",
"foundation_model": "gpt-3.5-turbo",
"provider_id": "openai",
"tool_choice": null,
"tools": null,
"tool_calls": null,
"timestamp": "2024-06-24T21:33:06.601353Z",
"failed": false,
"time_to_first_token": null,
"routing_time": 0.0,
"metadata": {
// any params you want to pass in the request
},
"stream": false,
"status_code": 200,
"customer_identifier": "123456",
"customer_email": "",
"used_custom_credential": false,
// ... other models ...
},
]
}
Was this page helpful?
url = "https://api.keywordsai.co/api/request-logs/?page=1&sort_by=-id&is_test=false&all_envs=false&fetch_filters=false&page_size=1"
from urllib.parse import urlencode
params = {
"page": 1,
"sort_by": "-id",
"is_test": "false",
"all_envs": "false",
"fetch_filters": "false",
"page_size": 1
}
url = f"https://api.keywordsai.co/api/request-logs/?{urlencode(params)}"
headers = {
"Authorization": f"Api-Key {YOUR_KEYWORDS_AI_API_KEY}",
}
data = {
"filters": {}
}
response = requests.post(url, headers=headers, json=data)
{
"results": [
{
"unique_id": "xxxxx",
"organization_key__name": "Keywords AI Default",
"organization": "Keywords AI",
"user": "hendrix@keywordsai.co",
"is_example": false,
"status": "success",
"prompt_tokens": 452,
"completion_tokens": 89,
"cost": 0.0005869,
"prompt_messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "What is Keywords AI?"
}
],
"completion_message": {
"role": "assistant",
"content": "Keywords AI is a unified DevOps platform for AI products."
},
"latency": 1.2114145755767822,
"model": "gpt-3.5-turbo",
"foundation_model": "gpt-3.5-turbo",
"provider_id": "openai",
"tool_choice": null,
"tools": null,
"tool_calls": null,
"timestamp": "2024-06-24T21:33:06.601353Z",
"failed": false,
"time_to_first_token": null,
"routing_time": 0.0,
"metadata": {
// any params you want to pass in the request
},
"stream": false,
"status_code": 200,
"customer_identifier": "123456",
"customer_email": "",
"used_custom_credential": false,
// ... other models ...
},
]
}