MCPcopy Create free account
hub / github.com/anomalyco/opencode / cost

Function cost

packages/opencode/src/provider/provider.ts:1155–1186  ·  view source on GitHub ↗
(c: ModelsDev.Model["cost"])

Source from the content-addressed store, hash-verified

1153export const use = serviceUse(Service)
1154
1155function cost(c: ModelsDev.Model["cost"]): Model["cost"] {
1156 const result: Model["cost"] = {
1157 input: c?.input ?? 0,
1158 output: c?.output ?? 0,
1159 cache: {
1160 read: c?.cache_read ?? 0,
1161 write: c?.cache_write ?? 0,
1162 },
1163 }
1164 if (c?.tiers) {
1165 result.tiers = c.tiers.map((item) => ({
1166 input: item.input,
1167 output: item.output,
1168 cache: {
1169 read: item.cache_read ?? 0,
1170 write: item.cache_write ?? 0,
1171 },
1172 tier: item.tier,
1173 }))
1174 }
1175 if (c?.context_over_200k) {
1176 result.experimentalOver200K = {
1177 cache: {
1178 read: c.context_over_200k.cache_read ?? 0,
1179 write: c.context_over_200k.cache_write ?? 0,
1180 },
1181 input: c.context_over_200k.input,
1182 output: c.context_over_200k.output,
1183 }
1184 }
1185 return result
1186}
1187
1188function fromModelsDevModel(provider: ModelsDev.Provider, model: ModelsDev.Model): Model {
1189 const base: Model = {

Callers 2

fromModelsDevModelFunction · 0.70
fromModelsDevProviderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected