package chatoyant

  1. Overview
  2. Docs
OCaml-first LLM SDK with Melange-generated JavaScript

Install

dune-project
 Dependency

Authors

Maintainers

Sources

chatoyant-v0.12.4.tbz
sha256=fbf19dea0d39482e0263812504d94c682a9f3a6e93f68fe0c57b2d38ed4166b3
sha512=4e01be9c0ec9c16880f98360dec4ef5e0dddd9192e2113991b154e891b3bdaefb614051c2cb63afa0b714efa0e4cc4fd8054528fdc1995f3a4858fe2fcd50256

doc/chatoyant.tokens/Chatoyant_tokens/Cost/index.html

Module Chatoyant_tokens.CostSource

Token usage and cost data shared by core and provider layers.

Sourcetype usage = {
  1. input_tokens : int;
  2. output_tokens : int;
  3. reasoning_tokens : int;
  4. cached_tokens : int;
  5. cache_write_tokens : int;
  6. total_tokens : int;
  7. actual_cost_usd : float option;
}
Sourcetype source =
  1. | Provider_reported
  2. | Estimated
  3. | Unmetered
  4. | Unknown
    (*

    Provenance for token usage. Provider-reported values are authoritative; estimated values must only be used when a provider did not return usage. Local inference is unmetered by design.

    *)
Sourcetype pricing = {
  1. input_per_million : float;
  2. output_per_million : float;
  3. cached_per_million : float option;
  4. cache_write_per_million : float option;
  5. cache_write_1h_per_million : float option;
  6. per_image : float option;
  7. per_second : float option;
}
Sourcetype result = {
  1. input : float;
  2. output : float;
  3. cached : float;
  4. cache_write : float;
  5. actual_usd : float option;
  6. total : float;
}
Sourcetype cost_per_token = {
  1. per_token_input : float;
  2. per_token_output : float;
  3. per_token_cached : float;
  4. per_token_cache_write : float;
}
Sourceval empty_usage : usage
Sourceval pricing : ?cached_per_million:float -> ?cache_write_per_million:float -> ?cache_write_1h_per_million:float -> ?per_image:float -> ?per_second:float -> input_per_million:float -> output_per_million:float -> unit -> pricing
Sourceval calculate : pricing:pricing option -> usage -> result
Sourceval estimate : pricing:pricing option -> ?input_tokens:int -> ?input_text:string -> expected_output_tokens:int -> unit -> result
Sourceval calculate_batch : pricing:pricing option -> usage list -> result
Sourceval calculate_image : pricing:pricing option -> count:int -> float
Sourceval calculate_video : pricing:pricing option -> duration_seconds:int -> float
Sourceval cost_per_token : pricing -> cost_per_token
Sourceval normalize_total : usage -> usage
Sourceval source_to_string : source -> string
Sourceval usage_to_json : usage -> Chatoyant_runtime.Json.t
Sourceval result_to_json : result -> Chatoyant_runtime.Json.t