Skip to content

Conversation

@pocketarc
Copy link
Contributor

OpenRouter doesn't always return usage data in API responses. When usage.prompt_tokens or usage.completion_tokens are missing, data_get() returns null, causing a TypeError in the Usage constructor which requires int values.

The Stream handler already handles this correctly. This aligns the Text and Structured handlers with the Stream handler.

Before:

TypeError: Prism\Prism\ValueObjects\Usage::__construct(): Argument #1 ($promptTokens) must be of type int, null given

After:

Missing token values default to 0, no error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant