@@ -33,6 +33,7 @@ async def __call__(self, *args, **kwargs):
3333from sentry_sdk .utils import package_version
3434
3535from openai import OpenAI , AsyncOpenAI
36+ from openai .types import CompletionUsage
3637
3738from concurrent .futures import ThreadPoolExecutor
3839
@@ -165,6 +166,11 @@ def test_nonstreaming_chat_completion(
165166 response_model = "gpt-3.5-turbo" ,
166167 message_content = "Test response" ,
167168 created = 1234567890 ,
169+ usage = CompletionUsage (
170+ prompt_tokens = 10 ,
171+ completion_tokens = 20 ,
172+ total_tokens = 30 ,
173+ ),
168174 ),
169175 serialize_pydantic = True ,
170176 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -252,6 +258,11 @@ async def test_async_nonstreaming_chat_completion(
252258 response_model = "gpt-3.5-turbo" ,
253259 message_content = "Test response" ,
254260 created = 1234567890 ,
261+ usage = CompletionUsage (
262+ prompt_tokens = 10 ,
263+ completion_tokens = 20 ,
264+ total_tokens = 30 ,
265+ ),
255266 ),
256267 serialize_pydantic = True ,
257268 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -919,6 +930,11 @@ def test_span_origin(
919930 response_model = "gpt-3.5-turbo" ,
920931 message_content = "Test response" ,
921932 created = 1234567890 ,
933+ usage = CompletionUsage (
934+ prompt_tokens = 10 ,
935+ completion_tokens = 20 ,
936+ total_tokens = 30 ,
937+ ),
922938 ),
923939 serialize_pydantic = True ,
924940 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -969,6 +985,11 @@ def test_multiple_providers(
969985 response_model = "gpt-3.5-turbo" ,
970986 message_content = "Test response" ,
971987 created = 1234567890 ,
988+ usage = CompletionUsage (
989+ prompt_tokens = 10 ,
990+ completion_tokens = 20 ,
991+ total_tokens = 30 ,
992+ ),
972993 ),
973994 serialize_pydantic = True ,
974995 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1068,6 +1089,11 @@ async def test_async_multiple_providers(
10681089 response_model = "gpt-3.5-turbo" ,
10691090 message_content = "Test response" ,
10701091 created = 1234567890 ,
1092+ usage = CompletionUsage (
1093+ prompt_tokens = 10 ,
1094+ completion_tokens = 20 ,
1095+ total_tokens = 30 ,
1096+ ),
10711097 ),
10721098 serialize_pydantic = True ,
10731099 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1168,6 +1194,11 @@ def test_additional_parameters(
11681194 response_model = "gpt-3.5-turbo" ,
11691195 message_content = "Test response" ,
11701196 created = 1234567890 ,
1197+ usage = CompletionUsage (
1198+ prompt_tokens = 10 ,
1199+ completion_tokens = 20 ,
1200+ total_tokens = 30 ,
1201+ ),
11711202 ),
11721203 serialize_pydantic = True ,
11731204 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1231,6 +1262,11 @@ async def test_async_additional_parameters(
12311262 response_model = "gpt-3.5-turbo" ,
12321263 message_content = "Test response" ,
12331264 created = 1234567890 ,
1265+ usage = CompletionUsage (
1266+ prompt_tokens = 10 ,
1267+ completion_tokens = 20 ,
1268+ total_tokens = 30 ,
1269+ ),
12341270 ),
12351271 serialize_pydantic = True ,
12361272 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1294,6 +1330,11 @@ def test_no_integration(
12941330 response_model = "gpt-3.5-turbo" ,
12951331 message_content = "Test response" ,
12961332 created = 1234567890 ,
1333+ usage = CompletionUsage (
1334+ prompt_tokens = 10 ,
1335+ completion_tokens = 20 ,
1336+ total_tokens = 30 ,
1337+ ),
12971338 ),
12981339 serialize_pydantic = True ,
12991340 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1346,6 +1387,11 @@ async def test_async_no_integration(
13461387 response_model = "gpt-3.5-turbo" ,
13471388 message_content = "Test response" ,
13481389 created = 1234567890 ,
1390+ usage = CompletionUsage (
1391+ prompt_tokens = 10 ,
1392+ completion_tokens = 20 ,
1393+ total_tokens = 30 ,
1394+ ),
13491395 ),
13501396 serialize_pydantic = True ,
13511397 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1528,6 +1574,11 @@ def test_binary_content_encoding_image_url(
15281574 response_model = "gpt-3.5-turbo" ,
15291575 message_content = "Test response" ,
15301576 created = 1234567890 ,
1577+ usage = CompletionUsage (
1578+ prompt_tokens = 10 ,
1579+ completion_tokens = 20 ,
1580+ total_tokens = 30 ,
1581+ ),
15311582 ),
15321583 serialize_pydantic = True ,
15331584 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1611,6 +1662,11 @@ async def test_async_binary_content_encoding_image_url(
16111662 response_model = "gpt-3.5-turbo" ,
16121663 message_content = "Test response" ,
16131664 created = 1234567890 ,
1665+ usage = CompletionUsage (
1666+ prompt_tokens = 10 ,
1667+ completion_tokens = 20 ,
1668+ total_tokens = 30 ,
1669+ ),
16141670 ),
16151671 serialize_pydantic = True ,
16161672 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1696,6 +1752,11 @@ def test_binary_content_encoding_mixed_content(
16961752 response_model = "gpt-3.5-turbo" ,
16971753 message_content = "Test response" ,
16981754 created = 1234567890 ,
1755+ usage = CompletionUsage (
1756+ prompt_tokens = 10 ,
1757+ completion_tokens = 20 ,
1758+ total_tokens = 30 ,
1759+ ),
16991760 ),
17001761 serialize_pydantic = True ,
17011762 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1768,6 +1829,11 @@ async def test_async_binary_content_encoding_mixed_content(
17681829 response_model = "gpt-3.5-turbo" ,
17691830 message_content = "Test response" ,
17701831 created = 1234567890 ,
1832+ usage = CompletionUsage (
1833+ prompt_tokens = 10 ,
1834+ completion_tokens = 20 ,
1835+ total_tokens = 30 ,
1836+ ),
17711837 ),
17721838 serialize_pydantic = True ,
17731839 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1839,6 +1905,11 @@ def test_binary_content_encoding_uri_type(
18391905 response_model = "gpt-3.5-turbo" ,
18401906 message_content = "Test response" ,
18411907 created = 1234567890 ,
1908+ usage = CompletionUsage (
1909+ prompt_tokens = 10 ,
1910+ completion_tokens = 20 ,
1911+ total_tokens = 30 ,
1912+ ),
18421913 ),
18431914 serialize_pydantic = True ,
18441915 request_headers = {"X-Stainless-Raw-Response" : "true" },
@@ -1916,6 +1987,11 @@ async def test_async_binary_content_encoding_uri_type(
19161987 response_model = "gpt-3.5-turbo" ,
19171988 message_content = "Test response" ,
19181989 created = 1234567890 ,
1990+ usage = CompletionUsage (
1991+ prompt_tokens = 10 ,
1992+ completion_tokens = 20 ,
1993+ total_tokens = 30 ,
1994+ ),
19191995 ),
19201996 serialize_pydantic = True ,
19211997 request_headers = {"X-Stainless-Raw-Response" : "true" },
0 commit comments