@cartanova/qgrid-cli 2.14.1 → 2.15.2
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.
- package/bundle/dist/application/qgrid/qgrid.frame.js +3 -2
- package/bundle/dist/application/request-log/request-log-cost.js +59 -0
- package/bundle/dist/application/request-log/request-log.model.js +55 -85
- package/bundle/dist/utils/providers/common/model-cost.js +10 -1
- package/bundle/dist/utils/providers/openai/openai-dispatcher.js +3 -2
- package/bundle/src/application/request-log/request-log-cost.test.ts +40 -0
- package/bundle/src/application/request-log/request-log-cost.ts +103 -0
- package/bundle/src/application/request-log/request-log.model.test.ts +121 -123
- package/bundle/src/application/request-log/request-log.model.ts +70 -167
- package/bundle/src/utils/providers/common/effort.test.ts +1 -0
- package/bundle/src/utils/providers/common/model-cost.test.ts +5 -0
- package/bundle/src/utils/providers/common/model-cost.ts +12 -0
- package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +7 -6
- package/bundle/src/utils/providers/openai/openai-dispatcher.ts +3 -1
- package/bundle/web-dist/client/assets/{index-jExDfi8j.js → index-VhUpqKIg.js} +3 -3
- package/bundle/web-dist/client/assets/logs-BwSzVf_A.js +1 -0
- package/bundle/web-dist/client/assets/{monit-CGTRk2U0.js → monit-B2CVdIml.js} +1 -1
- package/bundle/web-dist/client/assets/{routes-D9l20OWa.js → routes-BOOXpy3Q.js} +1 -1
- package/bundle/web-dist/client/assets/{settings-D2zIv0xR.js → settings-B_a3Nr0H.js} +1 -1
- package/bundle/web-dist/client/assets/{show-DefwCScC.js → show-D5Uxcb4a.js} +1 -1
- package/bundle/web-dist/client/assets/{tokens-CbmIxMZ9.js → tokens-zlrqnP63.js} +1 -1
- package/bundle/web-dist/client/assets/{use-oauth-login-flow-CEufhZcR.js → use-oauth-login-flow-qR-56G2w.js} +1 -1
- package/bundle/web-dist/client/assets/{use-update-token-mutation-E5ey27W6.js → use-update-token-mutation-B-vcLRx-.js} +1 -1
- package/bundle/web-dist/client/index.html +1 -1
- package/bundle/web-dist/server/assets/{logs-C0md5rmp.js → logs-6289J29J.js} +17 -4
- package/bundle/web-dist/server/entry-server.generated.js +3 -2
- package/package.json +1 -1
- package/skills/qgrid/references/ai-sdk-provider-contract.md +1 -1
- package/skills/qgrid/references/docs-workflow.md +10 -0
- package/skills/qgrid/references/openai-codex-runtime.md +22 -5
- package/skills/qgrid/references/sonamu-api-web-flow.md +1 -1
- package/bundle/web-dist/client/assets/logs-ol_IGjcT.js +0 -1
|
@@ -25,6 +25,12 @@ import { type RequestLogStepSaveParams } from "../request-log-step/request-log-s
|
|
|
25
25
|
import { type RequestLogSubsetKey, type RequestLogSubsetMapping } from "../sonamu.generated";
|
|
26
26
|
import { requestLogLoaderQueries, requestLogSubsetQueries } from "../sonamu.generated.sso";
|
|
27
27
|
import { renderJsonSchemaZodText, renderParsedJsonSchemaTypeText } from "./json-schema-type-text";
|
|
28
|
+
import {
|
|
29
|
+
MICRO_USD,
|
|
30
|
+
normalizedUsageForCost,
|
|
31
|
+
resolvePricingCost,
|
|
32
|
+
type RequestLogUsageRow,
|
|
33
|
+
} from "./request-log-cost";
|
|
28
34
|
import {
|
|
29
35
|
type HistoryItems,
|
|
30
36
|
type RequestLogListParams,
|
|
@@ -35,8 +41,8 @@ import {
|
|
|
35
41
|
} from "./request-log.types";
|
|
36
42
|
import { formatZodCode } from "./zod-code-format";
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
export { MICRO_USD };
|
|
45
|
+
|
|
40
46
|
const REQUEST_LOG_RUN_LOCK_CLASS_ID = 718;
|
|
41
47
|
const TOOL_ENUM_VALUE_LIMIT = 6;
|
|
42
48
|
|
|
@@ -178,27 +184,6 @@ function aggregateGenerateStepRows(rows: StepAggregateRow[]): RequestLogStepAggr
|
|
|
178
184
|
return aggregate;
|
|
179
185
|
}
|
|
180
186
|
|
|
181
|
-
type RequestLogUsageRow = {
|
|
182
|
-
token_name?: string | null;
|
|
183
|
-
model_name?: string | null;
|
|
184
|
-
input_tokens: number;
|
|
185
|
-
output_tokens: number;
|
|
186
|
-
cache_read_tokens: number;
|
|
187
|
-
cache_creation_tokens: number;
|
|
188
|
-
cache_creation_5m_tokens?: number | null;
|
|
189
|
-
cache_creation_1h_tokens?: number | null;
|
|
190
|
-
cost_usd?: number | null;
|
|
191
|
-
cost_source?: string | null;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
function isAnthropicUsageRow(row: Pick<RequestLogUsageRow, "token_name" | "model_name">): boolean {
|
|
195
|
-
return (
|
|
196
|
-
row.token_name?.startsWith("anthropic/") === true ||
|
|
197
|
-
row.model_name?.startsWith("claude-") === true ||
|
|
198
|
-
row.model_name?.startsWith("anthropic/claude-") === true
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
187
|
/** Provider of a provider-qualified model id (`openai/`, `anthropic/`, `grok/`); legacy ids are unknown. */
|
|
203
188
|
export function providerOfModelName(modelName: string | null | undefined): ProviderId | "unknown" {
|
|
204
189
|
const slash = modelName?.indexOf("/") ?? -1;
|
|
@@ -207,47 +192,6 @@ export function providerOfModelName(modelName: string | null | undefined): Provi
|
|
|
207
192
|
return isProviderId(prefix) ? prefix : "unknown";
|
|
208
193
|
}
|
|
209
194
|
|
|
210
|
-
function canonicalModelName(modelName: string): string {
|
|
211
|
-
return modelName.includes("/") ? modelName.split("/").pop()! : modelName;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
interface UsageForCost {
|
|
215
|
-
model: string | null;
|
|
216
|
-
inputTokens: number;
|
|
217
|
-
outputTokens: number;
|
|
218
|
-
cachedInputTokens: number;
|
|
219
|
-
cacheCreationInputTokens: number;
|
|
220
|
-
cacheCreationInputTokens5m?: number;
|
|
221
|
-
cacheCreationInputTokens1h?: number;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function normalizedUsageForCost(row: RequestLogUsageRow): UsageForCost {
|
|
225
|
-
const cacheRead = row.cache_read_tokens;
|
|
226
|
-
const cacheCreation = row.cache_creation_tokens;
|
|
227
|
-
const storedInput = row.input_tokens;
|
|
228
|
-
|
|
229
|
-
const legacyAnthropicSplitInput =
|
|
230
|
-
isAnthropicUsageRow(row) && storedInput < cacheRead + cacheCreation;
|
|
231
|
-
|
|
232
|
-
const usage: UsageForCost = {
|
|
233
|
-
model: row.model_name ? canonicalModelName(row.model_name) : null,
|
|
234
|
-
inputTokens: legacyAnthropicSplitInput ? storedInput + cacheRead + cacheCreation : storedInput,
|
|
235
|
-
outputTokens: row.output_tokens,
|
|
236
|
-
cachedInputTokens: cacheRead,
|
|
237
|
-
cacheCreationInputTokens: cacheCreation,
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
if (row.cache_creation_5m_tokens !== null && row.cache_creation_5m_tokens !== undefined) {
|
|
241
|
-
usage.cacheCreationInputTokens5m = row.cache_creation_5m_tokens;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (row.cache_creation_1h_tokens !== null && row.cache_creation_1h_tokens !== undefined) {
|
|
245
|
-
usage.cacheCreationInputTokens1h = row.cache_creation_1h_tokens;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return usage;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
195
|
function normalizeLegacyAnthropicRow<T extends RequestLogUsageRow>(row: T): T {
|
|
252
196
|
// 새 row 는 당시의 provider/가격표 비용을 확정 저장한다. 현재 가격표로 덮어쓰지 않는다.
|
|
253
197
|
if (row.cost_source) return row;
|
|
@@ -429,8 +373,8 @@ class RequestLogModelClass extends BaseModelClass<
|
|
|
429
373
|
async save(spa: RequestLogSaveParams[]): Promise<number[]> {
|
|
430
374
|
const wdb = this.getPuri("w");
|
|
431
375
|
|
|
432
|
-
// register
|
|
433
|
-
for (const sp of spa) wdb.ubRegister("request_logs", sp);
|
|
376
|
+
// register — 출처 없는 비용은 finishRun 과 같은 규칙으로 쓰기 시점에 확정한다.
|
|
377
|
+
for (const sp of spa) wdb.ubRegister("request_logs", { ...sp, ...resolvePricingCost(sp) });
|
|
434
378
|
|
|
435
379
|
// transaction
|
|
436
380
|
return wdb.transaction(async (trx) => {
|
|
@@ -701,10 +645,10 @@ class RequestLogModelClass extends BaseModelClass<
|
|
|
701
645
|
if (params.history !== undefined) update.history = params.history;
|
|
702
646
|
update.ttft_ms = (await this.firstGenerateStepTtft(requestLogId)) ?? 0;
|
|
703
647
|
|
|
704
|
-
// 서버 run 경로는 step 에서 확정한 exact cost
|
|
705
|
-
//
|
|
648
|
+
// 서버 run 경로는 step 에서 확정한 exact cost 와 출처를 넘긴다. 출처 없이 끝난 외부/legacy
|
|
649
|
+
// run 은 저장된 모델+usage 로 여기서 확정해, 읽기 경로가 다시 계산하지 않게 한다.
|
|
706
650
|
if (
|
|
707
|
-
params.
|
|
651
|
+
(params.cost_source === undefined || params.cost_source === null) &&
|
|
708
652
|
params.input_tokens !== undefined &&
|
|
709
653
|
params.output_tokens !== undefined
|
|
710
654
|
) {
|
|
@@ -714,34 +658,19 @@ class RequestLogModelClass extends BaseModelClass<
|
|
|
714
658
|
.where("id", requestLogId)
|
|
715
659
|
.first();
|
|
716
660
|
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
cache_creation_1h_tokens: params.cache_creation_1h_tokens,
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
update.cost_usd = Math.round(
|
|
734
|
-
calculateCostUsd(model, {
|
|
735
|
-
inputTokens: usage.inputTokens,
|
|
736
|
-
outputTokens: usage.outputTokens,
|
|
737
|
-
cachedInputTokens: usage.cachedInputTokens,
|
|
738
|
-
cacheCreationInputTokens: usage.cacheCreationInputTokens,
|
|
739
|
-
cacheCreationInputTokens5m: usage.cacheCreationInputTokens5m,
|
|
740
|
-
cacheCreationInputTokens1h: usage.cacheCreationInputTokens1h,
|
|
741
|
-
}) * 1_000_000,
|
|
742
|
-
);
|
|
743
|
-
update.cost_source = "pricing_table";
|
|
744
|
-
}
|
|
661
|
+
const resolved = resolvePricingCost({
|
|
662
|
+
token_name: params.token_name,
|
|
663
|
+
model_name: params.model_name ?? row?.model_name,
|
|
664
|
+
input_tokens: params.input_tokens,
|
|
665
|
+
output_tokens: params.output_tokens,
|
|
666
|
+
cache_read_tokens: params.cache_read_tokens ?? 0,
|
|
667
|
+
cache_creation_tokens: params.cache_creation_tokens ?? 0,
|
|
668
|
+
cache_creation_5m_tokens: params.cache_creation_5m_tokens,
|
|
669
|
+
cache_creation_1h_tokens: params.cache_creation_1h_tokens,
|
|
670
|
+
cost_usd: params.cost_usd,
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
if (resolved) Object.assign(update, resolved);
|
|
745
674
|
}
|
|
746
675
|
|
|
747
676
|
const wdb = this.getPuri("w");
|
|
@@ -882,7 +811,26 @@ class RequestLogModelClass extends BaseModelClass<
|
|
|
882
811
|
expiry.fallback_count = aggregate.fallback_count;
|
|
883
812
|
expiry.cost_usd = aggregate.cost_usd;
|
|
884
813
|
|
|
885
|
-
if (aggregate.cost_source !== undefined)
|
|
814
|
+
if (aggregate.cost_source !== undefined) {
|
|
815
|
+
expiry.cost_source = aggregate.cost_source;
|
|
816
|
+
} else {
|
|
817
|
+
// 출처 없는 외부 step 만 있던 run 은 만료 시점에 가격표 비용으로 확정한다.
|
|
818
|
+
const run = await wdb
|
|
819
|
+
.from("request_logs")
|
|
820
|
+
.select({ token_name: "token_name", model_name: "model_name" })
|
|
821
|
+
.where("id", requestLogId)
|
|
822
|
+
.first();
|
|
823
|
+
|
|
824
|
+
Object.assign(
|
|
825
|
+
expiry,
|
|
826
|
+
resolvePricingCost({
|
|
827
|
+
...aggregate,
|
|
828
|
+
token_name: run?.token_name,
|
|
829
|
+
model_name: run?.model_name,
|
|
830
|
+
}),
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
|
|
886
834
|
expiry.ttft_ms = firstTtft?.ttft_ms ?? 0;
|
|
887
835
|
|
|
888
836
|
const updated = await wdb
|
|
@@ -942,12 +890,9 @@ class RequestLogModelClass extends BaseModelClass<
|
|
|
942
890
|
/**
|
|
943
891
|
* 화면 표시용 총 비용. 목록과 같은 필터를 적용한다.
|
|
944
892
|
*
|
|
945
|
-
* driver와 image
|
|
946
|
-
*
|
|
947
|
-
*
|
|
948
|
-
* legacy 보정을 남겨둔 이유: 백필로 기존 legacy 는 0 이 되었지만, 외부 로거가
|
|
949
|
-
* `AppendStepInput`/`FinishRunInput` 으로 costSource 없이 넣으면 다시 생길 수 있다.
|
|
950
|
-
* 그런 row 는 저장값 대신 현재 가격표 재계산값이 맞으므로 차액을 더한다.
|
|
893
|
+
* driver와 image 비용 저장값을 SQL로 한 번 합산한다. 출처 없는 driver 비용은 쓰기 시점에
|
|
894
|
+
* `resolvePricingCost`로 확정하고 기존 row 는 백필로 확정했으므로, 읽을 때 가격표로 다시
|
|
895
|
+
* 계산하지 않는다(`scripts/backfill-request-log-costs.ts` dry-run 으로 보정 0 을 확인).
|
|
951
896
|
*
|
|
952
897
|
* 필터 조건을 여기서 다시 구현하지 않고 `applyListFilters` 를 공유하는 것이 핵심이다 —
|
|
953
898
|
* 두 쿼리가 각자 필터를 가지면 화면에서 필터를 걸었을 때 행 수와 비용이 조용히 어긋난다.
|
|
@@ -975,7 +920,7 @@ class RequestLogModelClass extends BaseModelClass<
|
|
|
975
920
|
// executeCountQuery 와 같은 방식으로 select 를 비우고 집계만 남긴다.
|
|
976
921
|
const stored = await totalQb
|
|
977
922
|
.clear("select")
|
|
978
|
-
// 음수 저장값(과거 버그)은 0 으로 눌러서
|
|
923
|
+
// 음수 저장값(과거 버그)은 0 으로 눌러서 더한다.
|
|
979
924
|
.select({
|
|
980
925
|
total: Puri.rawNumber(
|
|
981
926
|
"COALESCE(SUM(GREATEST(request_logs.cost_usd, 0) + COALESCE(request_logs.image_cost_usd, 0)), 0)",
|
|
@@ -987,81 +932,39 @@ class RequestLogModelClass extends BaseModelClass<
|
|
|
987
932
|
})
|
|
988
933
|
.first();
|
|
989
934
|
|
|
990
|
-
const { qb: legacyQb } = this.getSubsetQueries("C");
|
|
991
|
-
this.applyListFilters(legacyQb, params);
|
|
992
|
-
this.applySonamuFilters(legacyQb, sonamuFilter);
|
|
993
|
-
|
|
994
|
-
const legacyRows = await legacyQb
|
|
995
|
-
.whereRaw("request_logs.cost_source IS NULL OR request_logs.cost_usd IS NULL")
|
|
996
|
-
.clear("select")
|
|
997
|
-
.select({
|
|
998
|
-
token_name: "request_logs.token_name",
|
|
999
|
-
model_name: "request_logs.model_name",
|
|
1000
|
-
input_tokens: "request_logs.input_tokens",
|
|
1001
|
-
output_tokens: "request_logs.output_tokens",
|
|
1002
|
-
cache_read_tokens: "request_logs.cache_read_tokens",
|
|
1003
|
-
cache_creation_tokens: "request_logs.cache_creation_tokens",
|
|
1004
|
-
cache_creation_5m_tokens: "request_logs.cache_creation_5m_tokens",
|
|
1005
|
-
cache_creation_1h_tokens: "request_logs.cache_creation_1h_tokens",
|
|
1006
|
-
cost_usd: "request_logs.cost_usd",
|
|
1007
|
-
});
|
|
1008
|
-
|
|
1009
935
|
// Postgres returns SUM/COUNT as bigint, which node-postgres delivers as text
|
|
1010
936
|
// even though `Puri.rawNumber` types it as number.
|
|
1011
|
-
const storedTotal = bigintAggregate.parse(stored?.total ?? 0) / MICRO_USD;
|
|
1012
|
-
|
|
1013
|
-
// legacy row 는 위 SUM 에 저장값으로 이미 포함되어 있다. 재계산값과의 차액만 더한다.
|
|
1014
|
-
const usd = legacyRows.reduce((sum, row) => {
|
|
1015
|
-
const alreadySummed = Math.max(row.cost_usd ?? 0, 0) / MICRO_USD;
|
|
1016
|
-
const usage = normalizedUsageForCost(row);
|
|
1017
|
-
|
|
1018
|
-
if (!usage.model) return sum;
|
|
1019
|
-
|
|
1020
|
-
return (
|
|
1021
|
-
sum +
|
|
1022
|
-
calculateCostUsd(usage.model, {
|
|
1023
|
-
inputTokens: usage.inputTokens,
|
|
1024
|
-
outputTokens: usage.outputTokens,
|
|
1025
|
-
cachedInputTokens: usage.cachedInputTokens,
|
|
1026
|
-
cacheCreationInputTokens: usage.cacheCreationInputTokens,
|
|
1027
|
-
cacheCreationInputTokens5m: usage.cacheCreationInputTokens5m,
|
|
1028
|
-
cacheCreationInputTokens1h: usage.cacheCreationInputTokens1h,
|
|
1029
|
-
}) -
|
|
1030
|
-
alreadySummed
|
|
1031
|
-
);
|
|
1032
|
-
}, storedTotal);
|
|
1033
|
-
|
|
1034
937
|
return {
|
|
1035
|
-
usd,
|
|
938
|
+
usd: bigintAggregate.parse(stored?.total ?? 0) / MICRO_USD,
|
|
1036
939
|
unknownImageCostCount: bigintAggregate.parse(stored?.unknownImageCostCount ?? 0),
|
|
1037
940
|
unknownCostCount: bigintAggregate.parse(stored?.unknownCostCount ?? 0),
|
|
1038
941
|
};
|
|
1039
942
|
}
|
|
1040
943
|
|
|
1041
944
|
async distinctProjectNames(): Promise<string[]> {
|
|
1042
|
-
|
|
1043
|
-
.from("request_logs")
|
|
1044
|
-
.distinct("project_name")
|
|
1045
|
-
.where("project_name", "!=", null)
|
|
1046
|
-
.orderBy("project_name", "asc")
|
|
1047
|
-
.select({
|
|
1048
|
-
project_name: "project_name",
|
|
1049
|
-
});
|
|
1050
|
-
|
|
1051
|
-
return rows.map((r) => r.project_name!);
|
|
945
|
+
return this.distinctIndexedValues("project_name");
|
|
1052
946
|
}
|
|
1053
947
|
|
|
1054
948
|
async distinctModelNames(): Promise<string[]> {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
949
|
+
return this.distinctIndexedValues("model_name");
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* Loose index scan: 컬럼 인덱스에서 다음 값만 찾아 건너뛴다. 일반 DISTINCT 는 전체 행 수에
|
|
954
|
+
* 비례하지만 이 쿼리는 고유값 수에 비례한다. NULL 제외·오름차순 의미는 DISTINCT 와 같다.
|
|
955
|
+
*/
|
|
956
|
+
private async distinctIndexedValues(column: "project_name" | "model_name"): Promise<string[]> {
|
|
957
|
+
const result = await this.getPuri("r").knex.raw<{ rows: Array<{ v: string }> }>(
|
|
958
|
+
`WITH RECURSIVE t AS (
|
|
959
|
+
(SELECT ?? AS v FROM request_logs WHERE ?? IS NOT NULL ORDER BY ?? LIMIT 1)
|
|
960
|
+
UNION ALL
|
|
961
|
+
SELECT (SELECT ?? FROM request_logs WHERE ?? > t.v ORDER BY ?? LIMIT 1) FROM t WHERE t.v IS NOT NULL
|
|
962
|
+
)
|
|
963
|
+
SELECT v FROM t WHERE v IS NOT NULL`,
|
|
964
|
+
[column, column, column, column, column, column],
|
|
965
|
+
);
|
|
1063
966
|
|
|
1064
|
-
return rows.map((
|
|
967
|
+
return result.rows.map((row) => row.v);
|
|
1065
968
|
}
|
|
1066
969
|
|
|
1067
970
|
@api({ httpMethod: "POST", clients: ["axios", "tanstack-mutation"] })
|
|
@@ -24,6 +24,7 @@ describe("resolveOpenAIEffort", () => {
|
|
|
24
24
|
expect(resolveOpenAIEffort("gpt-5.6-terra", "ultra")).toBe("ultra");
|
|
25
25
|
expect(resolveOpenAIEffort("gpt-5.6-luna", "max")).toBe("max");
|
|
26
26
|
expect(resolveOpenAIEffort("gpt-6.1-sol", "ultra")).toBe("ultra");
|
|
27
|
+
expect(resolveOpenAIEffort("gpt-6.1-terra", "ultra")).toBe("ultra");
|
|
27
28
|
expect(resolveOpenAIEffort("gpt-6-sol", "ultra")).toBe("ultra");
|
|
28
29
|
expect(resolveOpenAIEffort("gpt-6-luna", "max")).toBe("max");
|
|
29
30
|
});
|
|
@@ -75,6 +75,7 @@ describe("calculateCostUsd", () => {
|
|
|
75
75
|
it.each([
|
|
76
76
|
["gpt-6-astra", 2.6],
|
|
77
77
|
["gpt-6.1-sol", 0.5],
|
|
78
|
+
["gpt-6.1-terra", 0.25],
|
|
78
79
|
["gpt-6-sol", 0.52],
|
|
79
80
|
["gpt-6-luna", 0.026],
|
|
80
81
|
["gpt-5.6-sol", 1.04],
|
|
@@ -130,6 +131,7 @@ describe("calculateCostUsd", () => {
|
|
|
130
131
|
it.each([
|
|
131
132
|
["gpt-6-astra", 10, 50, 1, 12.5],
|
|
132
133
|
["gpt-6.1-sol", 2, 10, 0.1, 2.5],
|
|
134
|
+
["gpt-6.1-terra", 1, 5, 0.05, 1.25],
|
|
133
135
|
["gpt-6-sol", 2, 10, 0.2, 2.5],
|
|
134
136
|
["gpt-6-luna", 0.1, 0.5, 0.01, 0.125],
|
|
135
137
|
["gpt-5.6-sol", 4, 20, 0.4, 5],
|
|
@@ -217,6 +219,7 @@ describe("calculateCostUsd", () => {
|
|
|
217
219
|
it.each([
|
|
218
220
|
["gpt-6-astra", 10, 50, 1, 12.5, 5.6125],
|
|
219
221
|
["gpt-6.1-sol", 2, 10, 0.1, 2.5, 1.1175],
|
|
222
|
+
["gpt-6.1-terra", 1, 5, 0.05, 1.25, 0.55875],
|
|
220
223
|
["gpt-6-sol", 2, 10, 0.2, 2.5, 1.1225],
|
|
221
224
|
["gpt-6-luna", 0.1, 0.5, 0.01, 0.125, 0.056125],
|
|
222
225
|
["gpt-5.6-sol", 4, 20, 0.4, 5, 2.245],
|
|
@@ -246,6 +249,7 @@ describe("calculateCostUsd", () => {
|
|
|
246
249
|
it.each([
|
|
247
250
|
["gpt-6-astra", 2.475],
|
|
248
251
|
["gpt-6.1-sol", 0.455],
|
|
252
|
+
["gpt-6.1-terra", 0.2275],
|
|
249
253
|
["gpt-6-sol", 0.495],
|
|
250
254
|
["gpt-6-luna", 0.02475],
|
|
251
255
|
["gpt-5.6-sol", 0.99],
|
|
@@ -264,6 +268,7 @@ describe("calculateCostUsd", () => {
|
|
|
264
268
|
it.each([
|
|
265
269
|
["gpt-6-astra", 2.725],
|
|
266
270
|
["gpt-6.1-sol", 0.505],
|
|
271
|
+
["gpt-6.1-terra", 0.2525],
|
|
267
272
|
["gpt-6-sol", 0.545],
|
|
268
273
|
["gpt-6-luna", 0.02725],
|
|
269
274
|
["gpt-5.6-sol", 1.09],
|
|
@@ -79,6 +79,17 @@ const OPENAI_COSTS = new Map<string, OpenAIModelSpec>(
|
|
|
79
79
|
cacheCreationInputTokens: 2.5,
|
|
80
80
|
longContext: LONG_CONTEXT_272K,
|
|
81
81
|
},
|
|
82
|
+
// GPT-6.1 Terra (2026-10-26 출시): Standard API pricing verified 2026-10-27. GPT-6.1 Sol 의 정확히 절반 단가.
|
|
83
|
+
// Codex 카탈로그(2026-10-27, client 0.164.0)는 ultra 까지 허용하고 기본 effort 는 low 다.
|
|
84
|
+
// @see https://developers.openai.com/api/docs/models/gpt-6.1-terra
|
|
85
|
+
"gpt-6.1-terra": {
|
|
86
|
+
maxEffort: "ultra",
|
|
87
|
+
inputTokens: 1,
|
|
88
|
+
outputTokens: 5,
|
|
89
|
+
cachedInputTokens: 0.05,
|
|
90
|
+
cacheCreationInputTokens: 1.25,
|
|
91
|
+
longContext: LONG_CONTEXT_272K,
|
|
92
|
+
},
|
|
82
93
|
// GPT-6 Sol, Luna (2026-09-22 출시): Standard API pricing verified 2026-09-23. GPT-5.6 Sol/Luna 의 절반 단가.
|
|
83
94
|
// Codex 카탈로그(2026-09-23)는 Sol 에 ultra, Luna 에 max 까지 허용하고 기본 effort 는 둘 다 medium 이다.
|
|
84
95
|
// @see https://developers.openai.com/api/docs/models/gpt-6-sol
|
|
@@ -366,6 +377,7 @@ const OPENAI_FAST_MULTIPLIERS = new Map<string, number>(
|
|
|
366
377
|
Object.entries({
|
|
367
378
|
"gpt-6-astra": 2,
|
|
368
379
|
"gpt-6.1-sol": 2,
|
|
380
|
+
"gpt-6.1-terra": 2,
|
|
369
381
|
"gpt-6-sol": 2,
|
|
370
382
|
"gpt-6-luna": 2,
|
|
371
383
|
"gpt-5.6-sol": 2,
|
|
@@ -53,7 +53,7 @@ async function tickTimer(): Promise<void> {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
describe("OpenAIDispatcher direct runtime", () => {
|
|
56
|
-
it.each(["gpt-6-sol", "gpt-6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5"])(
|
|
56
|
+
it.each(["gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5"])(
|
|
57
57
|
"disables thinking and omits summaries through generate/stream for %s",
|
|
58
58
|
async (model) => {
|
|
59
59
|
const run = vi.fn((options: OpenAIResponsesOptions) => {
|
|
@@ -1008,13 +1008,14 @@ describe("effort 어휘 해석 (Codex 카탈로그 기준)", () => {
|
|
|
1008
1008
|
return mapped?.reasoning?.effort;
|
|
1009
1009
|
}
|
|
1010
1010
|
|
|
1011
|
-
it("모델이 지원하는 값은 그대로 보내고, 상한 초과·공개 API 어휘는 reasoning 에서 빼 백엔드 기본값을 쓴다", async () => {
|
|
1012
|
-
await expect(mappedEffortFor("gpt-6-astra", "ultra")).resolves.toBe("
|
|
1013
|
-
await expect(mappedEffortFor("gpt-6.1-sol", "ultra")).resolves.toBe("
|
|
1014
|
-
await expect(mappedEffortFor("gpt-6-
|
|
1011
|
+
it("모델이 지원하는 값은 그대로 보내되 ultra 는 wire 상한인 max 로 보내고, 상한 초과·공개 API 어휘는 reasoning 에서 빼 백엔드 기본값을 쓴다", async () => {
|
|
1012
|
+
await expect(mappedEffortFor("gpt-6-astra", "ultra")).resolves.toBe("max");
|
|
1013
|
+
await expect(mappedEffortFor("gpt-6.1-sol", "ultra")).resolves.toBe("max");
|
|
1014
|
+
await expect(mappedEffortFor("gpt-6.1-terra", "ultra")).resolves.toBe("max");
|
|
1015
|
+
await expect(mappedEffortFor("gpt-6-sol", "ultra")).resolves.toBe("max");
|
|
1015
1016
|
await expect(mappedEffortFor("gpt-6-luna", "max")).resolves.toBe("max");
|
|
1016
1017
|
await expect(mappedEffortFor("gpt-6-luna", "ultra")).resolves.toBeUndefined();
|
|
1017
|
-
await expect(mappedEffortFor("gpt-5.6-terra", "ultra")).resolves.toBe("
|
|
1018
|
+
await expect(mappedEffortFor("gpt-5.6-terra", "ultra")).resolves.toBe("max");
|
|
1018
1019
|
await expect(mappedEffortFor("gpt-5.5", "xhigh")).resolves.toBe("xhigh");
|
|
1019
1020
|
await expect(mappedEffortFor("gpt-5.5", "max")).resolves.toBeUndefined();
|
|
1020
1021
|
await expect(mappedEffortFor("gpt-5.6-terra", "minimal")).resolves.toBeUndefined();
|
|
@@ -35,6 +35,7 @@ const logger = getLogger(["qgrid", "openai-dispatcher"]);
|
|
|
35
35
|
|
|
36
36
|
// Verified with the subscription Responses backend; public API support is not sufficient.
|
|
37
37
|
const THINKING_OFF_MODELS = new Set([
|
|
38
|
+
"gpt-6.1-terra",
|
|
38
39
|
"gpt-6-sol",
|
|
39
40
|
"gpt-6-luna",
|
|
40
41
|
"gpt-5.6-sol",
|
|
@@ -189,7 +190,8 @@ function asReasoning(req: GenerateRequest): OpenAIReasoning | undefined {
|
|
|
189
190
|
|
|
190
191
|
const reasoning: OpenAIReasoning = {};
|
|
191
192
|
|
|
192
|
-
|
|
193
|
+
// ultra is a Codex client mode (sub-agent delegation), not a wire value; the backend accepts up to max.
|
|
194
|
+
if (effort) reasoning.effort = effort === "ultra" ? "max" : effort;
|
|
193
195
|
|
|
194
196
|
if (summary) reasoning.summary = summary;
|
|
195
197
|
|