feat: bill OpenAI cache_write_tokens at cache-creation price with zero clamp
Parse OpenAI's native cache_write_tokens (chat prompt_tokens_details / responses input_tokens_details), bill it at the cache-creation ratio, and clamp the uncached prompt remainder at zero since cached + cache-write can exceed prompt_tokens. Propagate the field through chat/responses/claude format conversions and tiered expression billing (cc variable).
This commit is contained in:
@@ -41,12 +41,14 @@ func ResponsesHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *
|
||||
responsesReq = req
|
||||
case *dto.OpenAIResponsesCompactionRequest:
|
||||
responsesReq = &dto.OpenAIResponsesRequest{
|
||||
Model: req.Model,
|
||||
Input: req.Input,
|
||||
Instructions: req.Instructions,
|
||||
PreviousResponseID: req.PreviousResponseID,
|
||||
ParallelToolCalls: req.ParallelToolCalls,
|
||||
ServiceTier: req.ServiceTier,
|
||||
Model: req.Model,
|
||||
Input: req.Input,
|
||||
Instructions: req.Instructions,
|
||||
PreviousResponseID: req.PreviousResponseID,
|
||||
ParallelToolCalls: req.ParallelToolCalls,
|
||||
ServiceTier: req.ServiceTier,
|
||||
PromptCacheOptions: req.PromptCacheOptions,
|
||||
PromptCacheRetention: req.PromptCacheRetention,
|
||||
}
|
||||
default:
|
||||
return types.NewErrorWithStatusCode(
|
||||
|
||||
Reference in New Issue
Block a user