Affected Page / Module
Usage analytics / cost analytics
Use Case
We run CPA Manager Plus with xAI media models, including grok-imagine-image-quality, grok-imagine-image-2.0, grok-imagine-video, and grok-imagine-video-1.5. xAI bills image generation per image and video generation per output second/resolution, and returns the exact charged amount in usage.cost_in_usd_ticks.
We need Request Monitoring, Usage Analytics, Dashboard, and exports to report the real cost of these successful media requests even when token usage is zero.
Current Pain Point
CPAMP currently calculates cost only from per-1M-token prices. Successful image and video events are stored, but their input/output/total token counts are all zero, so CPAMP reports $0.000.
Verified with CPAMP v1.12.6 and CLIProxyAPI v7.2.145:
grok-imagine-image-quality: multiple successful image generation/edit events, all with zero total tokens.
grok-imagine-video-1.5: multiple successful video generation/status events, all with zero total tokens.
- The event records exist, so this is not the old missing-usage-event issue fixed by CLIProxyAPI #4308.
- The stored price schema only contains prompt/completion/cache prices per 1M tokens.
raw_json.usage and response metadata do not preserve cost_in_usd_ticks in CPAMP.
Existing issue #519 only requested informational billingUnit / billingRate fields and explicitly excluded cost calculation. PR #520 was closed without merge. This request is for actual request-level cost accounting.
Expected Solution
- Extend the CPA usage event contract to preserve a provider-reported monetary cost, preferably the exact xAI
usage.cost_in_usd_ticks value together with its currency and source.
- Store that request-level cost in CPAMP without converting it into synthetic tokens.
- Prefer the provider-reported exact cost for media requests; keep existing token-based estimation as the fallback for normal language models.
- Include media costs in Request Monitoring, Usage Analytics, Dashboard totals, API-key/account/model breakdowns, hourly rollups, and exports.
- If the upstream usage event does not yet expose
cost_in_usd_ticks, document and track the required CLIProxyAPI change rather than silently reporting zero cost.
- Support at least:
grok-imagine-image-quality
grok-imagine-image-2.0
grok-imagine-video
grok-imagine-video-1.5
Relevant Data Dimensions
Expected Acceptance Result
- A successful xAI image response containing
usage.cost_in_usd_ticks = 500000000 is stored and displayed as $0.05, while token counts remain zero.
- A successful video request is charged using the exact provider-reported request cost and is included once in aggregate totals, without double-counting generation and polling events.
- Cost totals match the xAI console for the same request IDs and time range within normal rounding tolerance.
- Language-model token billing continues to work unchanged.
- Historical events without provider-reported cost remain explicitly unknown or estimated; they are not presented as confirmed
$0.000 charges.
- Automated tests cover image cost, video cost, polling deduplication, rollups, exports, and token-billing regression.
Priority
High: affects the main workflow
Additional Context
The key distinction is that these models use non-token billing. Displaying a billing label is useful, but it does not solve request-level accounting or aggregate cost reporting.
Checklist
Affected Page / Module
Usage analytics / cost analytics
Use Case
We run CPA Manager Plus with xAI media models, including
grok-imagine-image-quality,grok-imagine-image-2.0,grok-imagine-video, andgrok-imagine-video-1.5. xAI bills image generation per image and video generation per output second/resolution, and returns the exact charged amount inusage.cost_in_usd_ticks.We need Request Monitoring, Usage Analytics, Dashboard, and exports to report the real cost of these successful media requests even when token usage is zero.
Current Pain Point
CPAMP currently calculates cost only from per-1M-token prices. Successful image and video events are stored, but their input/output/total token counts are all zero, so CPAMP reports
$0.000.Verified with CPAMP
v1.12.6and CLIProxyAPIv7.2.145:grok-imagine-image-quality: multiple successful image generation/edit events, all with zero total tokens.grok-imagine-video-1.5: multiple successful video generation/status events, all with zero total tokens.raw_json.usageand response metadata do not preservecost_in_usd_ticksin CPAMP.Existing issue #519 only requested informational
billingUnit/billingRatefields and explicitly excluded cost calculation. PR #520 was closed without merge. This request is for actual request-level cost accounting.Expected Solution
usage.cost_in_usd_ticksvalue together with its currency and source.cost_in_usd_ticks, document and track the required CLIProxyAPI change rather than silently reporting zero cost.grok-imagine-image-qualitygrok-imagine-image-2.0grok-imagine-videogrok-imagine-video-1.5Relevant Data Dimensions
Expected Acceptance Result
usage.cost_in_usd_ticks = 500000000is stored and displayed as$0.05, while token counts remain zero.$0.000charges.Priority
High: affects the main workflow
Additional Context
The key distinction is that these models use non-token billing. Displaying a billing label is useful, but it does not solve request-level accounting or aggregate cost reporting.
Checklist