@cartanova/qgrid-cli 2.15.3 → 2.15.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/bundle/dist/application/qgrid/qgrid.frame.js +168 -12
  2. package/bundle/dist/application/qgrid/qgrid.types.js +6 -3
  3. package/bundle/dist/application/request-log/request-log.model.js +4 -3
  4. package/bundle/dist/application/sonamu.generated.js +20 -5
  5. package/bundle/dist/application/sonamu.generated.sso.js +5 -3
  6. package/bundle/dist/i18n/en.js +2 -1
  7. package/bundle/dist/i18n/ko.js +2 -1
  8. package/bundle/dist/i18n/sd.generated.js +6 -1
  9. package/bundle/dist/migrations/20261109110340_alter_request_logs_add1_alter1.js +15 -0
  10. package/bundle/dist/utils/providers/grok/grok-types.js +1 -1
  11. package/bundle/dist/utils/providers/grok/grok-voice-client.js +4 -2
  12. package/bundle/dist/utils/providers/openai/openai-backend-protocol.js +6 -54
  13. package/bundle/dist/utils/providers/openai/openai-direct-client.js +2 -2
  14. package/bundle/dist/utils/providers/openai/openai-dispatcher.js +47 -19
  15. package/bundle/dist/utils/providers/openai/openai-image-generation.js +1 -2
  16. package/bundle/dist/utils/providers/openai/openai-realtime-protocol.js +389 -0
  17. package/bundle/dist/utils/providers/openai/openai-voice-client.js +460 -0
  18. package/bundle/src/application/qgrid/qgrid.frame.test.ts +43 -6
  19. package/bundle/src/application/qgrid/qgrid.frame.ts +246 -14
  20. package/bundle/src/application/qgrid/qgrid.types.ts +14 -2
  21. package/bundle/src/application/request-log/request-log.entity.json +17 -2
  22. package/bundle/src/application/request-log/request-log.model.test.ts +17 -0
  23. package/bundle/src/application/request-log/request-log.model.ts +11 -3
  24. package/bundle/src/application/sonamu.generated.http +2 -0
  25. package/bundle/src/application/sonamu.generated.sso.ts +2 -0
  26. package/bundle/src/application/sonamu.generated.ts +14 -0
  27. package/bundle/src/i18n/en.ts +1 -0
  28. package/bundle/src/i18n/ko.ts +1 -0
  29. package/bundle/src/i18n/sd.generated.ts +6 -0
  30. package/bundle/src/migrations/20261109110340_alter_request_logs_add1_alter1.ts +15 -0
  31. package/bundle/src/utils/providers/grok/grok-types.ts +2 -0
  32. package/bundle/src/utils/providers/grok/grok-voice-client.test.ts +2 -0
  33. package/bundle/src/utils/providers/grok/grok-voice-client.ts +2 -0
  34. package/bundle/src/utils/providers/openai/openai-backend-protocol.test.ts +8 -69
  35. package/bundle/src/utils/providers/openai/openai-backend-protocol.ts +7 -86
  36. package/bundle/src/utils/providers/openai/openai-direct-client.test.ts +0 -15
  37. package/bundle/src/utils/providers/openai/openai-direct-client.ts +3 -1
  38. package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +19 -93
  39. package/bundle/src/utils/providers/openai/openai-dispatcher.ts +98 -47
  40. package/bundle/src/utils/providers/openai/openai-image-generation.test.ts +6 -4
  41. package/bundle/src/utils/providers/openai/openai-image-generation.ts +0 -6
  42. package/bundle/src/utils/providers/openai/openai-realtime-protocol.ts +550 -0
  43. package/bundle/src/utils/providers/openai/openai-voice-client.test.ts +582 -0
  44. package/bundle/src/utils/providers/openai/openai-voice-client.ts +744 -0
  45. package/bundle/web-dist/client/assets/index-DyrPRt6O.css +1 -0
  46. package/bundle/web-dist/client/assets/index-Wi8Wxte6.js +104 -0
  47. package/bundle/web-dist/client/assets/{logs-Dw-GrMuH.js → logs-Bdg3wJV2.js} +1 -1
  48. package/bundle/web-dist/client/assets/{monit-BaFFiVKs.js → monit-DcwHRAKu.js} +1 -1
  49. package/bundle/web-dist/client/assets/{routes-R1xBZYVT.js → routes-lxVC1DDJ.js} +1 -1
  50. package/bundle/web-dist/client/assets/{settings-Bw_NXAx8.js → settings-C0VCdd1C.js} +1 -1
  51. package/bundle/web-dist/client/assets/{show-BH7nfFtF.js → show-B7QRPxsY.js} +2 -2
  52. package/bundle/web-dist/client/assets/{tokens-BPmRr7mD.js → tokens-CNRSm9sc.js} +1 -1
  53. package/bundle/web-dist/client/assets/{use-oauth-login-flow-B_MGbC3a.js → use-oauth-login-flow-eQnMzp8A.js} +1 -1
  54. package/bundle/web-dist/client/assets/{use-update-token-mutation-Dcq7Yv2R.js → use-update-token-mutation-KnwyYQjb.js} +1 -1
  55. package/bundle/web-dist/client/assets/voice-BydIuS0A.js +1 -0
  56. package/bundle/web-dist/client/index.html +2 -2
  57. package/bundle/web-dist/client/voice-samples/grok/altair.mp3 +0 -0
  58. package/bundle/web-dist/client/voice-samples/grok/ara.mp3 +0 -0
  59. package/bundle/web-dist/client/voice-samples/grok/atlas.mp3 +0 -0
  60. package/bundle/web-dist/client/voice-samples/grok/aurora.mp3 +0 -0
  61. package/bundle/web-dist/client/voice-samples/grok/carina.mp3 +0 -0
  62. package/bundle/web-dist/client/voice-samples/grok/castor.mp3 +0 -0
  63. package/bundle/web-dist/client/voice-samples/grok/celeste.mp3 +0 -0
  64. package/bundle/web-dist/client/voice-samples/grok/cosmo.mp3 +0 -0
  65. package/bundle/web-dist/client/voice-samples/grok/eve.mp3 +0 -0
  66. package/bundle/web-dist/client/voice-samples/grok/helios.mp3 +0 -0
  67. package/bundle/web-dist/client/voice-samples/grok/helix.mp3 +0 -0
  68. package/bundle/web-dist/client/voice-samples/grok/iris.mp3 +0 -0
  69. package/bundle/web-dist/client/voice-samples/grok/kepler.mp3 +0 -0
  70. package/bundle/web-dist/client/voice-samples/grok/leo.mp3 +0 -0
  71. package/bundle/web-dist/client/voice-samples/grok/liora.mp3 +0 -0
  72. package/bundle/web-dist/client/voice-samples/grok/lumen.mp3 +0 -0
  73. package/bundle/web-dist/client/voice-samples/grok/luna.mp3 +0 -0
  74. package/bundle/web-dist/client/voice-samples/grok/lux.mp3 +0 -0
  75. package/bundle/web-dist/client/voice-samples/grok/naksh.mp3 +0 -0
  76. package/bundle/web-dist/client/voice-samples/grok/orion.mp3 +0 -0
  77. package/bundle/web-dist/client/voice-samples/grok/perseus.mp3 +0 -0
  78. package/bundle/web-dist/client/voice-samples/grok/rex.mp3 +0 -0
  79. package/bundle/web-dist/client/voice-samples/grok/rigel.mp3 +0 -0
  80. package/bundle/web-dist/client/voice-samples/grok/sal.mp3 +0 -0
  81. package/bundle/web-dist/client/voice-samples/grok/sirius.mp3 +0 -0
  82. package/bundle/web-dist/client/voice-samples/grok/ursa.mp3 +0 -0
  83. package/bundle/web-dist/client/voice-samples/grok/zagan.mp3 +0 -0
  84. package/bundle/web-dist/client/voice-samples/grok/zenith.mp3 +0 -0
  85. package/bundle/web-dist/client/voice-samples/openai/alloy.mp3 +0 -0
  86. package/bundle/web-dist/client/voice-samples/openai/ash.mp3 +0 -0
  87. package/bundle/web-dist/client/voice-samples/openai/ballad.mp3 +0 -0
  88. package/bundle/web-dist/client/voice-samples/openai/cedar.mp3 +0 -0
  89. package/bundle/web-dist/client/voice-samples/openai/coral.mp3 +0 -0
  90. package/bundle/web-dist/client/voice-samples/openai/echo.mp3 +0 -0
  91. package/bundle/web-dist/client/voice-samples/openai/marin.mp3 +0 -0
  92. package/bundle/web-dist/client/voice-samples/openai/sage.mp3 +0 -0
  93. package/bundle/web-dist/client/voice-samples/openai/shimmer.mp3 +0 -0
  94. package/bundle/web-dist/client/voice-samples/openai/verse.mp3 +0 -0
  95. package/bundle/web-dist/server/assets/link-DrdV092C.js +4919 -0
  96. package/bundle/web-dist/server/assets/{logs-6289J29J.js → logs-BmBpBe-j.js} +13 -6
  97. package/bundle/web-dist/server/assets/{monit-YVvwJuAF.js → monit-Db1WrIls.js} +2 -2
  98. package/bundle/web-dist/server/assets/{plus-z5Hy__3C.js → plus-CW9y_K7l.js} +1 -1
  99. package/bundle/web-dist/server/assets/{refresh-cw-CNm0CERy.js → refresh-cw-CRgcH5bT.js} +1 -1
  100. package/bundle/web-dist/server/assets/{request-model-DIuPZZwu.js → request-model-DRF7hmJC.js} +1 -1
  101. package/bundle/web-dist/server/assets/{routes-DVWRvqn0.js → routes-CARZj7or.js} +4 -4
  102. package/bundle/web-dist/server/assets/{services.generated-CqS8DCjT.js → services.generated-B6QpnL_N.js} +7 -0
  103. package/bundle/web-dist/server/assets/{settings-CXwnKiMG.js → settings-B4jdpP5N.js} +4 -4
  104. package/bundle/web-dist/server/assets/{show-G1t8dOEh.js → show-D8r2sVK0.js} +17 -9
  105. package/bundle/web-dist/server/assets/{tokens-Di1vDwm5.js → tokens-TDQguTdh.js} +5 -5
  106. package/bundle/web-dist/server/assets/{use-oauth-login-flow-BUAcW_pK.js → use-oauth-login-flow-du7pOh_H.js} +1 -1
  107. package/bundle/web-dist/server/assets/{use-update-token-mutation-oH0O0n-g.js → use-update-token-mutation-DA6HiiWS.js} +1 -1
  108. package/bundle/web-dist/server/assets/voice-C2HfwkGp.js +668 -0
  109. package/bundle/web-dist/server/entry-server.generated.js +125 -4989
  110. package/bundle/web-dist/server/voice-samples/grok/altair.mp3 +0 -0
  111. package/bundle/web-dist/server/voice-samples/grok/ara.mp3 +0 -0
  112. package/bundle/web-dist/server/voice-samples/grok/atlas.mp3 +0 -0
  113. package/bundle/web-dist/server/voice-samples/grok/aurora.mp3 +0 -0
  114. package/bundle/web-dist/server/voice-samples/grok/carina.mp3 +0 -0
  115. package/bundle/web-dist/server/voice-samples/grok/castor.mp3 +0 -0
  116. package/bundle/web-dist/server/voice-samples/grok/celeste.mp3 +0 -0
  117. package/bundle/web-dist/server/voice-samples/grok/cosmo.mp3 +0 -0
  118. package/bundle/web-dist/server/voice-samples/grok/eve.mp3 +0 -0
  119. package/bundle/web-dist/server/voice-samples/grok/helios.mp3 +0 -0
  120. package/bundle/web-dist/server/voice-samples/grok/helix.mp3 +0 -0
  121. package/bundle/web-dist/server/voice-samples/grok/iris.mp3 +0 -0
  122. package/bundle/web-dist/server/voice-samples/grok/kepler.mp3 +0 -0
  123. package/bundle/web-dist/server/voice-samples/grok/leo.mp3 +0 -0
  124. package/bundle/web-dist/server/voice-samples/grok/liora.mp3 +0 -0
  125. package/bundle/web-dist/server/voice-samples/grok/lumen.mp3 +0 -0
  126. package/bundle/web-dist/server/voice-samples/grok/luna.mp3 +0 -0
  127. package/bundle/web-dist/server/voice-samples/grok/lux.mp3 +0 -0
  128. package/bundle/web-dist/server/voice-samples/grok/naksh.mp3 +0 -0
  129. package/bundle/web-dist/server/voice-samples/grok/orion.mp3 +0 -0
  130. package/bundle/web-dist/server/voice-samples/grok/perseus.mp3 +0 -0
  131. package/bundle/web-dist/server/voice-samples/grok/rex.mp3 +0 -0
  132. package/bundle/web-dist/server/voice-samples/grok/rigel.mp3 +0 -0
  133. package/bundle/web-dist/server/voice-samples/grok/sal.mp3 +0 -0
  134. package/bundle/web-dist/server/voice-samples/grok/sirius.mp3 +0 -0
  135. package/bundle/web-dist/server/voice-samples/grok/ursa.mp3 +0 -0
  136. package/bundle/web-dist/server/voice-samples/grok/zagan.mp3 +0 -0
  137. package/bundle/web-dist/server/voice-samples/grok/zenith.mp3 +0 -0
  138. package/bundle/web-dist/server/voice-samples/openai/alloy.mp3 +0 -0
  139. package/bundle/web-dist/server/voice-samples/openai/ash.mp3 +0 -0
  140. package/bundle/web-dist/server/voice-samples/openai/ballad.mp3 +0 -0
  141. package/bundle/web-dist/server/voice-samples/openai/cedar.mp3 +0 -0
  142. package/bundle/web-dist/server/voice-samples/openai/coral.mp3 +0 -0
  143. package/bundle/web-dist/server/voice-samples/openai/echo.mp3 +0 -0
  144. package/bundle/web-dist/server/voice-samples/openai/marin.mp3 +0 -0
  145. package/bundle/web-dist/server/voice-samples/openai/sage.mp3 +0 -0
  146. package/bundle/web-dist/server/voice-samples/openai/shimmer.mp3 +0 -0
  147. package/bundle/web-dist/server/voice-samples/openai/verse.mp3 +0 -0
  148. package/package.json +1 -1
  149. package/skills/qgrid/SKILL.md +5 -5
  150. package/skills/qgrid/references/ai-sdk-provider-contract.md +4 -0
  151. package/skills/qgrid/references/decision-rationale.md +13 -3
  152. package/skills/qgrid/references/openai-codex-runtime.md +17 -5
  153. package/skills/qgrid/references/request-log-run-lifecycle.md +7 -2
  154. package/skills/qgrid/references/sonamu-api-web-flow.md +6 -2
  155. package/skills/qgrid/references/verification-and-debugging.md +3 -3
  156. package/bundle/web-dist/client/assets/index-BakMhnHZ.js +0 -104
  157. package/bundle/web-dist/client/assets/index-DLo1QCw7.css +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartanova/qgrid-cli",
3
- "version": "2.15.3",
3
+ "version": "2.15.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cartanova-ai/qgrid"
@@ -55,7 +55,7 @@ Request logging is enabled by default. Use `providerOptions.qgrid.logger: false`
55
55
  - Prefer `getPuri()` for Sonamu model queries. Treat `getDB()` as a legacy escape hatch only when Puri cannot express the required query. Inside `@transactional` methods, all participating queries must use `getPuri()`; `getDB()` does not reuse Sonamu's ambient transaction connection.
56
56
  - Never hand-author migration files for Sonamu-managed schema. In the qgrid source repository, change the entity definition, inspect `sonamu migrate status`, and create migration files with `mise exec -- pnpm --dir packages/api sonamu migrate generate`. Inspect the generated files before applying them. If Sonamu cannot express a required schema change, stop and ask rather than silently replacing its workflow with a custom migration.
57
57
  - Keep OpenAI Codex built-in tools, apps, plugins, skills, web search, shell, and environment instruction blocks disabled unless the user explicitly asks for agentic Codex behavior.
58
- - Treat OpenAI image generation as opt-in outside dashboard chat. OpenAI `qgrid_chat` opts into raw API `imageGeneration: "auto"` on every turn. Auto mode registers only the server-executed `generate_image` function and calls Codex standalone Images for ordinary or transparent output. The raw explicit chat-model `imageGeneration: true` hosted route remains supported separately. The public SDK uses only `qgrid.image()` / `generateImage` for images, calling standalone Images for every background. Do not expose the raw `imageGeneration` or `imageGenerationOptions` fields as language-model options or retain deprecated shims. Do not reintroduce a client decision tool followed by another GPT generation request. Image costs use reported image usage at public token rates when available; otherwise estimate per image from the requested quality/size table. Auto or unsupported sizes use the 1536x1024 price; omitted quality uses medium. Display combined driver and image costs as dollar amounts without Cost labels. Do not show Known/Estimated labels, pricing disclaimers, or cost-source metadata in the dashboard.
58
+ - Treat OpenAI image generation as opt-in outside dashboard chat. OpenAI `qgrid_chat` opts into raw API `imageGeneration: "auto"` on every turn. Auto mode registers only the server-executed `generate_image` function and calls Codex standalone Images for ordinary or transparent output. Raw explicit `imageGeneration: true` on a chat model also calls standalone Images directly, without a text driver; never register the hosted Responses `image_generation` tool, which fails whenever the driver carries reasoning effort (2026-11-09). The public SDK uses only `qgrid.image()` / `generateImage` for images, calling standalone Images for every background. Do not expose the raw `imageGeneration` or `imageGenerationOptions` fields as language-model options or retain deprecated shims. Do not reintroduce a client decision tool followed by another GPT generation request. Image costs use reported image usage at public token rates when available; otherwise estimate per image from the requested quality/size table. Auto or unsupported sizes use the 1536x1024 price; omitted quality uses medium. Display combined driver and image costs as dollar amounts without Cost labels. Do not show Known/Estimated labels, pricing disclaimers, or cost-source metadata in the dashboard.
59
59
 
60
60
  ## Request log IDs (2.10.0+)
61
61
 
@@ -74,11 +74,11 @@ Request logging is enabled by default. Use `providerOptions.qgrid.logger: false`
74
74
 
75
75
  ## Image output formats (2.9.6+)
76
76
 
77
- - Raw explicit chat-model hosted Responses requests support `imageGenerationOptions.outputFormat: "png" | "jpeg" | "webp"`. Omission retains PNG. Auto chat and public `generateImage` use standalone Images and support PNG only; reject other formats before generation. Public image options use flat `QgridImageProviderOptions`.
78
- - Preserve the actual returned MIME type in qgrid content, AI SDK files, and request-log image URLs; do not relabel bytes as the requested format.
79
- - Transparent generation uses the standalone Codex Images route and accepts PNG only. Reject transparent JPEG/WebP requests before generation. Do not convert output or fall back to another route.
77
+ - Every OpenAI image request (explicit chat-model `imageGeneration: true`, auto chat, and public `generateImage`) uses standalone Images and supports PNG only. The raw `imageGenerationOptions.outputFormat` enum still lists `jpeg`/`webp`, but the API rejects them before generation. Public image options use flat `QgridImageProviderOptions`.
78
+ - Preserve the actual returned MIME type in qgrid content, AI SDK files, and request-log image URLs; do not relabel bytes as the requested format. Replayed history may still contain JPEG/WebP images from the former hosted route.
79
+ - Do not convert output or fall back to another route.
80
80
  - Keep the AI SDK standard `GeneratedFile.mediaType: string` contract. Do not add a qgrid-specific image wrapper or conditional return type.
81
- - A 2026-09-29 hosted-route probe returned PNG for a prompt-only WebP request and WebP when `outputFormat: "webp"` was supplied. Model prose is not format evidence; inspect file bytes. Chat does not infer output format from prose, and no post-generation conversion is performed.
81
+ - Model prose is not format evidence; inspect file bytes. Chat does not infer output format from prose.
82
82
 
83
83
  ## Verification
84
84
 
@@ -258,3 +258,7 @@ Do not store or replay `sessionKey` affinity coordinates for `anthropic/*` model
258
258
  `createQgridLogger` records external provider calls into qgrid request logs. Callers pass it as AI SDK 7's `telemetry` option. It skips qgrid provider calls to avoid double-logging, and it skips any external-provider generation whose `providerOptions.qgrid.logger` is `false`. This makes `logger: false` a single opt-out that produces zero native or telemetry request logs without changing the model call itself. Runs are keyed by the AI SDK `callId` and finish on `onEnd`, `onError` (an `AbortError` is recorded as `aborted`), or `onAbort`. When changing logger behavior, preserve the stale-run fallback for generations that never report a terminal event, such as an unconsumed stream.
259
259
 
260
260
  For external providers, the logger reads AI SDK's provider-neutral `onStart.output.responseFormat`. JSON output modes send `isStructured: true` plus the serialized schema when present; ordinary text sends `isStructured: false` and `jsonSchema: null`. A succeeded structured run also sends `responseJsonOk`, based only on whether the final response text parses as JSON. Qgrid does not duplicate caller-side Zod/schema validation. These lifecycle fields are optional on the server so older SDK clients remain compatible.
261
+
262
+ ## OpenAI voice models
263
+
264
+ `qgrid.transcription("openai/<id>")` and `qgrid.speech("openai/<id>")` share the Grok voice factories; the `openai/` prefix selects the realtime route and switches the option namespace to `providerOptions.openai`, whose schemas are copied field-for-field from `@ai-sdk/openai` (`openAITranscriptionModelOptions`, `openaiSpeechModelOptionsSchema`, vercel/ai `fce9210`). Honored: transcription `language`, `prompt` (`gpt-realtime-whisper` rejects `prompt` with HTTP 400 from the server; `whisper-1` accepts it but the upstream ignores it); speech `voice` (one of OpenAI realtime's 10 preset voices: `alloy ash ballad coral echo sage shimmer verse marin cedar`, default `marin`; others fail with HTTP 400), `instructions`/`openai.instructions`, `outputFormat` `wav` (default) or `pcm`. Every other set key emits the AI SDK `unsupported` warning; `language` on speech reuses the official provider's warning text and an unknown `outputFormat` falls back to `wav` with a warning (the official provider falls back to `mp3`). `providerOptions.qgrid.tokenName` must carry the `openai/` prefix. Transcription input must be PCM16 WAV or raw PCM; `segments` is empty, `durationInSeconds` is computed server-side from the audio, `language` echoes the request. Speech `providerMetadata.qgrid.mediaType` is `audio/wav` or `audio/pcm;rate=24000`. Keep model unions equal to the server's candidate lists and prune both from the live matrix (`openai-codex-runtime.md`, "Realtime voice").
@@ -136,6 +136,16 @@ Key decisions:
136
136
  - `--setting-sources project` is required for shared-service isolation. User/local Claude settings can load hooks or memory and leak context across requests.
137
137
  - Claude Code OAuth prompt cache sharing across tokens in the same workspace is an observed cost behavior, not a product contract. Monitor it; do not promise it.
138
138
 
139
+ ## OpenAI Realtime Voice
140
+
141
+ Sources: `docs/plans/2026-10-17-openai-realtime-audio-plan.md`, `docs/diagnosis/2026-10-17-openai-realtime-audio-probe.md`, `docs/diagnosis/2026-11-06-openai-realtime-tts-prompt.md`, `packages/api/src/utils/providers/openai/openai-realtime-protocol.ts`.
142
+
143
+ - STT mirrors Codex’s subscription path (`/realtime/calls` + sideband) rather than the simpler ChatGPT-web `/backend-api/transcribe`: the latter was removed from Codex (PR #16114), ignores model/language/prompt, and retains uploads for 30 days.
144
+ - TTS uses the direct realtime socket, which Codex treats as API-key-only, because the `/calls` sideband carries no audio and qgrid has no RTP stack. It is the one deliberate non-Codex path; a 401/403 there means the path is gated and must fail, not fall back.
145
+ - The TTS prompt is a sectioned system prompt (role, capitalized never-answer rules, sample exchanges) with only the text, inside `<script>` tags, as the user item. The realtime models are conversational: the original one-sentence prompt let `gpt-realtime-2.1` answer 7 of 12 question-form lines, and a read-aloud instruction placed in the user item was spoken by both models. The structure follows the OpenAI Realtime Prompting Guide and the prompt engineering guide's XML delimiters; the wording is qgrid's own.
146
+ - No image-model ids were added for GPT-Image-2.5: the subscription Images route ignores the `model` field (a nonsense id returns 200 with identical usage, hosted tools echo `gpt-image-2-codex`). Re-check by sending a nonsense id; a 400 means selection became real. Rechecked 2026-11-09 for GPT-Image-2.6 Flare/Sunburst: still 200 with identical usage, and C2PA metadata names only `ChatGPT / gpt-image` (`docs/diagnosis/2026-11-09-gpt-image-2-6-probe.md`).
147
+ - Model ids are candidates pruned by the live matrix, not promises from the catalog: raw probes passed, but only the production client through qgrid decides what ships.
148
+
139
149
  ## Grok (xAI Subscription) Runtime
140
150
 
141
151
  Sources:
@@ -259,7 +269,7 @@ Sources:
259
269
 
260
270
  Key decisions:
261
271
 
262
- - Image generation is OpenAI/Codex-only and request-level opt-in outside dashboard chat. Chat explicitly opts into raw `imageGeneration: "auto"` each turn. Auto mode registers one internal `generate_image` function and calls standalone Images for ordinary and transparent backgrounds. Raw explicit chat-model `imageGeneration: true` retains its hosted route for non-transparent images. Public SDK image requests use `qgrid.image()` / `generateImage` and standalone Images for any background, following AI SDK's separate `ImageModelV3` contract. The language-model SDK has no image-generation options; the former boolean and nested options are removed without deprecated shims. Do not add a public image-tool factory or globally enable image tools for other callers: that would change their tool framing and cache behavior.
272
+ - Image generation is OpenAI/Codex-only and request-level opt-in outside dashboard chat. Chat explicitly opts into raw `imageGeneration: "auto"` each turn. Auto mode registers one internal `generate_image` function and calls standalone Images for ordinary and transparent backgrounds. Raw explicit chat-model `imageGeneration: true` also uses standalone Images for every background (2026-11-09). The hosted Responses image tool began receiving the driver's reasoning effort as an unsupported `complexity` and failing; one route keeps behavior predictable at the cost of JPEG/WebP output. Public SDK image requests use `qgrid.image()` / `generateImage` and standalone Images for any background, following AI SDK's separate `ImageModelV3` contract. The language-model SDK has no image-generation options; the former boolean and nested options are removed without deprecated shims. Do not add a public image-tool factory or globally enable image tools for other callers: that would change their tool framing and cache behavior.
263
273
  - It is non-stream only. Codex returns completed base64 image payloads, not useful image deltas.
264
274
  - Image turns send full input directly and retain no provider conversation state. This prevents base64 payloads from entering reusable state.
265
275
  - qgrid performs preflight capability/model gates. Raw `imageGeneration: true` requires an image; `"auto"` allows normal text replies but still rejects attempted image generation without a completed image. Public `generateImage` requires one direct Images output per provider call; AI SDK batches requests for `n` outputs.
@@ -273,6 +283,6 @@ The current chat design registers `generate_image` for both ordinary and transpa
273
283
 
274
284
  Image edits need complete prior image bytes, not just text history or an assumption that the backend remembers earlier outputs. Chat replays uploaded and generated images, representing generated images as user visual references because assistant `input_image` blocks are invalid. Image previews report actual extension, decoded byte size, and natural dimensions. Uploaded images describe the existing resized JPEG sent to the model; generated images retain their returned bytes.
275
285
 
276
- Model labels show requested model to image model using serving metadata or the image model encoded in the logged cost method. The cost-method fallback remains an accounting assumption, not new evidence of the upstream model version. The UI has no image-generation or assumption badge and never fixes the name to `gpt-image-2.5`. The `gpt-image-2` wire ID also does not prove Images 2.0 serving weights or selectable 2.5 variants. Hosted and auto image logs retain driver identity and token costs separately from image metadata/cost; direct `qgrid.image()` requests have no driver cost.
286
+ Model labels show requested model to image model using serving metadata or the image model encoded in the logged cost method. The cost-method fallback remains an accounting assumption, not new evidence of the upstream model version. The UI has no image-generation or assumption badge and never fixes the name to `gpt-image-2.5`. The `gpt-image-2` wire ID also does not prove Images 2.0 serving weights or selectable 2.5 variants. Auto image logs retain driver identity and token costs separately from image metadata/cost; explicit `imageGeneration: true` and direct `qgrid.image()` requests have no driver cost. Older hosted-route logs (`codex-responses`) keep their recorded driver costs.
277
287
 
278
- Prompt wording alone is not a reliable format control: a 2026-09-29 hosted-route probe returned PNG for a WebP prompt and WebP with explicit `outputFormat: "webp"`. Model prose contradicted the output and must not be used as evidence. Auto chat and standalone generation are PNG-only and reject explicit non-PNG options. Do not infer format from chat prose or introduce post-generation conversion or a hosted fallback.
288
+ Prompt wording alone is not a reliable format control: a 2026-09-29 hosted-route probe returned PNG for a WebP prompt and WebP with explicit `outputFormat: "webp"`. Model prose contradicted the output and must not be used as evidence. All OpenAI image routes are PNG-only and reject explicit non-PNG options. Do not infer format from chat prose or introduce post-generation conversion or a hosted fallback.
@@ -1,6 +1,6 @@
1
1
  # OpenAI Direct Codex Runtime
2
2
 
3
- Use this reference before changing OpenAI transport, concurrency, routing, prompt-cache affinity, OAuth, quota lookup, image generation, or cancellation.
3
+ Use this reference before changing OpenAI transport, concurrency, routing, prompt-cache affinity, OAuth, quota lookup, image generation, realtime voice, or cancellation.
4
4
 
5
5
  ## Source files
6
6
 
@@ -10,6 +10,7 @@ Use this reference before changing OpenAI transport, concurrency, routing, promp
10
10
  - SSE decoding: `openai-sse.ts`.
11
11
  - Direct PKCE OAuth and refresh: `openai-oauth.ts`, `openai-refresh.ts`, `openai-callback-relay.ts`.
12
12
  - Direct quota lookup: `openai-quota.ts`.
13
+ - Realtime voice (STT/TTS): `openai-realtime-protocol.ts`, `openai-voice-client.ts`.
13
14
  - Provider integration and history: `packages/api/src/application/qgrid/qgrid.dispatcher.ts`, `conv-routing.ts`.
14
15
 
15
16
  ## Thinking control
@@ -199,15 +200,15 @@ Quota is fetched directly from `https://chatgpt.com/backend-api/wham/usage` with
199
200
 
200
201
  OpenAI usage reports total input, cached input, output, reasoning, and total tokens for the request. Preserve cached input as a subset of input; do not add it to input again when computing cache-hit rate.
201
202
 
202
- Raw/server chat-model image requests are opt-in and non-stream to the caller, while the Responses backend still delivers its response through SSE. Explicit chat-model `imageGeneration: true` retains the hosted image tool for non-transparent requests. On that route, raw `imageGenerationOptions.outputFormat` maps to the hosted tool's `output_format` (`png`, `jpeg`, or `webp`); omission retains PNG. These are not public language-model SDK options: SDK image generation uses `qgrid.image()` / `generateImage` and calls standalone Images directly. Auto chat also calls standalone Images through its internal function and accepts PNG only. Returned bytes determine the MIME type when recognizable, with the reported format as fallback. Preserve that type through qgrid content and request-log image data URLs. Standalone Images rejects other output formats. Hosted Responses preserves observed image settings with route `codex-responses`, using PNG byte dimensions or the backend-reported JPEG/WebP size. Unreported model/settings stay absent. Image costs use reported image usage when available, otherwise the requested quality/size price table. Auto or unsupported sizes use the 1536x1024 price, and omitted quality uses medium. These are API-price estimates, not observed output settings or subscription charges.
203
+ Raw/server image requests are opt-in and non-stream to the caller. Every OpenAI image request uses standalone Images: the image model `openai/gpt-image-2`, explicit chat-model `imageGeneration: true`, and the auto chat function. These are not public language-model SDK options: SDK image generation uses `qgrid.image()` / `generateImage`. Output is PNG only. The raw `imageGenerationOptions.outputFormat` enum still accepts `jpeg`/`webp` for schema compatibility, but the API rejects them before generation. Returned bytes determine the MIME type when recognizable, with the reported format as fallback; preserve that type through qgrid content and request-log image data URLs. Image costs use reported image usage when available, otherwise the requested quality/size price table. Auto or unsupported sizes use the 1536x1024 price, and omitted quality uses medium. These are API-price estimates, not observed output settings or subscription charges.
203
204
 
204
- Hosted image accounting reads `response.completed.response.tool_usage.image_gen`, separately from the driver's top-level `response.usage`. Preserve the response-level image usage on the first hosted output only, and obtain a missing image model from the response's `tools` entry. Do not overwrite per-image observed size/quality with that entry's `auto` configuration. On 2026-10-14, a raw subscription response reported image input/output usage and `model: gpt-image-2-codex`, while echoing `quality: auto` and `size: auto` despite explicit outgoing `high`/`1024x1536`. The raw image output was medium/1037x1517. This is an upstream override; qgrid must preserve observations rather than claim the requested controls were honored. Image costs remain GPT Image 2 public-price equivalents, not subscription billing.
205
+ Until 2026-11-09, explicit chat-model requests without transparency used the hosted Responses `image_generation` tool, read image usage from `response.completed.response.tool_usage.image_gen`, and stored route `codex-responses`. A 2026-11-09 live probe found that the backend passes the driver's `reasoning.effort` to that tool as `complexity`, which the effective tool model `gpt-image-2-codex` rejects for low, medium, and high (`Complexity 'low' is not supported for this image model`). The same request without effort succeeded. qgrid therefore sends explicit chat-model requests to standalone Images and no longer registers or parses the hosted tool. Older request logs may still show route `codex-responses` and JPEG/WebP output. Evidence: `docs/diagnosis/2026-11-09-gpt-image-2-6-probe.md`.
205
206
 
206
207
  ### Standalone image routes
207
208
 
208
209
  The explicit image-model route `openai/gpt-image-2` with raw `imageGeneration: true` uses standalone Images for opaque, auto, or transparent backgrounds. It is exposed by `qgrid.image()` / AI SDK `generateImage`; the raw flag is an internal transport detail. Public `generateText` has no image-generation options. Reference inputs select `images/edits`, otherwise `images/generations`. Direct image output is PNG-only; decode and validate returned dimensions, applying the transparent-and-visible pixel requirement only when transparency was explicitly requested. Preserve returned background, quality, model, and image usage without claiming requested hints were honored. Image-model requests cannot use chat tools, structured output, auto-image mode, or streaming. The `gpt-image-2` wire identifier does not establish the serving Images version or selectable 2.5 variant.
209
210
 
210
- Raw/server chat-model requests with explicit `imageGeneration: true` and `imageGenerationOptions.background: "transparent"` switch from hosted Responses to Codex `images/generations` or `images/edits`. The same selected subscription token, cancellation deadline, in-flight tracking, and one definitive 401 refresh apply. Use JSON content negotiation; do not reuse the Responses SSE Accept header. Never replay an ambiguous generation or fall back to opaque output/IS-Net. This explicit route runs `gpt-image-2` directly, so actual model metadata differs from the requested driver ID and ordinary driver usage stays zero. Image response usage and actual settings are preserved on `generation`; usage belongs to the first output only. Costs remain explicitly estimated from public prices.
211
+ Raw/server chat-model requests with explicit `imageGeneration: true` use Codex `images/generations` or `images/edits` for every background. The same selected subscription token, cancellation deadline, in-flight tracking, and one definitive 401 refresh apply. Use JSON content negotiation; do not reuse the Responses SSE Accept header. Never replay an ambiguous generation or fall back to opaque output/IS-Net. This explicit route runs `gpt-image-2` directly, so actual model metadata differs from the requested driver ID, ordinary driver usage stays zero, and driver controls such as effort, verbosity, and prompt cache keys are not sent. Image response usage and actual settings are preserved on `generation`; usage belongs to the first output only. Costs remain explicitly estimated from public prices.
211
212
 
212
213
  The direct image request adapter preserves text/system context and reference images (maximum five), rejects unsupported structured/tool requests before generation, and validates PNG contents with pngjs. Explicit transparency requires both a fully transparent pixel and visible content; opaque or entirely empty results fail that requirement. Invalid or oversized results fail for every background. Returned dimensions come from the decoded PNG; qgrid never silently resizes. A 2026-09-08 live request returned 1254x1254/medium for requested 1024x1024/high. Do not promise exact size/quality enforcement. See `openai-image-generation.ts` and opt-in `transparent`/`transparent-edit` cases in the image smoke script.
213
214
 
@@ -221,8 +222,19 @@ Auto mode accepts text-only completion when no image tool was attempted. Explici
221
222
 
222
223
  Auto image turns preserve the Responses driver model and token usage; image model, settings, and usage remain separate generation metadata. Their combined cost is a chat-driver estimate plus an image-usage estimate. If the image stage fails after the driver completed, carry that completed driver result internally so error/aborted logs still record its usage and price once. Do not attach partial image output or claim a successful image cost. Do not apply the explicit standalone route's zero-driver accounting to auto turns. Full image history is replayed on each turn without reusable provider conversation state. Global image-tool opt-in remains unchanged outside chat to preserve regular callers' tool framing and cache behavior.
223
224
 
224
- The 2026-09-29 hosted-route probe returned PNG for a prompt-only WebP request and WebP for the raw/server option `imageGenerationOptions.outputFormat: "webp"`. Verify bytes rather than model claims. Standalone Images still returns PNG; no format conversion is added. See `output/webp-prompt-probe-2026-09-29/verification.md` and `docs/solutions/architecture-patterns/qgrid-native-auto-image-generation-2.9.8.md`.
225
+ Standalone Images returns PNG. Verify bytes rather than model claims, and add no format conversion. See `docs/solutions/architecture-patterns/qgrid-native-auto-image-generation-2.9.8.md`.
225
226
 
226
227
  ### Size hints and observed dimensions (2026-10-13)
227
228
 
228
229
  `size` accepts `auto` or positive-integer WIDTHxHEIGHT hints. Keep the requested value separate from observed output metadata; do not promise exact dimensions or inject a resize. Prompt for the desired ratio. Twelve live subscription requests across hosted Responses and standalone generation/edit returned 841x1870 for 9:20, 941x1672 for 4K portrait, and 2172x724 for 4:1 (clamped to 3:1). Explicit 1152x2560 and even 1x1 hints returned 1254x1254 for a neutral prompt. These approximately 1.57MP observations are not a universal limit. Public API limits (16-pixel multiples, up to 4K) are not the private backend contract. Latest upstream Codex at `12cca49c81c8aa6a37a5cc4e39964ee3b70f9458` hardcodes `size: auto` for image generation/editing and saves bytes without resizing.
230
+
231
+ ## Realtime voice (speech-to-text, text-to-speech)
232
+
233
+ Sources: `openai-realtime-protocol.ts` (wire constants, session builders, PCM helpers), `openai-voice-client.ts` (one-shot STT/TTS client), `OpenAIDispatcher.transcribe/speak`, `qgrid.frame.ts` `transcribeOpenAI`/`speakOpenAI`, plan `docs/plans/2026-10-17-openai-realtime-audio-plan.md`, matrix `docs/diagnosis/2026-10-17-openai-realtime-audio-probe.md`.
234
+
235
+ `openai/<id>` on `POST /api/qgrid/transcribe` and `/speak` runs OpenAI realtime sessions with the same ChatGPT subscription tokens as Codex. The request shape mirrors `openai/codex` main (2026-10-17); each constant in `openai-realtime-protocol.ts` cites its Codex source line. Keep that fidelity: no `OpenAI-Beta` header (the server answers `beta_api_shape_disabled` for `realtime=v1`), no `openai-alpha`, no `intent=quicksilver` query. Headers are `Authorization`, `ChatGPT-Account-Id`, `originator`, `User-Agent`, `x-session-id`, `voice-session-id`, `session-id`, `thread-id`, identical on the POST and both WebSockets.
236
+
237
+ - STT is the Codex subscription path: `POST https://chatgpt.com/backend-api/codex/realtime/calls` with `{sdp, session}` (synthetic Opus-only SDP offer; the transcription session is Codex's exact V2 shape), `201` + `Location: /v1/realtime/calls/rtc_…`, then a sideband `wss://api.openai.com/v1/realtime?call_id=…`. Per-request `language`/`prompt` and `turn_detection: null` go in a sideband `session.update`; audio goes as 1 s `input_audio_buffer.append` chunks plus one `commit`; the result is `conversation.item.input_audio_transcription.completed`. A call with no ICE connection is torn down about 30 s after creation (25 s idle fine, 31 s gone), so the client enforces a 25 s deadline from the POST. When that attempt ends in teardown (deadline, sideband closed/errored or handshake rejected before the transcript — `isSidebandTeardownError`), the client retries once on the direct `wss://api.openai.com/v1/realtime?intent=transcription` socket with the same headers and session (`OpenAIVoiceClientOptions.sttDirectFallback`, default on; 60 s bound). Server `error` events and `/calls` 4xx never trigger the fallback. The request log records `transport` (`realtime-calls` | `realtime-ws`) and `fallbackReason`; `callId` and quota headers are absent after a fallback. The direct socket is the same non-Codex path as TTS, so a 401/403 there means it was gated. Input must already be PCM16: WAV (`audio/wav`) or raw PCM (`audio/pcm;rate=…;channels=…`), downmixed and linearly resampled to 24 kHz mono like Codex's `convert_pcm16`; compressed input is a 400. The server reports no language or duration: `durationSec` is computed from the PCM sent and `language` echoes the request.
238
+ - TTS is the one deviation from Codex. The `/calls` sideband never carries `response.output_audio.delta` (media stays on RTP, verified twice), and qgrid has no RTP stack, so speech uses the direct `wss://api.openai.com/v1/realtime?model=<id>` socket, which Codex itself treats as API-key-only (`realtime_conversation.rs:1931-1955`) but which accepts the ChatGPT bearer today. The session is Codex's V2 conversational payload minus `tools`, with a verbatim-reading system prompt (labeled `# Role & Objective` / `# Rules` / `# Examples` sections with capitalized never-answer rules; the caller's `instructions` follow as `# Style`), the text wrapped in `<script>…</script>` as the one `conversation.item.create` user item, and `response.create`; the output is concatenated PCM16 24 kHz returned as WAV (default) or raw PCM. OpenAI realtime has 10 preset voices, matching the Codex v2 list (`alloy ash ballad coral echo sage shimmer verse marin cedar`, default `marin`); others fail with 400. The model's own `response.output_audio_transcript.done` and `response.done.usage` audio/text tokens are logged with the request for fidelity checks. Treat a 401/403 on this socket as the path being gated: fail with the upstream error, do not fall back.
239
+ - Dispatcher: `OpenAIDispatcher.runVoice` selects a token with the same quota gate as Responses, refreshes once on a 401 and retries once, and invalidates the rate-limit cache afterwards. `OpenAIVoiceInputError` (unsupported audio, bad voice, empty text) becomes HTTP 400 `qgrid.openaiVoiceInvalidRequest`; everything else propagates as an upstream failure.
240
+ - Exposed ids (user decision 2026-10-17: keep every reachable id, document limits): STT `gpt-4o-mini-transcribe`, `gpt-4o-transcribe`, `gpt-transcribe` (4/4 on the matrix), `gpt-live-transcribe` and `gpt-realtime-whisper` (return about half of a 60 s clip; whisper also mangles Korean), `whisper-1` (ignores `prompt`). `gpt-realtime-whisper` rejects `prompt` upstream, so `OPENAI_TRANSCRIPTION_MODELS_WITHOUT_PROMPT` makes the client fail with a 400 before the realtime call. TTS `gpt-realtime-2.1-mini` (13/13 verbatim, default), `gpt-realtime-2.1` (12/13), `gpt-realtime-1.5` (6/13, often answers instead of repeating) on the 2026-10-17 statement texts. Realtime models are conversational and answer text addressed to the listener: on question-form character lines the original one-sentence prompt let `gpt-realtime-2.1` answer 7 of 12, while the current sectioned prompt with `<script>` delimiters read 12/12 on both 2.1 and 2.1-mini (`docs/diagnosis/2026-11-06-openai-realtime-tts-prompt.md`; 1.5 not re-run). Keep every instruction in the system prompt: an instruction placed in the user item was read aloud. Model behavior is tracked by the live matrix (`OPENAI_LIVE=1 pnpm tsx scripts/live-openai-voice-matrix.ts`, results in `docs/diagnosis/2026-10-17-openai-realtime-audio-probe.md`). Remove an id from `OPENAI_TRANSCRIPTION_MODELS`/`OPENAI_SPEECH_MODELS`, the SDK unions, and the READMEs together when it stops passing. Unavailable on subscription (verified 2026-10-17): `/backend-api/codex/audio/transcriptions`, `/audio/speech`, `gpt-4o-mini-tts`, `tts-1*`, `gpt-transcribe` via `/codex/responses`, Responses `input_audio`. The ChatGPT-web `POST /backend-api/transcribe` works but is not used (removed from Codex in PR #16114, ignores model/language, retains uploads 30 days).
@@ -94,14 +94,19 @@ OpenAI uses the completed Responses event's per-request usage fields.
94
94
 
95
95
  Anthropic normalizes native mutually exclusive categories by summing input + cache creation + cache read into total input. Prefer positive Claude Code `total_cost_usd`; otherwise calculate from the actual serving model and TTL split.
96
96
 
97
- For image requests, keep `cost_usd` as the Codex driver model token cost. Hosted image usage comes from `response.tool_usage.image_gen`, separately from the driver's `response.usage`. Explicit standalone Images requests, including `qgrid.image()`, run no driver and report zero driver usage/cost. Auto image turns preserve the Responses driver model and usage for every background while keeping standalone image usage/settings separately. Image usage and actual settings are preserved as `observedGeneration` alongside `requestedOptions` in the synthetic tool log. Price reported image usage at public token rates; only fall back to requested quality/size estimates when usage is absent. Display combined driver and image costs as dollar amounts without Cost labels; omit pricing disclaimers and cost-source metadata from the dashboard. Treat `image_cost_usd` as an API-price estimate, not subscription billing.
97
+ For image requests, keep `cost_usd` as the Codex driver model token cost. Explicit image requests, whether a chat model with `imageGeneration: true` or `qgrid.image()`, call standalone Images, run no driver, and report zero driver usage/cost. Older hosted-route rows (`codex-responses`) recorded image usage from `response.tool_usage.image_gen` alongside the driver's usage. Auto image turns preserve the Responses driver model and usage for every background while keeping standalone image usage/settings separately. Image usage and actual settings are preserved as `observedGeneration` alongside `requestedOptions` in the synthetic tool log. Price reported image usage at public token rates; only fall back to requested quality/size estimates when usage is absent. Display combined driver and image costs as dollar amounts without Cost labels; omit pricing disclaimers and cost-source metadata from the dashboard. Treat `image_cost_usd` as an API-price estimate, not subscription billing.
98
98
 
99
- For `imageGeneration: "auto"`, set `is_image_generation` only when returned content actually contains an image; offering the `generate_image` function is not sufficient. Keep stored `model_name` as the driver for hosted and auto image turns. Dashboard requested-to-image labels can derive the image model from serving/image-cost metadata without changing the stored driver or adding image-generation/assumption badges.
99
+ For `imageGeneration: "auto"`, set `is_image_generation` only when returned content actually contains an image; offering the `generate_image` function is not sufficient. Keep stored `model_name` as the driver for auto image turns and older hosted-route rows. Dashboard requested-to-image labels can derive the image model from serving/image-cost metadata without changing the stored driver or adding image-generation/assumption badges.
100
100
 
101
101
  If the auto image stage fails or is cancelled after the chat driver has completed, preserve the completed driver result as internal failure metadata. The frame converts it with the same usage/pricing mapper used on success; terminal logging writes one generate step before aggregating the run and retains the actual/requested model and token. The parent remains `error` or `aborted` with the original error message. Do not write a completed image step, invent an image cost, expose failure metadata in the HTTP error, or record this step again on success. A driver that never completed and a direct image-only call have no completed chat usage to retain. `logger: false` still creates no logs. Log-writing failures must not replace the original generation failure.
102
102
 
103
103
  Input images are not stored in `request_logs.user_prompt`; that field remains the text prompt. `beforeQuery` stores the current turn's `args.input` images on the run as `request_logs.input_images` (`{ mediaType, data, byteSize }` or `{ url }`), for text and image runs alike. Earlier-turn images in `history` stay in `request_logs.history`. For inspection in the detail view, qgrid stores reference image metadata/base64 in the synthetic `image_generation` step's `tool_args.inputImages`. If Codex returns multiple image outputs, store `inputImages` only on the first synthetic image tool step so multi-output logs do not duplicate the same input payload on every output.
104
104
 
105
+ ## Media fields
106
+
107
+ - `media_kind`: nullable enum (`image`, `video`, `stt`, `tts`) written at `createRun` by `startMediaRun` from the media endpoint's kind; text and chat runs keep NULL (chat-generated images are marked only by `is_image_generation`). The list `Fmt` column reads it, so any new media endpoint must open its run through `startMediaRun` or set it explicitly.
108
+ - Speech `response`: browser-playable audio is embedded as an `<audio>` data URL (see `sonamu-api-web-flow.md`); speech `ttft_ms` is the first audio byte, passed explicitly to `finishRun` because media runs have no generate step to derive it from.
109
+
105
110
  ## Structured output fields
106
111
 
107
112
  Structured output requests (those carrying a `jsonSchema`) persist three related fields:
@@ -58,11 +58,15 @@ Provider-qualified ids widen `model_name` and `requested_model_name` from 50 to
58
58
 
59
59
  Image-generation request logs add `is_image_generation`, `image_cost_usd`, and `image_cost_method`. The list view displays driver plus image cost as the total cost cell; the detail view shows driver cost and image cost separately and renders generated image data URLs from response/tool-step content.
60
60
 
61
- In 2.9.8, list and detail model labels show requested model to image model for generated-image results, using an image serving model or the model recorded in `image_cost_method`. The cost fallback is an estimate, not an upstream version guarantee. Preserve the actual driver in stored `model_name` for hosted/auto turns. Do not hardcode a display version or render an image-generation/assumption badge. Auto text-only replies are not marked `is_image_generation`.
61
+ In 2.9.8, list and detail model labels show requested model to image model for generated-image results, using an image serving model or the model recorded in `image_cost_method`. The cost fallback is an estimate, not an upstream version guarantee. Preserve the actual driver in stored `model_name` for auto turns and older hosted-route rows. Do not hardcode a display version or render an image-generation/assumption badge. Auto text-only replies are not marked `is_image_generation`.
62
62
 
63
63
  The list header ends its filter row with a reload button (2.10.2+) that calls the generated hooks' `refresh()` for the list and the total-cost query with the current filters; it does not refetch the token/project/model filter options, and TanStack Query's `isRefreshing` disables it while a reload is in flight.
64
64
 
65
- Structured output visibility: the list has an `Fmt` column (`img` when `is_image_generation` is true, otherwise `json` when `is_structured` is true, otherwise `text`) and a `broken` badge driven by `response_json_ok = false`; there is no broken-JSON list filter. At review time, all 114,647 succeeded structured rows had `response_json_ok = true` and zero false rows existed; the unindexed zero-result lookup scanned 1,286,016 rows and took about 3 seconds. Before reinstating the filter, validate the failure-signal semantics and index the predicate. The detail page shows a dark Response Type panel (zod expression by default, `type` declaration via toggle) rendered server-side from the stored `json_schema`. Plain-text rows render no panel. Rows written by pre-2.7.2 servers show `text`.
65
+ Structured output visibility: the list has an `Fmt` column (`voice/stt` or `voice/tts` when `media_kind` is `stt` or `tts`, `video` when it is `video`, otherwise `img` when `is_image_generation` is true, otherwise `json` when `is_structured` is true, otherwise `text`) and a `broken` badge driven by `response_json_ok = false`; there is no broken-JSON list filter. At review time, all 114,647 succeeded structured rows had `response_json_ok = true` and zero false rows existed; the unindexed zero-result lookup scanned 1,286,016 rows and took about 3 seconds. Before reinstating the filter, validate the failure-signal semantics and index the predicate. The detail page shows a dark Response Type panel (zod expression by default, `type` declaration via toggle) rendered server-side from the stored `json_schema`. Plain-text rows render no panel. Rows written by pre-2.7.2 servers show `text`.
66
+
67
+ Media rows (2.15.5+): `startMediaRun` writes the nullable `media_kind` column (`image`, `video`, `stt`, `tts`) at `createRun`; text runs keep it NULL, and media rows written before the column stay NULL and show their old `Fmt` label (no backfill). Speech rows store browser-playable audio (`audio/wav`, `audio/mpeg`) in `response` as `<audio src="data:...;base64,..."></audio>`, the same inline pattern image rows use, and the detail page renders it as an `<audio controls>` player; OpenAI `pcm` output is wrapped as WAV for the log copy only, while Grok `pcm`/`mulaw`/`alaw` keep the `[audio <mime> <bytes> bytes]` placeholder. The audio is stored once, not repeated in the `speech` step result. Speech `ttft_ms` is time to the first audio byte measured from the same start as `duration_ms`: the first `response.output_audio.delta` for OpenAI realtime, response-header arrival for Grok `/tts` (not streamed, so it is close to the full duration). `finishRun` takes an explicit `ttft_ms` for runs without generate steps and otherwise derives it from the first generate step. STT rows record no TTFT and store no input audio.
68
+
69
+ Voice playground (2.15.5+): the sidebar's Playground section links `/voice`, a dashboard-only test page with Text to speech and Speech to text panels that call the generated `QgridService.useSpeakMutation` / `useTranscribeMutation` with project name `qgrid_voice`; no API was added. Voice lists are web constants: OpenAI's 10 realtime presets and the 28 Grok `/tts` voices (9 female, 19 male) listed for the subscription token on 2026-11-06; the server still validates them. Instructions and the STT prompt are shown only for `openai/` models. STT sends no `language`: a 2026-11-09 run (6 OpenAI STT models × auto/en/ko × 6 synthetic learner clips) found `en` no better than auto and `ko` translating English audio into Korean on gpt-4o-transcribe and whisper-1. The STT model list keeps only `openai/gpt-4o-transcribe` (default), `openai/gpt-4o-mini-transcribe`, and the unmeasured `grok/grok-voice-transcribe-2.0`; the server still accepts the other ids. The page is one card with Text to speech / Speech to text tabs; both panels stay mounted (the inactive one is hidden) so form state and history survive tab switches. Each result is prepended to an in-memory history row (removable, lost on reload) with a request-log link that opens in a new tab so the history is kept. TTS voices are chips (Grok split Female/Male) above the text: a name selects the voice, and ▶ plays a bundled sample from `packages/web/public/voice-samples/{openai,grok}/<voice>.mp3` without a request (and selects it; pressing again stops). Each of the 38 samples introduces itself ("I'm <Voice>. Nice to meet you. How's it going?"), regenerated on 2026-11-09 through qgrid (`grok/grok-tts`, `openai/gpt-realtime-2.1-mini`) and checked with STT; re-encoded to 40 kbps mono MP3 (about 640 KB, shipped in the CLI bundle via `web-dist`). Do not trust the OpenAI speech self-transcript as a verbatim check: one ballad take carried an audible "Okay, let's read that line aloud exactly as written." preamble that two STT models heard while `response.output_audio_transcript.done` showed only the script. A voice added upstream needs a sample file or its ▶ fails to load. STT recordings and uploads are numbered clips so one clip run through several models reads as a comparison. Recordings (MediaRecorder webm/opus) and uploads are decoded with `AudioContext` at 24 kHz, mixed to mono, and sent as PCM16 WAV (`voice-audio.ts`), because the OpenAI transcription route accepts only WAV or raw PCM. Results link to their request log.
66
70
 
67
71
  Tool contract visibility: the detail page renders a Tools panel between Response Type and Steps for requests whose `tools` is non-empty. It starts collapsed and its header shows the tool count plus a responsive, truncated name list built from the detail subset — collapsed views issue no extra query. Expanding fires `toolsView` once and caches it for that request id, since a stored tool contract never changes. Each card shows the name, the full description, the parameter count, and a compact display-only zod shape; enum values past the sixth collapse to `/* +N */`, with the full shape reachable through hover and keyboard focus. All JSON Schema conversion happens server-side — the web renders completed strings and holds no schema logic.
68
72
 
@@ -139,11 +139,11 @@ Image generation:
139
139
  - Human-initiated only.
140
140
  - Requires active OpenAI token with image entitlement and applicable migration.
141
141
  - For 2.9.8 chat, verify the actual browser POST and served bundle, not only a direct function test. A globally installed CLI on port 44900 can serve stale assets while repository tests pass; identify the listening process and its executable before assuming a rebuild or refresh affects it.
142
- - Cover auto text-only replies and the single server-side `generate_image` function for ordinary generation and transparent editing. Zero selected references must create a fresh image despite older history; positive counts must select only the last N conversation images in order, up to five. Explicit raw `true` must retain its image-required hosted behavior for non-transparent chat-model requests. Verify driver usage stays separate from image usage and auto text replies are not image logs.
143
- - Verify extension, decoded bytes, and natural dimensions in chat image previews. A format request in prose is not evidence: the 2026-09-29 hosted-route WebP probe returned PNG from a prompt-only request and WebP from explicit `outputFormat: "webp"`. Auto chat and standalone output remain PNG-only and must reject explicit non-PNG options.
142
+ - Cover auto text-only replies and the single server-side `generate_image` function for ordinary generation and transparent editing. Zero selected references must create a fresh image despite older history; positive counts must select only the last N conversation images in order, up to five. Explicit raw `true` on a chat model must still require an image and call standalone Images directly, including when the request carries `effort`. Verify driver usage stays separate from image usage and auto text replies are not image logs.
143
+ - Verify extension, decoded bytes, and natural dimensions in chat image previews. A format request in prose is not evidence. All OpenAI image routes are PNG-only and must reject explicit non-PNG options.
144
144
  - Requires `QGRID_REAL_PROVIDER_ACCEPTANCE=1`, explicit `QGRID_URL` and `QGRID_OPENAI_MODEL`. Optional `QGRID_TOKEN_NAME` pins a subscription token. `QGRID_IMAGE_SMOKE_CASES` selects named cases; the default covers eight images plus text, rejected inputs, and cancellation. Optional `batch`, `logger-off`, and `cancel-direct` cover SDK batching, no-log calls, and cancellation during direct Images requests. Never replay generations automatically.
145
145
  - Set `QGRID_IMAGE_E2E_OUTPUT` for PNGs and sanitized usage/cost/log evidence; `QGRID_IMAGE_E2E_PROJECT` groups test logs. Use an isolated DB and access-only test token, with notifications and keepalive disabled. For final acceptance, build the current API and cold-start `sonamu start` against that isolated DB rather than relying on HMR. HMR can leave a fresh dispatcher uninitialized; readiness alone does not prove the intended module version. The suite checks readiness before live calls.
146
- - Subscription `response.completed.tool_usage.image_gen` can be present with all-zero usage for text-only or function-tool replies. This metadata alone is not a hosted image execution. Keep the zero-usage regression test and verify auto text against the real backend.
146
+ - Subscription `response.completed.tool_usage.image_gen` can be present with all-zero usage for text-only or function-tool replies. qgrid no longer parses it. Keep the regression test that auto text replies carrying this metadata stay text-only, and verify auto text against the real backend.
147
147
  - Run auto text and generation with both Luna and Astra when changing the internal tool schema. Astra's private backend failed with `strict: true` even with bounds removed, while the same schema succeeded with `strict: false`. Keep `strict: false` and server-side validation; do not add a runtime fallback/retry.
148
148
  - Not part of CI; it consumes ChatGPT subscription quota.
149
149