tweak: include usage by default for openai compatible providers (#2788)

pull/2831/head
Aiden Cline 2025-09-25 21:06:58 -05:00 committed by GitHub
parent 8f135d13e3
commit d47feb9969
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -338,6 +338,9 @@ export namespace Provider {
const s = await state()
const pkg = model.provider?.npm ?? provider.npm ?? provider.id
const options = { ...s.providers[provider.id]?.options }
if (pkg.includes("@ai-sdk/openai-compatible") && options["includeUsage"] === undefined) {
options["includeUsage"] = true
}
const key = Bun.hash.xxHash32(JSON.stringify({ pkg, options }))
const existing = s.sdk.get(key)
if (existing) return existing