Skip to content

feat: add cost tracking to chat and completion responses#68

Merged
hra42 merged 1 commit into
mainfrom
feat/chat-cost-tracking
Jun 7, 2026
Merged

feat: add cost tracking to chat and completion responses#68
hra42 merged 1 commit into
mainfrom
feat/chat-cost-tracking

Conversation

@hra42

@hra42 hra42 commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Add OpenRouter usage accounting support so callers can read the actual
cost of a request. New WithUsage / WithCompletionUsage options send
usage:{include:true}, and the shared Usage struct gains optional Cost,
CostDetails, PromptTokensDetails, and CompletionTokensDetails fields
(populated for both non-streaming and the final streaming chunk).

Includes unit tests (request shape + response decoding), a live e2e
test (chatcost), examples, and docs. Regenerated docs/api-surface.json.

Add OpenRouter usage accounting support so callers can read the actual
cost of a request. New WithUsage / WithCompletionUsage options send
usage:{include:true}, and the shared Usage struct gains optional Cost,
CostDetails, PromptTokensDetails, and CompletionTokensDetails fields
(populated for both non-streaming and the final streaming chunk).

Includes unit tests (request shape + response decoding), a live e2e
test (chatcost), examples, and docs. Regenerated docs/api-surface.json.
@hra42 hra42 self-assigned this Jun 7, 2026
@hra42 hra42 merged commit faa2483 into main Jun 7, 2026
5 checks passed
@hra42 hra42 deleted the feat/chat-cost-tracking branch June 7, 2026 19:59
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