Skip to content

OpenRouter's BYOK billing rule lives in Imp.Core #265

Closed

Description

@deepfates

Imp.Core.reported_cost/2 knows about OpenRouter's bring-your-own-key (BYOK) billing: when usage["is_byok"] is true, it adds cost_details.upstream_inference_cost to "cost". That's a single provider's billing rule sitting in Imp's provider-neutral core. It belongs with the OpenRouter-specific code, in Imp.Clients.ReqLLM, or in ReqLLM's OpenRouter provider if that's where usage gets normalised. Core should then read one provider-neutral charge.

Done when core has no provider names in it, the BYOK behaviour is unchanged (the existing tests pass), and those tests live beside the OpenRouter-specific code.

Activity

  1. deepfates commented on Oct 8, 2026

    @deepfates
    OwnerAuthor

    Triage, 2026-10-08: still open. The BYOK rule is still in Imp.Core.reported_cost/2 (lib/imp/core.ex:305-310) on main (b736d00).

  2. mvanhorn commented on Oct 8, 2026

    @mvanhorn
    Contributor

    Imp.Core.reported_cost/2 matched usage with "is_byok" and added "cost" to cost_details.upstream_inference_cost. The OpenRouter field names and the fee-plus-upstream rule sat in the provider-neutral cost reader instead of with the client that sees OpenRouter usage.

    Imp.Clients.ReqLLM.resolve_openrouter_charge/2 now resolves a charge only for an OpenRouter model whose usage has "is_byok": the fee plus upstream_inference_cost when both are numbers, otherwise nil.

  3. deepfates commented on Oct 8, 2026

    @deepfates
    OwnerAuthor

    Status, 2026-10-08: #303 is open for this. Its checks have not run, as a first-time contributor's run needs approval, and it has no review. Moved to In review.

  4. added a commit that references this issue on Oct 17, 2026
    a49f7c2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions