You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you pass a provider, RubyLLM resolves aliases first. For Bedrock, it then applies region/inference-profile resolution (for example `us.` prefixes) before falling back to an exact ID match.
208
210
211
+
## Calculating Costs
212
+
{: .d-inline-block }
213
+
214
+
v1.15+
215
+
{: .label .label-green }
216
+
217
+
Models can turn token usage into a `RubyLLM::Cost` object:
218
+
219
+
```ruby
220
+
model =RubyLLM.models.find('{{ site.models.default_chat }}')
Costs use RubyLLM's normalized token buckets: standard input, billable output, cache read, cache write, and separately priced thinking when the model registry exposes a distinct reasoning-token price. See [Tracking Token Usage]({% link _core_features/chat.md %}#tracking-token-usage) for the provider comparison table and what RubyLLM exposes consistently across providers.
233
+
234
+
Most applications use the shorter helpers on messages, chats, and agents:
235
+
236
+
```ruby
237
+
response.cost.total
238
+
chat.cost.total
239
+
agent.cost.total
240
+
```
241
+
242
+
To combine several cost objects yourself, use `RubyLLM::Cost.aggregate`:
If pricing is incomplete for tokens that were used, the affected cost and `cost.total` return `nil`. Cost helpers cover token-priced conversation usage; provider-specific add-ons such as search-query charges remain available in the provider's raw usage payload.
250
+
209
251
## Connecting to Custom Endpoints & Using Unlisted Models
0 commit comments