#Get total cost via API?

5 messages · Page 1 of 1 (latest)

gilded mica
#

Hi there, I'm using the openrouter API (with gemini 2.5 pro) along with the mistral ocr file-parser plugin.

In the response I have information about used token, however this does not resemble the total cost because the mistral usage cost is not included (or is it? e.g. 0.01 USD per parsed page).

There is information available:
https://openrouter.ai/api/v1/generation?id=gen-...

{
"data": {
"created_at": "2025-08-14T06:58:28.513503+00:00",
"model": "google/gemini-2.5-flash",
"app_id": null,
"external_user": null,
"streamed": true,
"cancelled": false,
"latency": 258,
"moderation_latency": null,
"generation_time": 1823,
"tokens_prompt": 2087,
"tokens_completion": 361,
"native_tokens_prompt": 2227,
"native_tokens_completion": 457,
"native_tokens_reasoning": 0,
"native_tokens_cached": 0,
"num_media_prompt": null,
"num_media_completion": null,
"num_search_results": null,
"origin": "https://localhost:3000/",
"is_byok": false,
"finish_reason": "stop",
"native_finish_reason": "STOP",
"usage": 0.0078106,
"api_type": "completions",
"id": "gen-1755154704-zmSG0GZzbGN2pkVbx0U5",
"upstream_id": null,
"total_cost": 0.0078106,
"cache_discount": null,
"upstream_inference_cost": 0,
"provider_name": "Google"
}
}

But I can't access this because it seems to not be an official endpoint and I can't authenticate with my API key.

Is there a way to get the total cost for one run?
Thank you!

Best,
Jooles

dire pastureBOT
#

I'm an AI assistant - my answers may be incorrect and I cannot see screenshots. Please verify information with the OpenRouter docs.

There is no public API endpoint that provides a "total cost" for a single run including third-party plugin (like Mistral OCR) parsing costs. Here’s what is supported:

  • You can get usage info (tokens, model cost) for the core model in the API response by adding usage: {include: true} to your request. This will not include plugin costs like Mistral OCR parsing OpenRouter FAQ:

    "You can also add the usage: {include: true} parameter to your chat request to get the usage information in the response."

  • Pricing for Mistral OCR and other file-parser engines is fixed and documented:

    '"mistral-ocr": Best for scanned documents or PDFs with images ($2 per 1,000 pages).'
    PDF Inputs Guide

  • The API does not return the plugin (Mistral OCR) cost in the response—you must calculate this manually based on the number of pages parsed and the fixed price.

To estimate total cost for a run:

  1. Take the model inference cost from the usage section of the API response.
  2. Manually add the plugin cost (e.g., $0.002 per page for Mistral OCR).
  3. There is no supported authenticated endpoint to retrieve the sum via API. To review all usage (model + plugin), use the Activity tab.

If you need programmatic cost aggregation for both LLM and parser plugin, you’ll have to track page counts and calculate based on pricing. For more details, see the PDF Inputs Guide and OpenRouter FAQ.

If you need official cost informa...

OpenRouter

A router for LLMs and other AI models

OpenRouter

A router for LLMs and other AI models

#

...tion or API feature, please contact the mods or OpenRouter support.

-# This is an automated response powered by Answer HQ. Use !mute to stop the bot from responding.

gilded mica
#

!mute

dire pastureBOT
#

🔇 Thread muted. The bot will no longer respond here.