Skip to content

Commit ff918aa

Browse files
fix: allow null values for prompt_tokens_details and completion_tokens_details (#75)
* fix: allow null values for prompt_tokens_details and completion_tokens_details Fixes #73 where OpenRouter API returns null for prompt_tokens_details and completion_tokens_details but schema validation only allowed object or undefined. Changed .optional() to .nullish() to accept null, undefined, or object values. Co-Authored-By: Louis <[email protected]> * chore: bump version to 0.7.1 Co-Authored-By: Louis <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Louis <[email protected]>
1 parent 93a880e commit ff918aa

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openrouter/ai-sdk-provider",
3-
"version": "0.7.0",
3+
"version": "0.7.1",
44
"license": "Apache-2.0",
55
"sideEffects": false,
66
"main": "./dist/index.js",

src/openrouter-chat-language-model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,13 +733,13 @@ const OpenRouterChatCompletionBaseResponseSchema = z.object({
733733
.object({
734734
cached_tokens: z.number(),
735735
})
736-
.optional(),
736+
.nullish(),
737737
completion_tokens: z.number(),
738738
completion_tokens_details: z
739739
.object({
740740
reasoning_tokens: z.number(),
741741
})
742-
.optional(),
742+
.nullish(),
743743
total_tokens: z.number(),
744744
cost: z.number().optional(),
745745
})

0 commit comments

Comments
 (0)