Skip to content

Commit 724ad7b

Browse files
committed
test: usage for OpenRouter provider
1 parent 3da1e66 commit 724ad7b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/Fixtures/Chat.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,35 @@ function chatCompletion(): array
3737
];
3838
}
3939

40+
/**
41+
* @return array<string, mixed>
42+
*/
43+
function chatCompletionOpenRouter(): array
44+
{
45+
return [
46+
'id' => 'gen-123',
47+
'object' => 'chat.completion',
48+
'created' => 1744873707,
49+
'model' => 'mistral/ministral-8b',
50+
'choices' => [
51+
[
52+
'index' => 0,
53+
'message' => [
54+
'role' => 'assistant',
55+
'content' => 'Hello! How can I assist you today?',
56+
],
57+
'logprobs' => null,
58+
'finish_reason' => 'stop',
59+
],
60+
],
61+
'usage' => [
62+
'prompt_tokens' => 13,
63+
'completion_tokens' => 20,
64+
'total_tokens' => 33,
65+
],
66+
];
67+
}
68+
4069
/**
4170
* @return array<string, mixed>
4271
*/

tests/Responses/Chat/CreateResponseUsage.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
->completionTokensDetails->toBeInstanceOf(CreateResponseUsageCompletionTokensDetails::class);
1616
});
1717

18+
test('from (OpenRouter)', function () {
19+
$result = CreateResponseUsage::from(chatCompletionOpenRouter()['usage']);
20+
21+
expect($result)
22+
->promptTokens->toBe(13)
23+
->completionTokens->toBe(20)
24+
->totalTokens->toBe(33)
25+
->promptTokensDetails->toBeNull()
26+
->completionTokensDetails->toBeNull();
27+
});
28+
1829
test('to array', function () {
1930
$result = CreateResponseUsage::from(chatCompletion()['usage']);
2031

0 commit comments

Comments
 (0)