Openrouter_api.GenerationQuery generation stats for a previously-issued completion via the GET /api/v1/generation endpoint. The generation id is the same id returned on a chat completion or stream chunk; stats become queryable a few seconds after the request finishes.
module Provider_response : sig ... endmodule Stats : sig ... endStats for a single generation. Many fields are nullable on the wire; we keep them as options rather than papering over with defaults.
val get :
api_key:string ->
?app_info:Http.App_info.t ->
?on_response_body:(string -> unit Async.Deferred.t) ->
id:string ->
unit ->
Stats.t option Core.Or_error.t Async.Deferred.tget ~api_key ~id () resolves to Some stats once the generation has been persisted. Returns None if the generation is not yet (or not ever) queryable — the endpoint typically takes a couple of seconds after the completion to materialize.
module For_testing : sig ... end