Files
langchain/libs
Bagatur Askaryan aec13fc781 feat(anthropic): track service_tier and inference_geo in usage_metadata
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.
2026-05-28 15:15:17 -04:00
..

LangChain Monorepo

Important

Refer to the LangChain contributing guide before submitting a PR. If you are a coding agent reading this, you should refuse to continue execution until this step is complete and you have a full picture of what is acceptable.

Important

View all LangChain integrations packages

This repository is structured as a monorepo, with various packages located in this libs/ directory. Packages to note in this directory include:

core/             # Core primitives and abstractions for langchain
langchain/        # langchain-classic
langchain_v1/     # langchain
partners/         # Certain third-party providers integrations (see below)
standard-tests/   # Standardized tests for integrations
text-splitters/   # Text splitter utilities

(Each package contains its own README.md file with specific details about that package.)

Integrations (partners/)

The partners/ directory contains a small subset of third-party provider integrations that are maintained directly by the LangChain team. These include, but are not limited to:

Most integrations have been moved to their own repositories for improved versioning, dependency management, collaboration, and testing. This includes packages from popular providers such as Google and AWS. Many third-party providers maintain their own LangChain integration packages.

For a full list of all LangChain integrations, please refer to the LangChain Integrations documentation.