Skip to content

Migrate money surfaces from karma to credits (content-server #2086 / W5.3) #11

Description

@baoinf

Tracks the SDK-side migration for content-server #2086 (W5.3).

Context

content-server #2086 changes every agent-facing REST response and usage header to present money as USD-denominated credits instead of karma, using the canonical rate 1 credit = $1.00 = 1,000 karma (credits = karma / 1000, 4dp).

Per the decision on that issue, this is a replace, not additive change: the karma_* fields and X-*-Karma-* headers are removed and replaced with credit equivalents — there is no one-release deprecation window. That makes it a breaking change for this SDK, which is why it needs its own tracked migration that lands after content-server #2086 deploys.

Two things change on the wire:

  1. Field/header renameskarma_*credits_* (e.g. karma_chargedcredits_charged, karma_costcredits_cost, amount_karmaamount_credits, estimated_karma_costestimated_credits_cost); currency on the credits endpoint becomes "credits"; headers X-Karma-Used/BalanceX-Credits-Used/Balance and X-Deva-Karma-Cost/BalanceX-Deva-Credits-Cost/Balance.
  2. Magnitude + type change — every money value shrinks by a factor of 1,000 and goes from an integer karma count to a 4dp credit decimal (e.g. balance 10001.0000, a 58-karma image cost → 0.0580).

Internal karma logic on the server (charging, buckets, ledger, emission) is unchanged — only the presented unit changes.

SDK touch-points to update

Audit of src/ against the credits-only surface:

  • src/types.ts:149 — chat usage object deva?: { karma_cost; karma_balance }{ credits_cost; credits_balance }; update any header parsing that reads X-Deva-Karma-Cost / X-Deva-Karma-Balance to the X-Deva-Credits-* names.
  • src/resources/wallet.ts:5WalletBalance.karma?: number → credits (decimal); revisit available / pending if they are karma-denominated.
  • src/resources/models.ts:6-9prompt_karma / completion_karma per-token pricing and currency — confirm whether these are sourced from a content-server surface in scope of #2086; migrate to credit-denominated pricing if so.
  • src/errors.ts:45 — "Out of karma / quota" comment; reword to credits (cosmetic).
  • Sweep examples/ and README.md for karma-denominated numbers and 1000 karma = $1 framing; restate as credits.
  • Bump SDK version and note the breaking change in the changelog once content-server #2086 is live.

Coordination

  • Land and release after content-server #2086 is deployed to production (the wire format flips at that point).
  • No dual-read/back-compat path is needed on the server side, so pin the minimum server version this SDK release targets.

Out of scope

  • Any change to how karma is charged or accounted on the server (unchanged — presentation only).
  • Deva-social user-facing karma.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions