Skip to content

[FEATURE]: Support explicit cost tiers for custom provider models #50713

Open

Description

@richardsun0713

Feature has not been suggested before.

Describe the enhancement you want to request

Custom provider models cannot configure arbitrary context-pricing tiers. This prevents exact local cost estimates for OpenAI-compatible gateways that charge a long-context rate above 272K input tokens.

OpenCode runtime cost models support arbitrary context tiers, but custom models in opencode.json expose only the legacy context_over_200k field.

Allow provider.*.models.*.cost.tiers in config, using the existing internal and models.dev shape:

{
  "cost": {
    "input": 2,
    "output": 10,
    "cache_read": 0.2,
    "cache_write": 2.5,
    "tiers": [
      {
        "tier": { "type": "context", "size": 272000 },
        "input": 4,
        "output": 15,
        "cache_read": 0.4,
        "cache_write": 5
      }
    ]
  }
}

Expected behavior:

  1. Configured tiers are accepted and included in a custom model cost definition.
  2. A configured tier replaces a catalog tier with the same type and size.
  3. Unrelated catalog tiers are preserved.
  4. Cost estimation uses the base rate at or below 272K tokens and the configured tier above it.

This complements #44223 and #44292, which address runtime handling of catalog tiers but intentionally do not add arbitrary tiers to custom configuration.

Activity

  1. github-actions commented on Sep 22, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Feature requests should use the feature request template, which requires a title starting with [FEATURE]: and a verification checkbox confirming you've searched for existing issues
    • Please resubmit or edit this issue using the feature request template

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. changed the title [-]Support explicit cost tiers for custom provider models[/-] [+][FEATURE]: Support explicit cost tiers for custom provider models[/+] on Sep 22, 2026
  3. github-actions commented on Sep 22, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now follows the contributing guidelines. We'll take a look.

  4. EncodedBird commented on Oct 11, 2026

    @EncodedBird

    I just want to add we have numerous public examples now of where the price tier split is needed. Claude 5.5 haiku has a price tier cutoff of 100k tokens. Grok has a cutoff of 200k tokens for its price tier. In order to have accurate prices, there needs to be a way to set cost tiers.

  5. henrikdukefoss commented on Oct 13, 2026

    @henrikdukefoss

    Some data on how often a tier boundary is actually crossed in agent traffic, which bears on how much a missing tiers field skews the estimate:

    Across 79,276 coding-agent requests (OpenCode, Cline, Roo, Kilo, Aider, Continue, Zed and others) on one OpenAI-compatible gateway, 2026-09-13 to 2026-10-12, input tokens per request (cache reads included) were:

    • median 99.6K, p90 280K, p99 533K
    • 49.7% of requests over 100K, the Haiku 5.5 cutoff mentioned above
    • 10.7% of requests over 272K, the GPT-6 Luna cutoff

    So with only context_over_200k available, a model with a 272K or 100K boundary gets the wrong rate on roughly 1 in 10 (or 1 in 2) requests in a long session. Those are the most expensive requests, so the error in a session total is larger than the request share suggests. One more thing worth handling: 87% of those input tokens were cache reads, so the tier needs its own cache_read rate. The proposed shape in the issue already allows that.

    Disclosure: the numbers come from the gateway I run (Standard Compute). The aggregate method and data file are public: https://standardcompute.com/agent-burn-index (JSON at /agent-burn-index/data.json).

  6. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed request! You'd like custom provider models in opencode.json to set arbitrary context-pricing tiers (for example a long-context rate above 272K tokens), merged per tier with catalog tiers. Maintainers will consider it.

    In the meantime, if you're on OpenCode v2 (opencode --version shows 2.x), v2's own config format already accepts arbitrary tiers. There, cost can be a list, and each entry can have a tier:

    {
      "provider": {
        "my-gateway": {
          "models": {
            "my-model": {
              "cost": [
                { "input": 2, "output": 10, "cache": { "read": 0.2, "write": 2.5 } },
                {
                  "tier": { "type": "context", "size": 272000 },
                  "input": 4, "output": 15,
                  "cache": { "read": 0.4, "write": 5 }
                }
              ]
            }
          }
        }
      }
    }

    Note that a configured cost currently replaces the model's whole cost list rather than merging with catalog tiers one by one, so include every tier you need. The legacy snake_case shape (cache_read, context_over_200k) is still limited to the 200K tier.

    Related (all closed; they fixed how v1 picks catalog tiers when estimating cost):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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