Skip to content

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

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

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