Budget & Spend Tracking
View all spend logs, if request_id is provided, only logs for that request_id will be returned
Example Request for all logs
curl -X GET "http://0.0.0.0:8000/spend/logs" -H "Authorization: Bearer sk-1234"Example Request for specific request_id
curl -X GET "http://0.0.0.0:8000/spend/logs?request_id=chatcmpl-6dcb2540-d3d7-4e49-bb27-291f863f112e" -H "Authorization: Bearer sk-1234"Example Request for specific api_key
curl -X GET "http://0.0.0.0:8000/spend/logs?api_key=sk-Fn8Ej39NkBQmUagFEoUWPQ" -H "Authorization: Bearer sk-1234"Example Request for specific user_id
curl -X GET "http://0.0.0.0:8000/spend/logs?user_id=ishaan@berri.ai" -H "Authorization: Bearer sk-1234"Authorizations
x-llm-api-keystringRequired
Bearer token
Query parameters
api_keystring · nullableOptional
Get spend logs based on api key
user_idstring · nullableOptional
Get spend logs based on user_id
request_idstring · nullableOptional
request_id to get spend logs for specific request_id. If none passed then pass spend logs for all requests
start_datestring · nullableOptional
Time from which to start viewing key spend
end_datestring · nullableOptional
Time till which to view key spend
Responses
200
Successful Response
application/json
request_idstringRequired
api_keystringRequired
modelstring · nullableOptionalDefault:
""api_basestring · nullableOptionalDefault:
""call_typestringRequired
spendnumber · nullableOptionalDefault:
0total_tokensinteger · nullableOptionalDefault:
0prompt_tokensinteger · nullableOptionalDefault:
0completion_tokensinteger · nullableOptionalDefault:
0startTimeany of · nullableRequired
stringOptional
string · date-timeOptional
endTimeany of · nullableRequired
stringOptional
string · date-timeOptional
userstring · nullableOptionalDefault:
""metadataany · nullableOptionalDefault:
{}cache_hitstring · nullableOptionalDefault:
Falsecache_keystring · nullableOptional
request_tagsany · nullableOptional
requester_ip_addressstring · nullableOptional
messagesany of · nullableRequired
stringOptional
or
responseany of · nullableRequired
stringOptional
or
422
Validation Error
application/json
get/spend/logs
GET /spend/logs HTTP/1.1
x-llm-api-key: YOUR_API_KEY
Accept: */*
[
{
"request_id": "text",
"api_key": "text",
"model": "",
"api_base": "",
"call_type": "text",
"spend": 0,
"total_tokens": 0,
"prompt_tokens": 0,
"completion_tokens": 0,
"startTime": "text",
"endTime": "text",
"user": "",
"metadata": null,
"cache_hit": "False",
"cache_key": "text",
"request_tags": null,
"requester_ip_address": "text",
"messages": "text",
"response": "text"
}
]Last updated