mirror of
https://github.com/hwchase17/langchain.git
synced 2026-07-12 19:31:24 +00:00
Mirrors the existing langchain-openai service_tier breakdown so downstream
pricing/analytics can apply Anthropic's priority-tier (~1.5x) and US-only
inference (1.1x) multipliers.
- `_create_usage_metadata` now reads `usage.service_tier` and
`usage.inference_geo` (or accepts explicit overrides). For
`service_tier in {priority, batch}` it prefixes the cache_read /
cache_creation / ephemeral keys with the tier and adds a bare tier key
equal to non-cache input. For `inference_geo == "us"` it adds a bare
`us` key equal to full input/output totals (1.1x applies to every
category).
- `service_tier` and `inference_geo` are echoed into `response_metadata`
(and `llm_output` already carries the full usage object).
- Streaming threads `service_tier` and `inference_geo` from
`message_start.message.usage` through a new `stream_state` dict so the
final `message_delta` chunk gets the breakdown — Anthropic's
`MessageDeltaUsage` doesn't carry these fields directly. The values are
only emitted on the final delta chunk to avoid string concatenation
during chunk merging.
FAQ
Looking for an integration not listed here? Check out the integrations documentation and the note in the libs/ README about third-party maintained packages.
Integration docs
For full documentation, see the primary and API reference docs for integrations.