-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents_send_usage_message_completed.py
More file actions
44 lines (34 loc) · 1.15 KB
/
events_send_usage_message_completed.py
File metadata and controls
44 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# coding=utf-8
import os
from corehttp.credentials import ServiceKeyCredential
from credytapi import CredytApiClient
"""
# PREREQUISITES
pip install credyt-api
# USAGE
python events_send_usage_message_completed.py
Before run the sample, please set environment variables AZURE_KEY with real value
which can access your service
"""
def main():
client = CredytApiClient(
credential=ServiceKeyCredential(key=os.getenv("CREDYT_API_KEY")),
)
client.events.send_usage(
body={
"customer_id": "cust_473cr1y0ghbyc3m1yfbwvn3nxx",
"events": [
{
"data": {"input_tokens": 2353, "model": "gpt-4-1", "output_tokens": 34697},
"description": "Chat message completed",
"event_type": "message_completed",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"occurred_at": "2024-07-29T15:51:28.071Z",
"subject": "chat_5f53d23a4958",
}
],
},
)
# x-ms-original-file: next/Events_send_usage_Message_Completed.json
if __name__ == "__main__":
main()