Skip to content

Expose provider token usage on responses#151

Open
KotlinFactory wants to merge 1 commit intohuggingface:mainfrom
SolbachLeads:pr/token-usage
Open

Expose provider token usage on responses#151
KotlinFactory wants to merge 1 commit intohuggingface:mainfrom
SolbachLeads:pr/token-usage

Conversation

@KotlinFactory
Copy link
Contributor

Summary

  • add a LanguageModelUsage type for provider-reported token usage
  • expose usage on LanguageModelSession.Response and streaming snapshots
  • map provider usage metadata for OpenAI, Open Responses, Anthropic, Gemini, and Ollama
  • add focused tests for response and stream usage exposure

Testing

  • xcrun swift build
  • xcrun swift test --filter MockLanguageModelTests

Notes

  • this PR is scoped to reporting token usage only
  • the branch is based directly on huggingface/main

@KotlinFactory
Copy link
Contributor Author

Background: Tracking LLM cost on a per-user or per-task basis.

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