You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: exclude undefined cost from providerMetadata (#359)
* fix: exclude undefined cost from providerMetadata
When cost is undefined, it should not be included in the providerMetadata
object since undefined is not a valid JSON value. This was causing AI SDK
validation failures when passing providerMetadata back into subsequent
conversation turns.
The fix uses conditional spreading/assignment to only include the cost
field when it has a defined value, matching the existing pattern used
for other optional fields like costDetails.
Fixes#262
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
* fix: apply same cost fix to embedding model
Ensure embedding model also uses conditional spreading for cost field
to maintain consistency with chat and completion models.
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
* fix: add providerMetadata to completion model doGenerate
For consistency with chat model and streaming endpoints, the completion
model's doGenerate method now returns providerMetadata with usage info.
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
* fix: add schema validation and provider field to completion/embedding models
- Completion doGenerate: use OpenRouterProviderMetadataSchema.parse() with provider field
- Completion doStream: track and include provider field in providerMetadata
- Completion schema: add provider field
- Embedding model: include provider field and full usage structure (promptTokens, completionTokens, totalTokens)
- Embedding schema: add provider field
- Update embedding test expectations
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
* fix: add schema validation to embedding model for consistency
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
* test: add coverage for completion doGenerate providerMetadata
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
0 commit comments