async-bulkhead-llm - v3.17.0
    Preparing search index...

    Function createModelAwareTokenEstimator

    • Estimates token usage using per-model character ratios.

      Accuracy: ±15% for known models on English prose. Falls back to naiveTokenEstimator (ratio 4.0) for unknown models.

      v2: respects request.model when present, falling back to defaultModel. v2: handles multimodal content (text blocks counted, others ignored). v3.7: counts request.system, adds request.extraInputTokens verbatim, and applies the opaqueBlockTokens surcharge (when configured) to every non-text block in messages and system.

      Parameters

      Returns TokenEstimator

    • Estimates token usage using per-model character ratios.

      Accuracy: ±15% for known models on English prose. Falls back to naiveTokenEstimator (ratio 4.0) for unknown models.

      v2: respects request.model when present, falling back to defaultModel. v2: handles multimodal content (text blocks counted, others ignored). v3.7: counts request.system, adds request.extraInputTokens verbatim, and applies the opaqueBlockTokens surcharge (when configured) to every non-text block in messages and system.

      Parameters

      Returns TokenEstimator