Compare commits

...

21 Commits

Author SHA1 Message Date
Dax 63a883a4f7 refactor(console): stream zen bodies without modifiers (#44472) 2026-08-23 13:14:18 -04:00
Dax b3bad6b581 fix(console): revert scanned zen request streaming (#44470) 2026-08-23 13:03:20 -04:00
opencode-agent[bot] ca10088bdf chore: generate 2026-08-23 16:51:36 +00:00
Dax dd3f915956 fix(console): release streamed zen prefixes (#44465) 2026-08-23 12:50:18 -04:00
opencode-agent[bot] c11c41bd86 chore: generate 2026-08-23 16:48:45 +00:00
Dax fa117558ee fix(console): scan zen model before streaming (#44463) 2026-08-23 12:47:29 -04:00
Frank 17b47301ba feat(console): add unblock workspace action 2026-08-23 12:46:02 -04:00
Dax 3d31e4bcec fix(console): revert streamed zen request bodies (#44444) 2026-08-23 11:54:07 -04:00
opencode-agent[bot] bb72277407 chore: generate 2026-08-23 15:19:54 +00:00
Dax 32c3637da0 fix(console): stream zen request bodies (#44429) 2026-08-23 11:18:38 -04:00
Dax Raad 9d466cd849 fix(stats): normalize model casing 2026-08-23 10:33:11 -04:00
opencode-agent[bot] e3bd6e0947 chore: generate 2026-08-23 14:00:45 +00:00
Dax dc13c6bb3d fix(console): reduce zen request memory (#44403) 2026-08-23 09:59:29 -04:00
Brendan Allan 3a31c4ea80 fix(app): keep model provider headers visible (#44115) 2026-08-22 20:50:02 +08:00
Kit Langton e00890c672 fix: resolve console device URLs (#44029) 2026-08-22 00:25:56 +00:00
joelstucki-taulia 3a4c253969 fix(provider): guard textVerbosity injection for @ai-sdk/openai-compatible providers (#43915)
Co-authored-by: Joel Stucki <joel.stucki@example.com>
2026-08-21 22:19:33 +00:00
Adam 34a83b27c3 fix(stats): improve chart tooltip truncation 2026-08-21 17:13:13 -05:00
opencode-agent[bot] ff3ef6e3e6 chore: update nix node_modules hashes 2026-08-21 21:54:44 +00:00
opencode-agent[bot] e2ec62d073 fix: bump Amazon Bedrock provider (#43909)
Co-authored-by: neriousy <34747899+neriousy@users.noreply.github.com>
2026-08-21 23:39:17 +02:00
opencode-agent[bot] bcf1103a8c docs(zen): update GPT 5.6 Sol pricing (#43986)
Co-authored-by: Slickstef11 <98915060+Slickstef11@users.noreply.github.com>
2026-08-21 17:00:03 -04:00
Dax Raad 9cb6fb6529 fix(console): cache desktop downloads 2026-08-21 16:58:52 -04:00
41 changed files with 620 additions and 191 deletions
+9 -7
View File
@@ -293,7 +293,7 @@
},
"dependencies": {
"@ai-sdk/alibaba": "1.0.17",
"@ai-sdk/amazon-bedrock": "4.0.112",
"@ai-sdk/amazon-bedrock": "4.0.158",
"@ai-sdk/anthropic": "3.0.82",
"@ai-sdk/azure": "3.0.88",
"@ai-sdk/cerebras": "2.0.41",
@@ -568,7 +568,7 @@
"@actions/github": "6.0.1",
"@agentclientprotocol/sdk": "0.21.0",
"@ai-sdk/alibaba": "1.0.17",
"@ai-sdk/amazon-bedrock": "4.0.112",
"@ai-sdk/amazon-bedrock": "4.0.158",
"@ai-sdk/anthropic": "3.0.82",
"@ai-sdk/azure": "3.0.88",
"@ai-sdk/cerebras": "2.0.60",
@@ -1173,7 +1173,7 @@
"@ai-sdk/alibaba": ["@ai-sdk/alibaba@1.0.17", "", { "dependencies": { "@ai-sdk/openai-compatible": "2.0.41", "@ai-sdk/provider": "3.0.8", "@ai-sdk/provider-utils": "4.0.23" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-ZbE+U5bWz2JBc5DERLowx5+TKbjGBE93LqKZAWvuEn7HOSQMraxFMZuc0ST335QZJAyfBOzh7m1mPQ+y7EaaoA=="],
"@ai-sdk/amazon-bedrock": ["@ai-sdk/amazon-bedrock@4.0.112", "", { "dependencies": { "@ai-sdk/anthropic": "3.0.81", "@ai-sdk/openai": "3.0.67", "@ai-sdk/provider": "3.0.10", "@ai-sdk/provider-utils": "4.0.27", "@smithy/eventstream-codec": "^4.0.1", "@smithy/util-utf8": "^4.0.0", "aws4fetch": "^1.0.20" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-PsSh7a6qW+3kQXPs1kD4wDwuZby0t1PIaB6j/1aMKmPFJ5LxcIcULLMF/bjITLt5o/8lc0t6TXIwG0zlhH7uZw=="],
"@ai-sdk/amazon-bedrock": ["@ai-sdk/amazon-bedrock@4.0.158", "", { "dependencies": { "@ai-sdk/anthropic": "3.0.111", "@ai-sdk/openai": "3.0.98", "@ai-sdk/provider": "3.0.15", "@ai-sdk/provider-utils": "4.0.46", "@smithy/eventstream-codec": "^4.0.1", "@smithy/util-utf8": "^4.0.0", "aws4fetch": "^1.0.20" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-yZebHEszUzPLsK+Rq5sVZJkJj7EYDgY+Lz36IGf/RSkSC5LOMDbVKoQ55S8xNzJqVjUDqlWuZiQzg40HQslmCw=="],
"@ai-sdk/anthropic": ["@ai-sdk/anthropic@3.0.82", "", { "dependencies": { "@ai-sdk/provider": "3.0.10", "@ai-sdk/provider-utils": "4.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-WKKou2wbhGGYV8PSALAPyV2YY4nfCqCPkyBzYtJtDA9yCcIFwsbtkTNgg7bqtLCVzeEsY7wwxRoCWy+EMfrw/A=="],
@@ -5641,13 +5641,13 @@
"@ai-sdk/alibaba/@ai-sdk/openai-compatible": ["@ai-sdk/openai-compatible@2.0.41", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@ai-sdk/provider-utils": "4.0.23" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-kNAGINk71AlOXx10Dq/PXw4t/9XjdK8uxfpVElRwtSFMdeSiLVt58p9TPx4/FJD+hxZuVhvxYj9r42osxWq79g=="],
"@ai-sdk/amazon-bedrock/@ai-sdk/anthropic": ["@ai-sdk/anthropic@3.0.81", "", { "dependencies": { "@ai-sdk/provider": "3.0.10", "@ai-sdk/provider-utils": "4.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-B1JDd9Ugq9R5AgIaW3674lhGCMMYJcPUxnrZh8fzbGojgg4QvHFRv6eZahGQAUsmGHbcf74G9bdSBDLWQGY2GA=="],
"@ai-sdk/amazon-bedrock/@ai-sdk/anthropic": ["@ai-sdk/anthropic@3.0.111", "", { "dependencies": { "@ai-sdk/provider": "3.0.15", "@ai-sdk/provider-utils": "4.0.46" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-atgBW8jZPr/KuaKX5FvDIHuXBI8VCol6kVeoD4P0657+VXR73QsLogXQVN/Zt5FHtq9WzpdIZseCJiXPqkgwwA=="],
"@ai-sdk/amazon-bedrock/@ai-sdk/openai": ["@ai-sdk/openai@3.0.67", "", { "dependencies": { "@ai-sdk/provider": "3.0.10", "@ai-sdk/provider-utils": "4.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-oAiGC9eWG7IgtdsdS74bOCnAAHarAfTJhWN9x5INwnWPekL802AvF+0I5DvLzIF1MIRmNw4N8mPSL/GUVbX9Mw=="],
"@ai-sdk/amazon-bedrock/@ai-sdk/openai": ["@ai-sdk/openai@3.0.98", "", { "dependencies": { "@ai-sdk/provider": "3.0.15", "@ai-sdk/provider-utils": "4.0.46" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-nAvp8pVOUJ3znJHRzZs54Y7CJQSikOW1Ty7LTdtQT+/pgtAwqhuKd8oaXbiW2xQaYBdH2i8o9AcEpcUdXIyF+g=="],
"@ai-sdk/amazon-bedrock/@ai-sdk/provider": ["@ai-sdk/provider@3.0.10", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-Q3BZ27qfpYqnCYGvE3vt+Qi6LGOF9R5Nmzn+9JoM1lCRsD9mYaIhfJLkSunN48nfGXJ6n+XNV0J/XVpqGQl7Dw=="],
"@ai-sdk/amazon-bedrock/@ai-sdk/provider": ["@ai-sdk/provider@3.0.15", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-XeZW1CcDF2GMbH4wejW6xBRI2QCOgnkVYUnxoeDadB1mf85riL2bMUeDoh+6gJ/r4mjNfzUPW8OjLjvwTP0u1Q=="],
"@ai-sdk/amazon-bedrock/@ai-sdk/provider-utils": ["@ai-sdk/provider-utils@4.0.27", "", { "dependencies": { "@ai-sdk/provider": "3.0.10", "@standard-schema/spec": "^1.1.0", "eventsource-parser": "^3.0.8" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-ubkAJ+xODouwtmN1tYlvTPphH1hPOBfZaEQe8U7skGvFAnIRs9PPpsq57bC2+Ky/MB4yzhd6YOsxTAx9sGpazw=="],
"@ai-sdk/amazon-bedrock/@ai-sdk/provider-utils": ["@ai-sdk/provider-utils@4.0.46", "", { "dependencies": { "@ai-sdk/provider": "3.0.15", "@standard-schema/spec": "^1.1.0", "eventsource-parser": "^3.0.8", "undici": "^6.28.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-tEtld97plCFiYevsJuOkGkeuhQndeMWFBVrJS4AjnbD5AqrNSXRCe0p+BZ3Cju/sxDeeZ9ym3q9YUV8fASA7aQ=="],
"@ai-sdk/amazon-bedrock/@smithy/eventstream-codec": ["@smithy/eventstream-codec@4.2.14", "", { "dependencies": { "@aws-crypto/crc32": "5.2.0", "@smithy/types": "^4.14.1", "@smithy/util-hex-encoding": "^4.2.2", "tslib": "^2.6.2" } }, "sha512-erZq0nOIpzfeZdCyzZjdJb4nVSKLUmSkaQUVkRGQTXs30gyUGeKnrYEg+Xe1W5gE3aReS7IgsvANwVPxSzY6Pw=="],
@@ -6589,6 +6589,8 @@
"@ai-sdk/amazon-bedrock/@ai-sdk/provider-utils/@standard-schema/spec": ["@standard-schema/spec@1.1.0", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
"@ai-sdk/amazon-bedrock/@ai-sdk/provider-utils/undici": ["undici@6.28.0", "", {}, "sha512-LIY910g9TI13YS95lrMFrs8Rm/u/irgHeTWoKCoteeJ04CUJ92eEfj0rVn+7VKMPBpUPiUoBKfhNyLI23EE/KA=="],
"@ai-sdk/anthropic/@ai-sdk/provider-utils/@standard-schema/spec": ["@standard-schema/spec@1.1.0", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
"@ai-sdk/azure/@ai-sdk/provider-utils/@standard-schema/spec": ["@standard-schema/spec@1.1.0", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
+4 -4
View File
@@ -1,8 +1,8 @@
{
"nodeModules": {
"x86_64-linux": "sha256-yQ8EIxxYkzlEWIMY/UiIR+7lbGBuizsoehMPZzFA65Y=",
"aarch64-linux": "sha256-JF9VVgnl5QUZ430fqb5Qu8y0kchYJ00LO3FbYcd0lBM=",
"aarch64-darwin": "sha256-f3Tu6eu463NWcHgr7dupfD/zUTh26bJ6N2vVXuEyi6c=",
"x86_64-darwin": "sha256-miv9Sv4KdhD0UIi2O5LVS1wQOfq29IV+9S+BvIzAvgo="
"x86_64-linux": "sha256-Be1I6OG6UitofhcGu2BeNzevmoQXc4Or5r/NPzwtft4=",
"aarch64-linux": "sha256-O+d+26CQIjZ08Rn8Qm3IytdDqIMbPdhzaGOZeUKAvIU=",
"aarch64-darwin": "sha256-ObS50y/oy6fM9wSGUL/wx6O0+fTWHC04mXJNd7w/2Z0=",
"x86_64-darwin": "sha256-eoR7ZSyH62Fq2ZaW2b2QqU2FC97rYxTMeEe+djT0nto="
}
}
@@ -450,7 +450,7 @@ function ModelSelectorPopoverV2View(props: {
<For each={groups()}>
{(group) => (
<MenuV2.Group>
<MenuV2.GroupLabel class="gap-2 px-3">
<MenuV2.GroupLabel class="sticky top-0 z-10 gap-2 bg-v2-background-bg-layer-01 px-3">
<span class="min-w-0 truncate">{group.items[0].provider.name}</span>
</MenuV2.GroupLabel>
<MenuV2.RadioGroup value={props.current()}>
@@ -0,0 +1,21 @@
import type { APIEvent } from "@solidjs/start/server"
import { Workspace } from "@opencode-ai/console-core/workspace.js"
import { safeEqual } from "@opencode-ai/console-core/util/crypto.js"
import { Resource } from "@opencode-ai/console-resource"
import z from "zod"
const Body = z.object({ workspaceID: z.string().startsWith("wrk_") })
export async function POST(event: APIEvent) {
if (!safeEqual(event.request.headers.get("authorization") ?? "", `Bearer ${Resource.SUPPORT_API_KEY.value}`)) {
return Response.json({ error: "Unauthorized" }, { status: 401 })
}
const body = Body.safeParse(await event.request.json().catch(() => undefined))
if (!body.success) {
return Response.json({ error: "Invalid request", issues: body.error.issues }, { status: 400 })
}
return Workspace.unblock(body.data)
.then(() => Response.json({ success: true, message: "Workspace unblocked" }))
.catch((error) => Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 }))
}
@@ -1,4 +1,5 @@
import type { APIEvent } from "@solidjs/start"
import { waitUntil } from "@opencode-ai/console-resource"
import type { DownloadPlatform } from "../types"
const prodAssetNames: Record<string, string> = {
@@ -30,14 +31,34 @@ export async function GET({ params: { platform, channel } }: APIEvent) {
const assetName = channel === "stable" ? prodAssetNames[platform] : betaAssetNames[platform]
if (!assetName) return new Response(null, { status: 404 })
const resp = await fetch(
const latest = await fetch(
`https://github.com/anomalyco/${channel === "stable" ? "opencode" : "opencode-beta"}/releases/latest/download/${assetName}`,
{ redirect: "manual" },
)
const location = latest.headers.get("location")
if (!location) return new Response(null, { status: 502 })
const downloadName = downloadNames[platform]
const key = new Request(location)
const cache = (caches as CacheStorage & { default: Cache }).default
const cached = await cache.match(key)
if (cached) return download(cached, platform, "HIT")
const resp = await fetch(location)
if (!resp.ok) return resp
const headers = new Headers(resp.headers)
headers.set("cache-control", "public, max-age=31536000, immutable")
headers.delete("set-cookie")
const result = new Response(resp.body, { status: resp.status, statusText: resp.statusText, headers })
waitUntil(cache.put(key, result.clone()))
return download(result, platform, "MISS")
}
function download(resp: Response, platform: string, cache: "HIT" | "MISS") {
const downloadName = downloadNames[platform]
const headers = new Headers(resp.headers)
if (downloadName) headers.set("content-disposition", `attachment; filename="${downloadName}"`)
headers.set("x-opencode-cache", cache)
return new Response(resp.body, { status: resp.status, statusText: resp.statusText, headers })
}
@@ -30,7 +30,6 @@ import {
} from "./error"
import {
buildCostChunk,
createBodyConverter,
createStreamPartConverter,
createResponseConverter,
UsageInfo,
@@ -53,12 +52,10 @@ import { createProviderBudgetTracker } from "./providerBudgetTracker"
import { accumulateUsage, HOT_WORKSPACES } from "./usageBatcher"
import { Workspace } from "@opencode-ai/console-core/workspace.js"
import { countryFromRequest, isModelCountryRestricted } from "~/lib/request-country"
import { prepareRequestBody } from "./requestBody"
type ZenData = Awaited<ReturnType<typeof ZenData.list>>
type RetryOptions = {
excludeProviders: string[]
retryCount: number
}
type PreparedBody = Awaited<ReturnType<typeof prepareRequestBody>>
type BillingSource = "anonymous" | "free" | "byok" | "subscription" | "lite" | "balance"
function resolve(text: string, params?: Record<string, string | number>) {
@@ -86,8 +83,6 @@ export async function handler(
type ProviderInfo = Awaited<ReturnType<typeof selectProvider>>
type CostInfo = ReturnType<typeof calculateCost>
const MAX_FAILOVER_RETRIES = 3
const MAX_RETRYABLE_STATUS_RETRIES = 3
const dict = i18n(localeFromRequest(input.request))
const t = (key: Key, params?: Record<string, string | number>) => resolve(dict[key], params)
const ADMIN_WORKSPACES = [
@@ -96,12 +91,15 @@ export async function handler(
"wrk_01KKZDKDWCS1VTJF8QTX62DD50", // contributors
]
let requestBody: PreparedBody | undefined
try {
const url = input.request.url
const body = await input.request.json()
const model = opts.parseModel(url, body)
const variant = opts.parseVariant(url, body)
const isStream = opts.parseIsStream(url, body)
const body = input.request.body
if (!body) throw new Error("Missing request body")
requestBody = opts.format === "google" ? undefined : await prepareRequestBody(body)
const model =
opts.format === "google" ? opts.parseModel(url, undefined) : (requestBody?.model ?? "")
const googleStream = opts.format === "google" ? opts.parseIsStream(url, undefined) : undefined
const rawIp = input.request.headers.get("x-real-ip") ?? ""
const ip = rawIp.includes(":") ? rawIp.split(":").slice(0, 4).join(":") : rawIp
const rawZenApiKey = opts.parseApiKey(input.request.headers)
@@ -112,12 +110,10 @@ export async function handler(
const projectId = input.request.headers.get("x-opencode-project") ?? ""
const userAgent = input.request.headers.get("user-agent") ?? ""
logger.metric({
is_stream: isStream,
session: sessionId,
request: requestId,
client: ocClient,
user_agent: userAgent,
"model.variant": variant,
"model.tier": opts.modelList === "full" ? "zen" : "go",
})
const zenData = ZenData.list(opts.modelList)
@@ -175,7 +171,7 @@ export async function handler(
)
const providerBudget = await providerBudgetTracker?.check()
const retriableRequest = async (retry: RetryOptions = { excludeProviders: [], retryCount: 0 }) => {
const providerRequest = async () => {
const providerInfo = selectProvider(
model,
zenData,
@@ -183,7 +179,6 @@ export async function handler(
modelInfo,
stickyId,
trialProviders,
retry,
stickyProvider,
modelTpmLimits,
modelTpsLimits,
@@ -199,80 +194,65 @@ export async function handler(
})
const startTimestamp = Date.now()
const reqUrl = providerInfo.modifyUrl(providerInfo.api, isStream)
const reqBody = JSON.stringify(
providerInfo.modifyBody({
...createBodyConverter(opts.format, providerInfo.format)(body),
model: providerInfo.model,
...(() => {
const replacer = (obj: Record<string, any>): Record<string, any> =>
Object.fromEntries(
Object.entries(obj).flatMap(([k, v]) => {
if (Array.isArray(v)) return [[k, v]]
if (typeof v === "object") return [[k, replacer(v)]]
if (typeof v === "string") {
if (v === "$workspace") return authInfo?.workspaceID ? [[k, authInfo.workspaceID]] : []
if (v === "$org")
return authInfo?.workspaceID ? [[k, authInfo.workspaceID.replace("wrk_", "org_")]] : []
if (v === "$user") return stickyId ? [[k, stickyId]] : []
if (v.startsWith("$header.")) {
const headerValue = input.request.headers.get(v.slice(8))
return headerValue ? [[k, headerValue]] : []
}
}
return [[k, v]]
}),
)
return replacer(providerInfo.payloadModifier ?? {})
})(),
}),
)
const reqUrl = providerInfo.modifyUrl(providerInfo.api, googleStream ?? false)
const specialAnthropic =
providerInfo.format === "anthropic" &&
(providerInfo.model.startsWith("arn:aws:bedrock:") ||
providerInfo.model.startsWith("global.anthropic.") ||
providerInfo.model.startsWith("databricks-claude-"))
if (providerInfo.format !== opts.format) throw new Error("Zen provider format must match request format")
if (specialAnthropic) throw new Error("Anthropic provider body modifiers are incompatible with streaming")
const prepared = requestBody
const reqBody = (() => {
if (opts.format === "google") return body
if (!prepared) throw new Error("Missing prepared request body")
return prepared.stream(providerInfo.model, providerInfo.format === "oa-compat")
})()
logger.debug("REQUEST URL: " + reqUrl)
logger.debug("REQUEST: " + reqBody.substring(0, 300) + "...")
logger.debug("REQUEST: " + (requestBody?.preview ?? "") + "...")
const isNewInference =
providerInfo.id.startsWith("console.") ||
providerInfo.id.startsWith("console-go.") ||
providerInfo.id.startsWith("inf.") ||
providerInfo.id.startsWith("inf-go.")
const res = await fetchWithRetryableStatus(
reqUrl,
{
method: "POST",
headers: (() => {
const headers = new Headers(input.request.headers)
providerInfo.modifyHeaders(headers, providerInfo.apiKey, stickyId)
Object.entries(providerInfo.headerModifier ?? {}).forEach(([k, v]) => {
if (v === "$ip") return headers.set(k, ip)
if (v === "$caller") return headers.set(k, stickyId)
if (v === "$session") return headers.set(k, sessionId)
if (v === "$model") return headers.set(k, model)
if (v === "$request") return headers.set(k, requestId)
if (v === "$project") return headers.set(k, projectId)
if (v === "$workspace") {
if (authInfo?.workspaceID) headers.set(k, authInfo.workspaceID)
return
}
if (v === "$org") {
if (authInfo?.workspaceID) headers.set(k, authInfo.workspaceID.replace("wrk_", "org_"))
return
}
headers.set(k, v)
})
headers.delete("host")
headers.delete("content-length")
headers.delete("x-opencode-request")
if (!isNewInference) headers.delete("x-opencode-session")
headers.delete("x-opencode-project")
headers.delete("x-opencode-client")
return headers
})(),
body: reqBody,
// Propagate caller disconnects to the upstream provider request so
// abandoned Console requests do not leave orphaned inference work open.
signal: input.request.signal,
},
{ count: isNewInference ? MAX_RETRYABLE_STATUS_RETRIES : 0 },
)
const res = await fetch(reqUrl, {
method: "POST",
headers: (() => {
const headers = new Headers(input.request.headers)
providerInfo.modifyHeaders(headers, providerInfo.apiKey, stickyId)
Object.entries(providerInfo.headerModifier ?? {}).forEach(([k, v]) => {
if (v === "$ip") return headers.set(k, ip)
if (v === "$caller") return headers.set(k, stickyId)
if (v === "$session") return headers.set(k, sessionId)
if (v === "$model") return headers.set(k, model)
if (v === "$request") return headers.set(k, requestId)
if (v === "$project") return headers.set(k, projectId)
if (v === "$workspace") {
if (authInfo?.workspaceID) headers.set(k, authInfo.workspaceID)
return
}
if (v === "$org") {
if (authInfo?.workspaceID) headers.set(k, authInfo.workspaceID.replace("wrk_", "org_"))
return
}
headers.set(k, v)
})
headers.delete("host")
headers.delete("content-length")
headers.delete("x-opencode-request")
if (!isNewInference) headers.delete("x-opencode-session")
headers.delete("x-opencode-project")
headers.delete("x-opencode-client")
return headers
})(),
body: reqBody,
// Propagate caller disconnects to the upstream provider request so
// abandoned Console requests do not leave orphaned inference work open.
signal: input.request.signal,
})
const isStream = res.headers.get("content-type")?.toLowerCase().includes("text/event-stream") ?? false
logger.metric({ is_stream: isStream })
if (isNewInference) {
const resEndpointId = res.headers.get("x-opencode-endpoint-id")
@@ -291,29 +271,10 @@ export async function handler(
})
}
// Try another provider => stop retrying if using fallback provider
if (
//!isNewInference &&
res.status !== 200 &&
// ie. 400 error is usually provider error like malformed request
res.status !== 400 &&
// ie. openai 404 error: Item with id 'msg_0ead8b004a3b165d0069436a6b6834819896da85b63b196a3f' not found.
!(modelInfo.id.startsWith("gpt-") && res.status === 404) &&
// ie. cannot change codex model providers mid-session
modelInfo.stickyProvider !== "strict" &&
modelInfo.fallbackProvider &&
providerInfo.id !== modelInfo.fallbackProvider
) {
return retriableRequest({
excludeProviders: [...retry.excludeProviders, providerInfo.id],
retryCount: retry.retryCount + 1,
})
}
return { providerInfo, reqBody, res, startTimestamp }
return { providerInfo, res, startTimestamp, isStream }
}
const { providerInfo, reqBody, res, startTimestamp } = await retriableRequest()
const { providerInfo, res, startTimestamp, isStream } = await providerRequest()
// Store sticky provider
if (res.status === 200) await stickyTracker?.set(providerInfo.id)
@@ -469,6 +430,8 @@ export async function handler(
headers: resHeaders,
})
} catch (error: any) {
if (requestBody) void requestBody.cancel().catch(() => {})
else void input.request.body?.cancel().catch(() => {})
// The caller disconnected before we finished. Because the outbound provider
// request shares input.request.signal, an aborted caller surfaces here as an
// AbortError. There is no client left to receive a body, so skip the error
@@ -593,7 +556,6 @@ export async function handler(
modelInfo: ModelInfo,
stickyId: string,
trialProviders: string[] | undefined,
retry: RetryOptions,
stickyProviderId: string | undefined,
modelTpmLimits: Record<string, number> | undefined,
modelTpsLimits: Record<string, { qualify: number; unqualify: number }> | undefined,
@@ -620,14 +582,11 @@ export async function handler(
}))
}
// Use fallback provider if max retries reached
const fallbackProvider = allProviders.find((provider) => provider.id === modelInfo.fallbackProvider)
if (retry.retryCount === MAX_FAILOVER_RETRIES) return fallbackProvider
let topPriority = Infinity
const providers = allProviders
.filter((provider) => provider.weight !== 0)
.filter((provider) => !retry.excludeProviders.includes(provider.id))
.filter((provider) => {
if (provider.budgetPriority === undefined) return true
if (!providerBudget) return true
@@ -1035,15 +994,6 @@ export async function handler(
providerInfo.apiKey = authInfo.provider.credentials
}
async function fetchWithRetryableStatus(url: string, options: RequestInit, retry = { count: 0 }) {
const res = await fetch(url, options)
if ([429, 529].includes(res.status) && retry.count < MAX_RETRYABLE_STATUS_RETRIES) {
await new Promise((resolve) => setTimeout(resolve, Math.pow(2, retry.count) * 500))
return fetchWithRetryableStatus(url, options, { count: retry.count + 1 })
}
return res
}
function calculateCost(modelInfo: ModelInfo, usageInfo: UsageInfo) {
const { inputTokens, outputTokens, reasoningTokens, cacheReadTokens, cacheWrite5mTokens, cacheWrite1hTokens } =
usageInfo
@@ -0,0 +1,191 @@
const TAIL_LIMIT = 4 * 1024
const encoder = new TextEncoder()
export async function prepareRequestBody(body: ReadableStream<Uint8Array>) {
const reader = body.getReader()
const chunks: Uint8Array[] = []
const decoder = new TextDecoder()
let text = ""
let done = false
let searchFrom = 0
let bom = 0
let match: RegExpExecArray | null = null
const pattern = /("model"\s*:\s*")([^"]+)"/g
while (!done && !match) {
const next = await reader.read()
done = next.done
if (!next.value) continue
if (!chunks.length && next.value[0] === 0xef && next.value[1] === 0xbb && next.value[2] === 0xbf) bom = 3
chunks.push(next.value)
text += decoder.decode(next.value, { stream: true })
pattern.lastIndex = searchFrom
match = pattern.exec(text)
searchFrom = Math.max(0, text.length - 256)
}
if (done) {
text += decoder.decode()
if (!match) {
pattern.lastIndex = searchFrom
match = pattern.exec(text)
}
}
const found = (() => {
if (!match) return
const start = bom + utf8Length(text, match.index + match[1].length)
return { model: match[2], start, end: start + utf8Length(match[2], match[2].length) }
})()
const preview = text.substring(0, 300)
text = ""
match = null
let used = false
return {
model: found?.model ?? "",
preview,
cancel: () => reader.cancel(),
stream(providerModel: string, includeUsage: boolean) {
if (used) throw new Error("Request body stream already consumed")
if (!found) throw new Error("Missing model field")
used = true
const initial = replace(chunks, found.start, found.end, providerModel)
chunks.length = 0
const output = passthrough(initial, reader, done)
if (!includeUsage) return output
return appendUsage(output)
},
}
}
function utf8Length(value: string, end: number) {
let length = 0
for (let i = 0; i < end; i++) {
const code = value.charCodeAt(i)
if (code <= 0x7f) length++
else if (code <= 0x7ff) length += 2
else if (code >= 0xd800 && code <= 0xdbff && i + 1 < end && value.charCodeAt(i + 1) >= 0xdc00) {
length += 4
i++
} else length += 3
}
return length
}
function replace(chunks: Uint8Array[], start: number, end: number, value: string) {
let offset = 0
let inserted = false
return chunks.flatMap((chunk) => {
const chunkStart = offset
const chunkEnd = offset + chunk.length
offset = chunkEnd
if (chunkEnd <= start || chunkStart >= end) return [chunk]
const parts = [chunk.subarray(0, Math.max(0, start - chunkStart))]
if (!inserted) {
parts.push(encoder.encode(value))
inserted = true
}
parts.push(chunk.subarray(Math.min(chunk.length, end - chunkStart)))
return parts.filter((part) => part.length)
})
}
function passthrough(
initial: Array<Uint8Array | undefined>,
reader: ReadableStreamDefaultReader<Uint8Array>,
sourceDone: boolean,
) {
let done = sourceDone
let index = 0
return new ReadableStream<Uint8Array>({
async pull(controller) {
const chunk = initial[index]
if (chunk) {
initial[index++] = undefined
controller.enqueue(chunk)
return
}
initial.length = 0
if (done) {
controller.close()
return
}
const next = await reader.read()
done = next.done
if (next.value) controller.enqueue(next.value)
if (done) controller.close()
},
cancel(reason) {
initial.length = 0
return reader.cancel(reason)
},
})
}
function appendUsage(body: ReadableStream<Uint8Array>) {
const reader = body.getReader()
const decoder = new TextDecoder()
let tail = new Uint8Array()
let streamText = ""
let isStream = false
const inspect = (chunk?: Uint8Array) => {
streamText += chunk ? decoder.decode(chunk, { stream: true }) : decoder.decode()
for (const match of streamText.matchAll(/"stream"\s*:\s*(true|false)/g)) isStream = match[1] === "true"
streamText = streamText.slice(-64)
}
return new ReadableStream<Uint8Array>({
async pull(controller) {
while (true) {
const next = await reader.read()
if (next.done) {
inspect()
if (!isStream) {
if (tail.length) controller.enqueue(tail)
controller.close()
return
}
const close = tail.lastIndexOf(125)
if (close < 0) {
controller.error(new Error("Invalid JSON request body"))
return
}
if (close) controller.enqueue(tail.subarray(0, close))
controller.enqueue(encoder.encode(',"stream_options":{"include_usage":true}}'))
if (close + 1 < tail.length) controller.enqueue(tail.subarray(close + 1))
controller.close()
return
}
const chunk = next.value
inspect(chunk)
if (tail.length + chunk.length <= TAIL_LIMIT) {
const combined = new Uint8Array(tail.length + chunk.length)
combined.set(tail)
combined.set(chunk, tail.length)
tail = combined
continue
}
const emit = tail.length + chunk.length - TAIL_LIMIT
if (emit <= tail.length) {
controller.enqueue(tail.subarray(0, emit))
const combined = new Uint8Array(TAIL_LIMIT)
combined.set(tail.subarray(emit))
combined.set(chunk, tail.length - emit)
tail = combined
return
}
if (tail.length) controller.enqueue(tail)
controller.enqueue(chunk.subarray(0, emit - tail.length))
tail = chunk.slice(emit - tail.length)
return
}
},
cancel(reason) {
return reader.cancel(reason)
},
})
}
@@ -0,0 +1,122 @@
import { describe, expect, test } from "bun:test"
import { prepareRequestBody } from "../src/routes/zen/util/requestBody"
describe("Zen request body streaming", () => {
test("patches the leading model without buffering the remaining body", async () => {
let reads = 0
const body = new ReadableStream<Uint8Array>(
{
pull(controller) {
const chunks = [
'{"model":"client-model","stream":true,"messages":[',
JSON.stringify({ role: "user", content: "large payload" }),
"]}",
]
const chunk = chunks[reads++]
if (chunk) controller.enqueue(new TextEncoder().encode(chunk))
else controller.close()
},
},
{ highWaterMark: 0 },
)
const request = await prepareRequestBody(body)
expect(request.model).toBe("client-model")
expect(reads).toBe(1)
const output = await new Response(request.stream("provider-model", false)).text()
expect(JSON.parse(output)).toEqual({
model: "provider-model",
stream: true,
messages: [{ role: "user", content: "large payload" }],
})
})
test("appends stream usage options at the end of the request", async () => {
const body = new Blob(['{"model":"client-model","stream":true,"messages":[]} ']).stream()
const request = await prepareRequestBody(body)
const output = await new Response(request.stream("provider-model", true)).text()
expect(JSON.parse(output)).toEqual({
model: "provider-model",
stream: true,
messages: [],
stream_options: { include_usage: true },
})
expect(output.endsWith(" ")).toBe(true)
})
test("detects streaming after a large message while forwarding", async () => {
const content = "x".repeat(128 * 1024)
let reads = 0
const chunks = [
'{"model":"client-model","messages":[',
JSON.stringify({ role: "user", content }),
'],"stream":true}',
]
const body = new ReadableStream<Uint8Array>(
{
pull(controller) {
const chunk = chunks[reads++]
if (chunk) controller.enqueue(new TextEncoder().encode(chunk))
else controller.close()
},
},
{ highWaterMark: 0 },
)
const request = await prepareRequestBody(body)
expect(reads).toBe(1)
const output = await new Response(request.stream("provider-model", true)).text()
expect(JSON.parse(output)).toEqual({
model: "provider-model",
messages: [{ role: "user", content }],
stream: true,
stream_options: { include_usage: true },
})
})
test("buffers through a late model field and then streams the rest", async () => {
const content = "こんにちは".repeat(32 * 1024)
let reads = 0
const chunks = [
'{"messages":[',
JSON.stringify({ role: "user", content }),
'],"model":"client-model","stream":true,"extra":"after-model"}',
]
const body = new ReadableStream<Uint8Array>(
{
pull(controller) {
const chunk = chunks[reads++]
if (chunk) controller.enqueue(new TextEncoder().encode(chunk))
else controller.close()
},
},
{ highWaterMark: 0 },
)
const request = await prepareRequestBody(body)
expect(request.model).toBe("client-model")
expect(reads).toBe(3)
expect(JSON.parse(await new Response(request.stream("provider-model", true)).text())).toEqual({
messages: [{ role: "user", content }],
model: "provider-model",
stream: true,
extra: "after-model",
stream_options: { include_usage: true },
})
})
test("preserves a UTF-8 BOM while patching the model", async () => {
const body = new Blob(['\uFEFF{"messages":[],"model":"client-model","stream":false}']).stream()
const request = await prepareRequestBody(body)
const output = new Uint8Array(await new Response(request.stream("provider-model", false)).arrayBuffer())
expect([...output.subarray(0, 3)]).toEqual([0xef, 0xbb, 0xbf])
expect(JSON.parse(new TextDecoder().decode(output))).toEqual({
messages: [],
model: "provider-model",
stream: false,
})
})
})
+12
View File
@@ -97,6 +97,18 @@ export namespace Workspace {
},
)
export const unblock = fn(
z.object({
workspaceID: Identifier.schema("workspace"),
}),
async (input) => {
const result = await Database.use((tx) =>
tx.update(WorkspaceTable).set({ is_blocked: false }).where(eq(WorkspaceTable.id, input.workspaceID)),
)
if (result.rowsAffected === 0) throw new Error("Workspace not found")
},
)
export const remove = fn(z.void(), async () => {
await Database.use((tx) =>
tx
+1 -1
View File
@@ -62,7 +62,7 @@
},
"dependencies": {
"@ai-sdk/alibaba": "1.0.17",
"@ai-sdk/amazon-bedrock": "4.0.112",
"@ai-sdk/amazon-bedrock": "4.0.158",
"@ai-sdk/anthropic": "3.0.82",
"@ai-sdk/azure": "3.0.88",
"@ai-sdk/cerebras": "2.0.41",
+10 -1
View File
@@ -45,9 +45,18 @@ function oauth(http: HttpClient.HttpClient) {
authorize: () =>
Effect.gen(function* () {
const device = yield* post(http, `${defaultServer}/auth/device/code`, { client_id: clientID }, Device)
const verification = yield* Effect.try({
try: () => {
const url = new URL(device.verification_uri_complete, `${defaultServer}/`)
if (url.protocol !== "http:" && url.protocol !== "https:") throw new Error("expected HTTP(S)")
return url
},
catch: (cause) =>
new Error(`Invalid device verification URL: ${cause instanceof Error ? cause.message : String(cause)}`),
})
return {
mode: "auto" as const,
url: `${defaultServer}${device.verification_uri_complete}`,
url: verification.href,
instructions: `Enter code: ${device.user_code}`,
callback: poll(http, defaultServer, device.device_code, Duration.seconds(device.interval)),
}
@@ -1,5 +1,6 @@
import { describe, expect } from "bun:test"
import { Effect } from "effect"
import { HttpClient, HttpClientResponse } from "effect/unstable/http"
import { Catalog } from "@opencode-ai/core/catalog"
import { Credential } from "@opencode-ai/core/credential"
import { EventV2 } from "@opencode-ai/core/event"
@@ -14,14 +15,16 @@ import { PluginTestLayer } from "./fixture"
const it = testEffect(PluginTestLayer)
const addPlugin = Effect.fn(function* () {
const addPlugin = Effect.fn(function* (http?: HttpClient.HttpClient) {
const plugin = yield* PluginV2.Service
const host = yield* PluginHost.make(plugin)
const events = yield* EventV2.Service
const integration = yield* Integration.Service
const client = yield* HttpClient.HttpClient
yield* OpencodePlugin.effect(host).pipe(
Effect.provideService(EventV2.Service, events),
Effect.provideService(Integration.Service, integration),
Effect.provideService(HttpClient.HttpClient, http ?? client),
)
})
@@ -82,6 +85,63 @@ describe("OpencodePlugin", () => {
}),
)
it.effect("resolves origin-rooted device verification URLs", () =>
Effect.gen(function* () {
const http = HttpClient.make((request) =>
Effect.succeed(
HttpClientResponse.fromWeb(
request,
Response.json({
device_code: "device",
user_code: "user",
verification_uri_complete: "/console/device?user_code=user&client_id=opencode-cli",
expires_in: 60,
interval: 60,
}),
),
),
)
yield* addPlugin(http)
const integration = yield* Integration.Service
const attempt = yield* integration.connection.oauth({
integrationID: Integration.ID.make("opencode"),
methodID: Integration.MethodID.make("device"),
inputs: {},
})
expect(attempt.url).toBe("https://opencode.ai/console/device?user_code=user&client_id=opencode-cli")
}),
)
it.effect("rejects malformed device verification URLs", () =>
Effect.gen(function* () {
const http = HttpClient.make((request) =>
Effect.succeed(
HttpClientResponse.fromWeb(
request,
Response.json({
device_code: "device",
user_code: "user",
verification_uri_complete: "http://[::1",
expires_in: 60,
interval: 60,
}),
),
),
)
yield* addPlugin(http)
const integration = yield* Integration.Service
const error = yield* integration.connection
.oauth({
integrationID: Integration.ID.make("opencode"),
methodID: Integration.MethodID.make("device"),
inputs: {},
})
.pipe(Effect.flip)
expect(error).toBeInstanceOf(Integration.AuthorizationError)
expect(String(error.cause)).toContain("Invalid device verification URL")
}),
)
it.live("loads providers and models from the connected OpenCode server", () =>
Effect.acquireUseRelease(
Effect.sync(() => {
+1 -1
View File
@@ -56,7 +56,7 @@
"@actions/github": "6.0.1",
"@agentclientprotocol/sdk": "0.21.0",
"@ai-sdk/alibaba": "1.0.17",
"@ai-sdk/amazon-bedrock": "4.0.112",
"@ai-sdk/amazon-bedrock": "4.0.158",
"@ai-sdk/anthropic": "3.0.82",
"@ai-sdk/azure": "3.0.88",
"@ai-sdk/cerebras": "2.0.60",
+9 -1
View File
@@ -396,10 +396,18 @@ const layer: Layer.Layer<Service, never, AccountRepo.Service | HttpClient.HttpCl
const parsed = yield* HttpClientResponse.schemaBodyJson(DeviceAuth)(response).pipe(
mapAccountServiceError("Failed to decode response"),
)
const verification = yield* Effect.try({
try: () => {
const url = new URL(parsed.verification_uri_complete, `${normalizedServer}/`)
if (url.protocol !== "http:" && url.protocol !== "https:") throw new Error("expected HTTP(S)")
return url.href
},
catch: (cause) => new AccountServiceError({ message: "Invalid device verification URL", cause }),
})
return new Login({
code: parsed.device_code,
user: parsed.user_code,
url: `${normalizedServer}${parsed.verification_uri_complete}`,
url: verification,
server: normalizedServer,
expiry: parsed.expires_in,
interval: parsed.interval,
+3 -3
View File
@@ -1303,13 +1303,13 @@ export function options(input: {
}
}
// Only set textVerbosity for non-chat gpt-5.x models
// Chat models (e.g. gpt-5.2-chat-latest) only support "medium" verbosity
// Generic OpenAI-compatible APIs do not necessarily support OpenAI's verbosity parameter.
// Only enable the default for integrations known to implement it.
if (
input.model.api.id.includes("gpt-5.") &&
!input.model.api.id.includes("codex") &&
!input.model.api.id.includes("-chat") &&
input.model.providerID !== "azure"
(input.model.api.npm === "@ai-sdk/openai" || input.model.api.npm === "@ai-sdk/amazon-bedrock/mantle")
) {
result["textVerbosity"] = "low"
}
+28 -7
View File
@@ -10,6 +10,7 @@ import { Account } from "../../src/account/account"
import {
AccessToken,
AccountID,
AccountServiceError,
AccountTransportError,
DeviceCode,
Login,
@@ -71,18 +72,18 @@ const deviceTokenClient = (body: unknown, status = 400) =>
const poll = (body: unknown, status = 400) =>
Account.Service.use((s) => s.poll(login())).pipe(Effect.provide(live(deviceTokenClient(body, status))))
it.live("login normalizes trailing slashes in the provided server URL", () =>
it.live("login resolves origin-rooted verification URLs from servers with base paths", () =>
Effect.gen(function* () {
const seen: Array<string> = []
const client = HttpClient.make((req) =>
Effect.gen(function* () {
seen.push(`${req.method} ${req.url}`)
if (req.url === "https://one.example.com/auth/device/code") {
if (req.url === "https://one.example.com/console/auth/device/code") {
return json(req, {
device_code: "device-code",
user_code: "user-code",
verification_uri_complete: "/device?user_code=user-code",
verification_uri_complete: "/console/device?user_code=user-code",
expires_in: 600,
interval: 5,
})
@@ -92,11 +93,31 @@ it.live("login normalizes trailing slashes in the provided server URL", () =>
}),
)
const result = yield* Account.use.login("https://one.example.com/").pipe(Effect.provide(live(client)))
const result = yield* Account.use.login("https://one.example.com/console/").pipe(Effect.provide(live(client)))
expect(seen).toEqual(["POST https://one.example.com/auth/device/code"])
expect(result.server).toBe("https://one.example.com")
expect(result.url).toBe("https://one.example.com/device?user_code=user-code")
expect(seen).toEqual(["POST https://one.example.com/console/auth/device/code"])
expect(result.server).toBe("https://one.example.com/console")
expect(result.url).toBe("https://one.example.com/console/device?user_code=user-code")
}),
)
it.live("login rejects malformed device verification URLs", () =>
Effect.gen(function* () {
const client = HttpClient.make((req) =>
Effect.succeed(
json(req, {
device_code: "device-code",
user_code: "user-code",
verification_uri_complete: "http://[::1",
expires_in: 600,
interval: 5,
}),
),
)
const error = yield* Effect.flip(Account.use.login("https://one.example.com").pipe(Effect.provide(live(client))))
expect(error).toBeInstanceOf(AccountServiceError)
if (error instanceof AccountServiceError) expect(error.message).toBe("Invalid device verification URL")
}),
)
@@ -523,6 +523,7 @@ describe("ProviderTransform.options - gpt-5 textVerbosity", () => {
expect(result.reasoningEffort).toBe("medium")
expect(result.reasoningSummary).toBeUndefined()
expect(result.include).toBeUndefined()
expect(result.textVerbosity).toBeUndefined()
})
test("azure chat completions omit Responses-only reasoning options after variants merge", async () => {
@@ -812,7 +812,8 @@ function ModelTrendSection(props: {
<div data-slot="tooltip-divider" />
<p>
<span data-slot="tooltip-label">
<i data-kind={props.lineTone === "active" ? "users" : "tokens"} /> {props.rowLabel}
<i data-kind={props.lineTone === "active" ? "users" : "tokens"} />
<span data-slot="tooltip-name">{props.rowLabel}</span>
</span>
<b>{props.formatValue(props.value(active.point))}</b>
</p>
@@ -473,13 +473,15 @@ function LabUsageSection(props: { lab: ModelCatalogLab; data: StatsLabData | nul
<div data-slot="tooltip-divider" />
<p>
<span data-slot="tooltip-label">
<i data-kind="tokens" /> {i18n.t("lab.dailyTokens")}
<i data-kind="tokens" />
<span data-slot="tooltip-name">{i18n.t("lab.dailyTokens")}</span>
</span>
<b>{formatTokens(active.point.tokens)}</b>
</p>
<p>
<span data-slot="tooltip-label">
<i data-kind="users" /> {i18n.t("model.uniqueUsers")}
<i data-kind="users" />
<span data-slot="tooltip-name">{i18n.t("model.uniqueUsers")}</span>
</span>
<b>{formatUsers(active.point.users)}</b>
</p>
+9 -2
View File
@@ -1590,6 +1590,13 @@ body {
white-space: nowrap;
}
[data-page="stats"] [data-component="chart-tooltip"] [data-slot="tooltip-name"] {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
[data-page="stats"] [data-component="chart-tooltip"] [data-slot="tooltip-divider"] {
height: 1px;
margin: 4px -16px 2px;
@@ -1677,7 +1684,7 @@ body {
[data-page="stats"] :is([data-section="top-models"], [data-section="unique-users"]) [data-component="chart-tooltip"] p {
grid-template-columns: minmax(0, 1fr) auto;
gap: 4px;
gap: 1ch;
height: 16px;
margin: 4px 0 0;
padding: 0 8px;
@@ -4723,7 +4730,7 @@ body {
[data-page="stats"] [data-component="model-usage-chart"] [data-component="chart-tooltip"] p {
grid-template-columns: minmax(0, 1fr) auto;
gap: 4px;
gap: 1ch;
height: 20px;
margin: 8px 0;
padding: 0 8px;
+2 -2
View File
@@ -568,8 +568,8 @@ function TopModelsChart(props: {
style={{
background: getRankColor(item.segment.model, item.index, segmentOrder(), usageColors),
}}
/>{" "}
{item.segment.model}
/>
<span data-slot="tooltip-name">{item.segment.model}</span>
</span>
<b>{formatUsageChartValue(item.segment.value, metric())}</b>
</p>
@@ -4,6 +4,7 @@ import { modelAuthor, normalizeInferenceModel, statModel, statProvider } from ".
describe("inference stat normalization", () => {
test("normalizes model suffixes used by router/provider variants", () => {
expect(normalizeInferenceModel("GPT-5-Free")).toBe("gpt-5")
expect(normalizeInferenceModel("deepseek-v4-flash-free")).toBe("deepseek-v4-flash")
expect(normalizeInferenceModel("deepseek-v4-flash:global")).toBe("deepseek-v4-flash")
expect(normalizeInferenceModel("mimo-v2.5-free")).toBe("mimo-v2.5")
@@ -23,7 +23,7 @@ export const RETIRED_STAT_MODELS = ["big-pickle", ...Object.keys(MODEL_NAME_ALIA
export const RETIRED_STAT_PROVIDERS = ["opencode"]
export function normalizeInferenceModel(value: string | undefined) {
return (value || "unknown").replace(/(-free|:free|:global)+$/, "") || "unknown"
return (value || "unknown").toLowerCase().replace(/(-free|:free|:global)+$/, "") || "unknown"
}
export function modelAuthor(value: string | undefined) {
+2 -2
View File
@@ -188,8 +188,8 @@ https://opencode.ai/zen/v1/models
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -195,8 +195,8 @@ Podržavamo pay-as-you-go model. Ispod su cijene **po 1M tokena**.
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -195,8 +195,8 @@ Vi understøtter en pay-as-you-go-model. Nedenfor er priserne **pr. 1M tokens**.
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -184,8 +184,8 @@ Wir unterstützen ein Pay-as-you-go-Modell. Unten findest du die Preise **pro 1M
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -195,8 +195,8 @@ Admitimos un modelo de pago por uso. A continuación se muestran los precios **p
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -184,8 +184,8 @@ Nous prenons en charge un modèle de paiement à l'utilisation. Vous trouverez c
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+3 -3
View File
@@ -195,8 +195,8 @@ Supportiamo un modello pay-as-you-go. Qui sotto trovi i prezzi **per 1M token**.
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
@@ -221,7 +221,7 @@ Supportiamo un modello pay-as-you-go. Qui sotto trovi i prezzi **per 1M token**.
| GPT 5 Codex | $1.07 | $8.50 | $0.107 | - |
| GPT 5 Nano | $0.05 | $0.40 | $0.005 | - |
**GPT 5.6 Sol:** I prezzi mostrati includono uno sconto del 50% fino al 18 settembre 2026.
**GPT 5.6 Sol:** I prezzi mostrati includono uno sconto del 50% fino al 18 septembre 2026.
**DeepSeek V4 Flash / Pro:** Gli orari Peak sono 01:00-04:00 e 06:00-10:00 UTC; tutti gli altri orari sono Off-Peak. [Scopri di più](https://api-docs.deepseek.com/quick_start/pricing/).
+2 -2
View File
@@ -184,8 +184,8 @@ https://opencode.ai/zen/v1/models
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -184,8 +184,8 @@ https://opencode.ai/zen/v1/models
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -195,8 +195,8 @@ Vi støtter en pay-as-you-go-modell. Nedenfor er prisene **per 1M tokens**.
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -195,8 +195,8 @@ Obsługujemy model pay-as-you-go. Poniżej znajdują się ceny **za 1M tokenów*
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -184,8 +184,8 @@ Oferecemos um modelo pay-as-you-go. Abaixo estão os preços **por 1M tokens**.
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -195,8 +195,8 @@ https://opencode.ai/zen/v1/models
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -186,8 +186,8 @@ https://opencode.ai/zen/v1/models
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -184,8 +184,8 @@ Kullandıkça öde modelini destekliyoruz. Aşağıda **1M token başına** fiya
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -195,8 +195,8 @@ We support a pay-as-you-go model. Below are the prices **per 1M tokens**.
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -184,8 +184,8 @@ https://opencode.ai/zen/v1/models
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+2 -2
View File
@@ -189,8 +189,8 @@ https://opencode.ai/zen/v1/models
| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
| GPT 5.6 Sol (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | $3.125 |
| GPT 5.6 Sol (> 272K tokens) | $5.00 | $22.50 | $0.50 | $6.25 |
| GPT 5.6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
| GPT 5.6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |