package ocaml-ai-sdk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Ai_provider_openrouter.Convert_usageSource

OpenRouter usage conversion with extended metrics.

Sourcetype prompt_tokens_details = {
  1. cached_tokens : int option;
  2. cache_write_tokens : int option;
}
Sourcetype completion_tokens_details = {
  1. reasoning_tokens : int option;
}
Sourcetype cost_details = {
  1. upstream_inference_cost : float option;
}
Sourcetype openrouter_usage = {
  1. prompt_tokens : int option;
  2. completion_tokens : int option;
  3. total_tokens : int option;
  4. prompt_tokens_details : prompt_tokens_details option;
  5. completion_tokens_details : completion_tokens_details option;
  6. cost : float option;
  7. cost_details : cost_details option;
}
Sourceval openrouter_usage_of_json : Melange_json.t -> openrouter_usage
Sourcetype openrouter_usage_metadata = {
  1. cache_read_tokens : int;
  2. cache_write_tokens : int;
  3. reasoning_tokens : int;
  4. cost : float option;
  5. upstream_inference_cost : float option;
}

Extended usage metadata for OpenRouter responses.

Convert to standard SDK usage.

Extract extended metadata from usage (defaults to zeros/None if fields are absent).