Cost Usage Calculation
Unfortunately, depending on the service, this information can not only be retrieved; AI Engine will then guess the tokens usage and price.
Services
Hosting Service | Streaming | Tokens Usage | Price Usage | Notes |
OpenAI (+ Azure) | No | ❤️ Returned by OpenAI | ❤️ Calculated by AI Engine | |
OpenAI (+ Azure) | Yes | ❤️ Returned by OpenAI | ❤️ Calculated by AI Engine | |
OpenRouter | No | ❤️ Returned by OpenRouter | ❤️ Returned by OpenRouter | |
OpenRouter | Yes | ❤️ Returned by OpenRouter | ❤️ Returned by OpenRouter | An extra request is made to retrieve the tokens/price. |
Anthropic (Claude) | Any | ❤️ Returned by OpenRouter | ❤️ Calculated by AI Engine | |
Google | Any | ⚠️ Guessed by AI Engine | ❌ None | |
⚠️ Tokens: Guessed by AI Engine
This is done through the estimate_tokens function in the core. In fact, the implementation of each model could do it differently, but there is currently no way to know how each service actually calculate those tokens (since they depend on how the messages are actually formatted, how the images are counted, etc). This is highly inaccurate. If you depend on this, use something else.
Did this answer your question?
😞
😐
🤩