Skip to content

feat(types): expose USD cost/tier fields on CreditUsage - #202

Open
jeremyipark wants to merge 2 commits into
mainfrom
devin/1783984844-usage-cost-dollars
Open

feat(types): expose USD cost/tier fields on CreditUsage#202
jeremyipark wants to merge 2 commits into
mainfrom
devin/1783984844-usage-cost-dollars

Conversation

@jeremyipark

@jeremyipark jeremyipark commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

The VLM Run API returns per-request USD cost + service-tier info inside the usage object of prediction/execution responses (CreditUsageResponse in vlm-lab, populated in vlm/infra/cloud/billing/usage.py), but the SDK's CreditUsage model only declared the credit fields — so Pydantic silently dropped the dollar fields and response.usage.cost_dollars was inaccessible.

This adds the 5 wire fields to CreditUsage so they round-trip:

 class CreditUsage(BaseModel):
     elements_processed: Optional[int] = None
     element_type: Optional[Literal["image", "page", "video", "audio"]] = None
     credits_used: Optional[int] = None
     steps: Optional[int] = None
     message: Optional[str] = None
     duration_seconds: int = 0
+    service_tier: Optional[str] = None
+    mode_multiplier: Optional[float] = None
+    standard_cost_dollars: Optional[float] = None
+    cost_dollars: Optional[float] = None
+    savings_dollars: Optional[float] = None

These mirror exactly the non-excluded fields of the API's CreditUsageResponse. The API's input_tokens / output_tokens / credit_cost_dollars are intentionally not added — they are exclude=True on the server (internal-only, not on the wire).

Applies to both PredictionResponse.usage and AgentExecutionResponse.usage (both typed as CreditUsage).

resp = client.image.generate(domain="document.invoice", urls=[...])
resp.usage.cost_dollars      # effective USD charged
resp.usage.standard_cost_dollars
resp.usage.savings_dollars   # discount on flex tier
resp.usage.service_tier      # "standard" | "flex" | "priority"

Test plan

  • Added tests in tests/test_predictions.py covering parse-from-payload, default-None, and PredictionResponse round-trip of the new fields.
  • pytest tests/test_predictions.py tests/test_agent.py → 79 passed.
  • pre-commit run (ruff + black) → passed.

Companion Node SDK PR: vlm-run/vlmrun-node-sdk (same fields on the CreditUsage interface).

Link to Devin session: https://app.devin.ai/sessions/af66c3426c7f41188105bcaff4defc1b
Requested by: @jeremyipark


Open in Devin Review

Co-Authored-By: jeremy <jeremyparkphd@gmail.com>
@jeremyipark jeremyipark self-assigned this Jul 13, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds several optional fields (service_tier, mode_multiplier, standard_cost_dollars, cost_dollars, and savings_dollars) to the CreditUsage model in vlmrun/client/types.py to support new API payload fields. It also adds corresponding unit tests in tests/test_predictions.py to verify parsing, default values, and round-tripping within PredictionResponse. There are no review comments, and the changes look correct and well-tested.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread vlmrun/client/types.py Outdated
@dineshreddy91
dineshreddy91 self-requested a review July 14, 2026 00:31
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants