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
Copy file name to clipboardExpand all lines: docs/05_bring_your_own_model_provider.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,6 +135,46 @@ class MyImageQAProvider(ImageQAProvider):
135
135
```
136
136
137
137
138
+
### Execution Cost Tracking
139
+
140
+
The built-in VLM providers include default pricing for supported models. You can override the pricing on any provider by passing `input_cost_per_million_tokens` and `output_cost_per_million_tokens`:
141
+
142
+
```python
143
+
from askui import AgentSettings, ComputerAgent
144
+
from askui.model_providers import AnthropicVlmProvider
145
+
from askui.reporting import SimpleHtmlReporter
146
+
147
+
with ComputerAgent(
148
+
reporters=[SimpleHtmlReporter()],
149
+
settings=AgentSettings(
150
+
vlm_provider=AnthropicVlmProvider(
151
+
model_id="claude-sonnet-4-6",
152
+
input_cost_per_million_tokens=3.0,
153
+
output_cost_per_million_tokens=15.0,
154
+
),
155
+
),
156
+
) as agent:
157
+
agent.act("Open settings")
158
+
```
159
+
160
+
If you implement a fully custom `VlmProvider`, override the `pricing` property to enable cost tracking:
161
+
162
+
```python
163
+
from askui.model_providers import VlmProvider, ModelPricing
164
+
165
+
classMyVlmProvider(VlmProvider):
166
+
@property
167
+
defpricing(self) -> ModelPricing |None:
168
+
return ModelPricing(
169
+
input_cost_per_million_tokens=1.0,
170
+
output_cost_per_million_tokens=5.0,
171
+
)
172
+
173
+
# ... rest of implementation
174
+
```
175
+
176
+
---
177
+
138
178
## Advanced: Injecting a Custom Client
139
179
140
180
For full control over HTTP settings (timeouts, proxies, retries), you can inject a pre-configured client:
The HTML report automatically shows the estimated API cost when using a `VlmProvider` with pricing information. The built-in Anthropic and AskUI providers include default pricing for supported Claude models.
38
+
39
+
The report will display:
40
+
- Total estimated cost
41
+
- Per-token rates used for the calculation
42
+
- Input and output token breakdowns (as before)
43
+
35
44
### Custom Reporters
36
45
37
46
Create custom reporters by implementing the `Reporter` interface:
0 commit comments