import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.usage.completions({
startTime: 1704067200,
endTime: 1704153600,
limit: 30,
page: "cursor_abc123",
userIds: [
"user_123",
"user_456",
],
groupBy: [
"model",
],
models: [
"meetkai:functionary-urdu-mini-pak",
],
});
console.log(result);
}
run();{
"object": "page",
"data": [
{
"object": "bucket",
"start_time": 1704067200,
"end_time": 1704153600,
"results": [
{
"object": "organization.usage.completions.result",
"input_tokens": 1200,
"output_tokens": 300,
"input_cached_tokens": 200,
"num_model_requests": 12,
"user_id": "user_123",
"api_key_id": "key_abc123",
"model": "meetkai:functionary-urdu-mini-pak",
"batch": null,
"service_tier": null,
"project_id": null
}
]
}
],
"has_more": false,
"next_page": null
}Retrieve usage metrics for chat completions, aggregated from the ChatCompletion table.
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.usage.completions({
startTime: 1704067200,
endTime: 1704153600,
limit: 30,
page: "cursor_abc123",
userIds: [
"user_123",
"user_456",
],
groupBy: [
"model",
],
models: [
"meetkai:functionary-urdu-mini-pak",
],
});
console.log(result);
}
run();{
"object": "page",
"data": [
{
"object": "bucket",
"start_time": 1704067200,
"end_time": 1704153600,
"results": [
{
"object": "organization.usage.completions.result",
"input_tokens": 1200,
"output_tokens": 300,
"input_cached_tokens": 200,
"num_model_requests": 12,
"user_id": "user_123",
"api_key_id": "key_abc123",
"model": "meetkai:functionary-urdu-mini-pak",
"batch": null,
"service_tier": null,
"project_id": null
}
]
}
],
"has_more": false,
"next_page": null
}Authenticate with your MKA1 API key at the API gateway: Authorization: Bearer <mka1-api-key>. For multi-user server-side integrations, also send X-On-Behalf-Of to identify the end user making the request.
Optional external user identifier for multi-user server-side integrations. Use this when acting on behalf of one of your end users.
Start time (Unix seconds), inclusive
-9007199254740991 <= x <= 90071992547409911704067200
End time (Unix seconds), exclusive
-9007199254740991 <= x <= 90071992547409911704153600
Width of each time bucket (1m, 1h, 1d)
1m, 1h, 1d "1d"
Number of buckets to return
1 <= x <= 144030
Pagination cursor
"cursor_abc123"
Filter by external Subs (externalUserIds)
["user_123", "user_456"]Group by specified fields
user_id, api_key_id, model Filter by model names
Was this page helpful?