PR_pr_feat-anthropic-real-usage-cost-tracking.md
Track Anthropic costs from native usage metadata instead of relying on the fallback tiktoken estimator.
Anthropic requests were being costed with a generic text-length estimator rather than the provider's native token usage metadata. That made Anthropic totals inaccurate, especially for streaming responses and tool-calling flows where usage arrives through response metadata rather than plain text length.
gpt_researcher/utils/costs.pyresponse_metadata["usage"] / usage_metadata when Anthropic returns native token countsGenericLLMProvider for both normal and streaming responsescreate_chat_completion() and tool-calling flowsVerified locally with:
uv run python -c "import gpt_researcher; print('ok')"uv run python -m unittest tests.test_costs tests.test_llm_usage_trackingNone.
None identified.