[PR #11599] feat(opencode): cost calculation according to service_tier (OpenAI) #13858

Open
opened 2026-02-16 18:18:41 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11599

State: open
Merged: No


What does this PR do?

Allows to set (override) detailed prices for models by service_tier. It helps to calculate price by reading service_tier from result.

How to verify:

Example of config for get-5.2:

"provider": {
        "openai": {
            "models": {
                "gpt-5.2": {
                    "options": {
                        "serviceTier": "flex"
                    },
                    "cost": {
                        "input": 1.75,
                        "output": 14.00,
                        "cache_read": 0.175,
                        "service_tier": {
                            "default": {
                                "input": 1.75,
                                "output": 14.00,
                                "cache_read": 0.175,
                            },
                            "flex": {
                                "input": 0.875,
                                "output": 7.00,
                                "cache_read": 0.0875,
                            },
                            "priority": {
                                "input": 3.50,
                                "output": 28.00,
                                "cache_read": 0.35,
                            },
                        },
                    }
                }
            }
        },
        ...
  • Try to run model via OpenAI and take a look at logs and actual price in OpenAI

Notes

models.dev is not providing the prices for tiers now but if it will be added from theirs side it will be possible to start reading values in the future

Closes #11597 and maybe #Closes #7511

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11599 **State:** open **Merged:** No --- ### What does this PR do? Allows to set (override) detailed prices for models by service_tier. It helps to calculate price by reading service_tier from result. ### How to verify: Example of config for get-5.2: ``` "provider": { "openai": { "models": { "gpt-5.2": { "options": { "serviceTier": "flex" }, "cost": { "input": 1.75, "output": 14.00, "cache_read": 0.175, "service_tier": { "default": { "input": 1.75, "output": 14.00, "cache_read": 0.175, }, "flex": { "input": 0.875, "output": 7.00, "cache_read": 0.0875, }, "priority": { "input": 3.50, "output": 28.00, "cache_read": 0.35, }, }, } } } }, ... ``` * Try to run model via OpenAI and take a look at logs and actual price in OpenAI ### Notes models.dev is not providing the prices for tiers now but if it will be added from theirs side it will be possible to start reading values in the future Closes #11597 and maybe #Closes #7511
yindo added the pull-request label 2026-02-16 18:18:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13858