diff --git a/apps/api/src/routes/activity.ts b/apps/api/src/routes/activity.ts index 7d97c6edb6..1ffcad3a21 100644 --- a/apps/api/src/routes/activity.ts +++ b/apps/api/src/routes/activity.ts @@ -40,6 +40,7 @@ const dailyActivitySchema = z.object({ inputTokens: z.number(), outputTokens: z.number(), cachedTokens: z.number(), + cacheWriteTokens: z.number(), totalTokens: z.number(), cost: z.number(), inputCost: z.number(), @@ -50,6 +51,7 @@ const dailyActivitySchema = z.object({ imageOutputCost: z.number(), videoOutputCost: z.number(), cachedInputCost: z.number(), + cacheWriteInputCost: z.number(), errorCount: z.number(), errorRate: z.number(), cacheCount: z.number(), @@ -262,10 +264,18 @@ activity.openapi(getActivity, async (c) => { sql`COALESCE(SUM(CAST(${apiKeyHourlyStats.cachedTokens} AS NUMERIC)), 0)`.as( "cachedTokens", ), + cacheWriteTokens: + sql`COALESCE(SUM(CAST(${apiKeyHourlyStats.cacheWriteTokens} AS NUMERIC)), 0)`.as( + "cacheWriteTokens", + ), cachedInputCost: sql`COALESCE(SUM(${apiKeyHourlyStats.cachedInputCost}), 0)`.as( "cachedInputCost", ), + cacheWriteInputCost: + sql`COALESCE(SUM(${apiKeyHourlyStats.cacheWriteInputCost}), 0)`.as( + "cacheWriteInputCost", + ), creditsRequestCount: sql`COALESCE(SUM(${apiKeyHourlyStats.creditsRequestCount}), 0)`.as( "creditsRequestCount", @@ -388,6 +398,7 @@ activity.openapi(getActivity, async (c) => { const inputTokens = Number(day.inputTokens); const outputTokens = Number(day.outputTokens); const cachedTokens = Number(day.cachedTokens); + const cacheWriteTokens = Number(day.cacheWriteTokens); const totalTokens = Number(day.totalTokens); const cost = Number(day.cost); const inputCost = Number(day.inputCost); @@ -401,6 +412,7 @@ activity.openapi(getActivity, async (c) => { const imageOutputCost = Number(day.imageOutputCost); const videoOutputCost = Number(day.videoOutputCost); const cachedInputCost = Number(day.cachedInputCost); + const cacheWriteInputCost = Number(day.cacheWriteInputCost); const creditsRequestCount = Number(day.creditsRequestCount); const apiKeysRequestCount = Number(day.apiKeysRequestCount); @@ -420,6 +432,7 @@ activity.openapi(getActivity, async (c) => { inputTokens, outputTokens, cachedTokens, + cacheWriteTokens, totalTokens, cost, inputCost, @@ -430,6 +443,7 @@ activity.openapi(getActivity, async (c) => { imageOutputCost, videoOutputCost, cachedInputCost, + cacheWriteInputCost, errorCount, errorRate, cacheCount, @@ -476,6 +490,10 @@ activity.openapi(getActivity, async (c) => { sql`COALESCE(SUM(CAST(${projectHourlyStats.cachedTokens} AS NUMERIC)), 0)`.as( "cachedTokens", ), + cacheWriteTokens: + sql`COALESCE(SUM(CAST(${projectHourlyStats.cacheWriteTokens} AS NUMERIC)), 0)`.as( + "cacheWriteTokens", + ), totalTokens: sql`COALESCE(SUM(CAST(${projectHourlyStats.totalTokens} AS NUMERIC)), 0)`.as( "totalTokens", @@ -515,6 +533,10 @@ activity.openapi(getActivity, async (c) => { sql`COALESCE(SUM(${projectHourlyStats.cachedInputCost}), 0)`.as( "cachedInputCost", ), + cacheWriteInputCost: + sql`COALESCE(SUM(${projectHourlyStats.cacheWriteInputCost}), 0)`.as( + "cacheWriteInputCost", + ), errorCount: sql`COALESCE(SUM(${projectHourlyStats.errorCount}), 0)`.as( "errorCount", @@ -649,6 +671,7 @@ activity.openapi(getActivity, async (c) => { const inputTokens = Number(day.inputTokens); const outputTokens = Number(day.outputTokens); const cachedTokens = Number(day.cachedTokens); + const cacheWriteTokens = Number(day.cacheWriteTokens); const totalTokens = Number(day.totalTokens); const cost = Number(day.cost); const inputCost = Number(day.inputCost); @@ -659,6 +682,7 @@ activity.openapi(getActivity, async (c) => { const imageOutputCost = Number(day.imageOutputCost); const videoOutputCost = Number(day.videoOutputCost); const cachedInputCost = Number(day.cachedInputCost); + const cacheWriteInputCost = Number(day.cacheWriteInputCost); const errorCount = Number(day.errorCount); const cacheCount = Number(day.cacheCount); const discountSavings = Number(day.discountSavings); @@ -679,6 +703,7 @@ activity.openapi(getActivity, async (c) => { inputTokens, outputTokens, cachedTokens, + cacheWriteTokens, totalTokens, cost, inputCost, @@ -689,6 +714,7 @@ activity.openapi(getActivity, async (c) => { imageOutputCost, videoOutputCost, cachedInputCost, + cacheWriteInputCost, errorCount, errorRate, cacheCount, diff --git a/apps/api/src/routes/admin.ts b/apps/api/src/routes/admin.ts index f9116d35fd..f1a0cba8ca 100644 --- a/apps/api/src/routes/admin.ts +++ b/apps/api/src/routes/admin.ts @@ -132,6 +132,8 @@ const orgMetricsSchema = z.object({ outputCost: z.number(), cachedTokens: z.number(), cachedCost: z.number(), + cacheWriteTokens: z.number(), + cacheWriteCost: z.number(), mostUsedModel: z.string().nullable(), mostUsedProvider: z.string().nullable(), mostUsedModelCost: z.number(), @@ -1003,6 +1005,8 @@ admin.openapi(getOrganizationMetrics, async (c) => { let outputCost = 0; let cachedTokens = 0; let cachedCost = 0; + let cacheWriteTokens = 0; + let cacheWriteCost = 0; let discountSavings = 0; let mostUsedModel: string | null = null; let mostUsedProvider: string | null = null; @@ -1028,6 +1032,10 @@ admin.openapi(getOrganizationMetrics, async (c) => { sql`COALESCE(SUM(CAST(${projectHourlyStats.cachedTokens} AS INTEGER)), 0)`.as( "cachedTokens", ), + cacheWriteTokens: + sql`COALESCE(SUM(CAST(${projectHourlyStats.cacheWriteTokens} AS INTEGER)), 0)`.as( + "cacheWriteTokens", + ), totalTokens: sql`COALESCE(SUM(CAST(${projectHourlyStats.totalTokens} AS INTEGER)), 0)`.as( "totalTokens", @@ -1051,6 +1059,10 @@ admin.openapi(getOrganizationMetrics, async (c) => { sql`COALESCE(SUM(${projectHourlyStats.cachedInputCost}), 0)`.as( "cachedInputCost", ), + cacheWriteInputCost: + sql`COALESCE(SUM(${projectHourlyStats.cacheWriteInputCost}), 0)`.as( + "cacheWriteInputCost", + ), }) .from(projectHourlyStats) .where( @@ -1071,6 +1083,8 @@ admin.openapi(getOrganizationMetrics, async (c) => { outputCost = Number(totals.outputCost) || 0; cachedTokens = Number(totals.cachedTokens) || 0; cachedCost = Number(totals.cachedInputCost) || 0; + cacheWriteTokens = Number(totals.cacheWriteTokens) || 0; + cacheWriteCost = Number(totals.cacheWriteInputCost) || 0; discountSavings = Number(totals.discountSavings) || 0; } @@ -1130,6 +1144,8 @@ admin.openapi(getOrganizationMetrics, async (c) => { outputCost, cachedTokens, cachedCost, + cacheWriteTokens, + cacheWriteCost, mostUsedModel, mostUsedProvider, mostUsedModelCost, @@ -1386,6 +1402,8 @@ const projectMetricsSchema = z.object({ outputCost: z.number(), cachedTokens: z.number(), cachedCost: z.number(), + cacheWriteTokens: z.number(), + cacheWriteCost: z.number(), mostUsedModel: z.string().nullable(), mostUsedProvider: z.string().nullable(), mostUsedModelCost: z.number(), @@ -1462,6 +1480,8 @@ admin.openapi(getProjectMetrics, async (c) => { let outputCost = 0; let cachedTokens = 0; let cachedCost = 0; + let cacheWriteTokens = 0; + let cacheWriteCost = 0; let discountSavings = 0; let mostUsedModel: string | null = null; let mostUsedProvider: string | null = null; @@ -1485,6 +1505,10 @@ admin.openapi(getProjectMetrics, async (c) => { sql`COALESCE(SUM(CAST(${projectHourlyStats.cachedTokens} AS INTEGER)), 0)`.as( "cachedTokens", ), + cacheWriteTokens: + sql`COALESCE(SUM(CAST(${projectHourlyStats.cacheWriteTokens} AS INTEGER)), 0)`.as( + "cacheWriteTokens", + ), totalTokens: sql`COALESCE(SUM(CAST(${projectHourlyStats.totalTokens} AS INTEGER)), 0)`.as( "totalTokens", @@ -1508,6 +1532,10 @@ admin.openapi(getProjectMetrics, async (c) => { sql`COALESCE(SUM(${projectHourlyStats.cachedInputCost}), 0)`.as( "cachedInputCost", ), + cacheWriteInputCost: + sql`COALESCE(SUM(${projectHourlyStats.cacheWriteInputCost}), 0)`.as( + "cacheWriteInputCost", + ), }) .from(projectHourlyStats) .where( @@ -1528,6 +1556,8 @@ admin.openapi(getProjectMetrics, async (c) => { outputCost = Number(totals.outputCost) || 0; cachedTokens = Number(totals.cachedTokens) || 0; cachedCost = Number(totals.cachedInputCost) || 0; + cacheWriteTokens = Number(totals.cacheWriteTokens) || 0; + cacheWriteCost = Number(totals.cacheWriteInputCost) || 0; discountSavings = Number(totals.discountSavings) || 0; } @@ -1584,6 +1614,8 @@ admin.openapi(getProjectMetrics, async (c) => { outputCost, cachedTokens, cachedCost, + cacheWriteTokens, + cacheWriteCost, mostUsedModel, mostUsedProvider, mostUsedModelCost, @@ -1608,12 +1640,14 @@ const logEntrySchema = z.object({ totalTokens: z.string().nullable(), reasoningTokens: z.string().nullable(), cachedTokens: z.string().nullable(), + cacheWriteTokens: z.string().nullable(), imageInputTokens: z.string().nullable(), imageOutputTokens: z.string().nullable(), cost: z.number().nullable(), inputCost: z.number().nullable(), outputCost: z.number().nullable(), cachedInputCost: z.number().nullable(), + cacheWriteInputCost: z.number().nullable(), requestCost: z.number().nullable(), webSearchCost: z.number().nullable(), imageInputCost: z.number().nullable(), @@ -1793,12 +1827,14 @@ admin.openapi(getProjectLogs, async (c) => { totalTokens: tables.log.totalTokens, reasoningTokens: tables.log.reasoningTokens, cachedTokens: tables.log.cachedTokens, + cacheWriteTokens: tables.log.cacheWriteTokens, imageInputTokens: tables.log.imageInputTokens, imageOutputTokens: tables.log.imageOutputTokens, cost: tables.log.cost, inputCost: tables.log.inputCost, outputCost: tables.log.outputCost, cachedInputCost: tables.log.cachedInputCost, + cacheWriteInputCost: tables.log.cacheWriteInputCost, requestCost: tables.log.requestCost, webSearchCost: tables.log.webSearchCost, imageInputCost: tables.log.imageInputCost, @@ -1866,6 +1902,7 @@ admin.openapi(getProjectLogs, async (c) => { totalTokens: l.totalTokens ? String(l.totalTokens) : null, reasoningTokens: l.reasoningTokens ? String(l.reasoningTokens) : null, cachedTokens: l.cachedTokens ? String(l.cachedTokens) : null, + cacheWriteTokens: l.cacheWriteTokens ? String(l.cacheWriteTokens) : null, imageInputTokens: l.imageInputTokens ? String(l.imageInputTokens) : null, imageOutputTokens: l.imageOutputTokens ? String(l.imageOutputTokens) @@ -5043,6 +5080,8 @@ const mappingDetailSchema = z.object({ inputPrice: z.string().nullable(), outputPrice: z.string().nullable(), cachedInputPrice: z.string().nullable(), + cacheWriteInputPrice: z.string().nullable(), + cacheWriteInputPrice1h: z.string().nullable(), imageInputPrice: z.string().nullable(), requestPrice: z.string().nullable(), contextSize: z.number().nullable(), @@ -5099,6 +5138,9 @@ admin.openapi(getMappingDetail, async (c) => { inputPrice: tables.modelProviderMapping.inputPrice, outputPrice: tables.modelProviderMapping.outputPrice, cachedInputPrice: tables.modelProviderMapping.cachedInputPrice, + cacheWriteInputPrice: tables.modelProviderMapping.cacheWriteInputPrice, + cacheWriteInputPrice1h: + tables.modelProviderMapping.cacheWriteInputPrice1h, imageInputPrice: tables.modelProviderMapping.imageInputPrice, requestPrice: tables.modelProviderMapping.requestPrice, contextSize: tables.modelProviderMapping.contextSize, @@ -5186,6 +5228,8 @@ admin.openapi(getMappingDetail, async (c) => { inputPrice: m.inputPrice, outputPrice: m.outputPrice, cachedInputPrice: m.cachedInputPrice, + cacheWriteInputPrice: m.cacheWriteInputPrice, + cacheWriteInputPrice1h: m.cacheWriteInputPrice1h, imageInputPrice: m.imageInputPrice, requestPrice: m.requestPrice, contextSize: m.contextSize, diff --git a/apps/api/src/routes/internal-models.ts b/apps/api/src/routes/internal-models.ts index 6c615f6907..0ed734133c 100644 --- a/apps/api/src/routes/internal-models.ts +++ b/apps/api/src/routes/internal-models.ts @@ -49,6 +49,8 @@ const modelProviderMappingSchema = z.object({ inputPrice: z.string().nullable(), outputPrice: z.string().nullable(), cachedInputPrice: z.string().nullable(), + cacheWriteInputPrice: z.string().nullable(), + cacheWriteInputPrice1h: z.string().nullable(), imageInputPrice: z.string().nullable(), imageOutputPrice: z.string().nullable(), imageInputTokensByResolution: z.record(z.number()).nullable(), diff --git a/apps/api/src/routes/logs.ts b/apps/api/src/routes/logs.ts index b396ff9fd4..cf2c1202b2 100644 --- a/apps/api/src/routes/logs.ts +++ b/apps/api/src/routes/logs.ts @@ -112,6 +112,7 @@ const logSchema = z.object({ completionTokens: z.string().nullable(), totalTokens: z.string().nullable(), reasoningTokens: z.string().nullable(), + cacheWriteTokens: z.string().nullable().optional(), messages: z.any(), temperature: z.number().nullable(), maxTokens: z.number().nullable(), @@ -131,6 +132,7 @@ const logSchema = z.object({ outputCost: z.number().nullable(), requestCost: z.number().nullable(), cachedInputCost: z.number().nullable().optional(), + cacheWriteInputCost: z.number().nullable().optional(), webSearchCost: z.number().nullable().optional(), imageInputTokens: z.string().nullable(), imageOutputTokens: z.string().nullable(), diff --git a/apps/api/src/testing.ts b/apps/api/src/testing.ts index 48c73a471a..e1d4db5296 100644 --- a/apps/api/src/testing.ts +++ b/apps/api/src/testing.ts @@ -123,6 +123,10 @@ function getCommonAggregationFields() { sql`coalesce(sum(cast(${tables.log.cachedTokens} as numeric)), 0)`.as( "cachedTokens", ), + cacheWriteTokens: + sql`coalesce(sum(cast(${tables.log.cacheWriteTokens} as numeric)), 0)`.as( + "cacheWriteTokens", + ), cost: sql`coalesce(sum(${tables.log.cost}), 0)`.as("cost"), inputCost: sql`coalesce(sum(${tables.log.inputCost}), 0)`.as( "inputCost", @@ -163,6 +167,10 @@ function getCommonAggregationFields() { sql`coalesce(sum(${tables.log.cachedInputCost}), 0)`.as( "cachedInputCost", ), + cacheWriteInputCost: + sql`coalesce(sum(${tables.log.cacheWriteInputCost}), 0)`.as( + "cacheWriteInputCost", + ), // Per-mode breakdowns creditsRequestCount: sql`sum(case when ${tables.log.usedMode} = 'credits' then 1 else 0 end)::int`.as( diff --git a/apps/code/src/lib/api/v1.d.ts b/apps/code/src/lib/api/v1.d.ts index c87e5a8647..0c6bd0f1a2 100644 --- a/apps/code/src/lib/api/v1.d.ts +++ b/apps/code/src/lib/api/v1.d.ts @@ -903,6 +903,7 @@ export interface paths { completionTokens: string | null; totalTokens: string | null; reasoningTokens: string | null; + cacheWriteTokens?: string | null; messages?: unknown; temperature: number | null; maxTokens: number | null; @@ -963,6 +964,7 @@ export interface paths { outputCost: number | null; requestCost: number | null; cachedInputCost?: number | null; + cacheWriteInputCost?: number | null; webSearchCost?: number | null; imageInputTokens: string | null; imageOutputTokens: string | null; @@ -1151,6 +1153,7 @@ export interface paths { completionTokens: string | null; totalTokens: string | null; reasoningTokens: string | null; + cacheWriteTokens?: string | null; messages?: unknown; temperature: number | null; maxTokens: number | null; @@ -1211,6 +1214,7 @@ export interface paths { outputCost: number | null; requestCost: number | null; cachedInputCost?: number | null; + cacheWriteInputCost?: number | null; webSearchCost?: number | null; imageInputTokens: string | null; imageOutputTokens: string | null; @@ -1340,6 +1344,7 @@ export interface paths { inputTokens: number; outputTokens: number; cachedTokens: number; + cacheWriteTokens: number; totalTokens: number; cost: number; inputCost: number; @@ -1350,6 +1355,7 @@ export interface paths { imageOutputCost: number; videoOutputCost: number; cachedInputCost: number; + cacheWriteInputCost: number; errorCount: number; errorRate: number; cacheCount: number; @@ -1605,6 +1611,8 @@ export interface paths { outputCost: number; cachedTokens: number; cachedCost: number; + cacheWriteTokens: number; + cacheWriteCost: number; mostUsedModel: string | null; mostUsedProvider: string | null; mostUsedModelCost: number; @@ -1928,6 +1936,8 @@ export interface paths { outputCost: number; cachedTokens: number; cachedCost: number; + cacheWriteTokens: number; + cacheWriteCost: number; mostUsedModel: string | null; mostUsedProvider: string | null; mostUsedModelCost: number; @@ -2002,12 +2012,14 @@ export interface paths { totalTokens: string | null; reasoningTokens: string | null; cachedTokens: string | null; + cacheWriteTokens: string | null; imageInputTokens: string | null; imageOutputTokens: string | null; cost: number | null; inputCost: number | null; outputCost: number | null; cachedInputCost: number | null; + cacheWriteInputCost: number | null; requestCost: number | null; webSearchCost: number | null; imageInputCost: number | null; @@ -3405,6 +3417,8 @@ export interface paths { inputPrice: string | null; outputPrice: string | null; cachedInputPrice: string | null; + cacheWriteInputPrice: string | null; + cacheWriteInputPrice1h: string | null; imageInputPrice: string | null; requestPrice: string | null; contextSize: number | null; @@ -8684,6 +8698,8 @@ export interface operations { inputPrice: string | null; outputPrice: string | null; cachedInputPrice: string | null; + cacheWriteInputPrice: string | null; + cacheWriteInputPrice1h: string | null; imageInputPrice: string | null; imageOutputPrice: string | null; imageInputTokensByResolution: { diff --git a/apps/gateway/src/anthropic/anthropic.ts b/apps/gateway/src/anthropic/anthropic.ts index 5f6473bbff..5627449f68 100644 --- a/apps/gateway/src/anthropic/anthropic.ts +++ b/apps/gateway/src/anthropic/anthropic.ts @@ -22,6 +22,7 @@ const anthropicMessageSchema = z.object({ cache_control: z .object({ type: z.enum(["ephemeral"]), + ttl: z.enum(["5m", "1h"]).optional(), }) .optional(), }), @@ -100,6 +101,7 @@ const anthropicRequestSchema = z.object({ cache_control: z .object({ type: z.enum(["ephemeral"]), + ttl: z.enum(["5m", "1h"]).optional(), }) .optional(), }), @@ -156,6 +158,15 @@ const anthropicResponseSchema = z.object({ // them. The downstream conversion code already handles 0 correctly. cache_creation_input_tokens: z.number().optional().default(0), cache_read_input_tokens: z.number().optional().default(0), + // Anthropic returns this breakdown when 5m/1h TTLs are mixed; emit it + // whenever upstream gave us a per-TTL split so SDK clients can attribute + // spend across the 1.25x and 2x cache write rates. + cache_creation: z + .object({ + ephemeral_5m_input_tokens: z.number(), + ephemeral_1h_input_tokens: z.number(), + }) + .optional(), }), }); @@ -547,6 +558,10 @@ anthropic.openapi(messages, async (c) => { output_tokens: number; cache_creation_input_tokens: number; cache_read_input_tokens: number; + cache_creation?: { + ephemeral_5m_input_tokens: number; + ephemeral_1h_input_tokens: number; + }; } = { input_tokens: 0, output_tokens: 0, @@ -757,12 +772,20 @@ anthropic.openapi(messages, async (c) => { chunk.usage.prompt_tokens_details ?? {}; const cacheRead: number = promptDetails.cached_tokens ?? 0; const cacheCreation: number = - promptDetails.cache_creation_tokens ?? 0; + promptDetails.cache_write_tokens ?? + promptDetails.cache_creation_tokens ?? + 0; const totalPrompt: number = chunk.usage.prompt_tokens ?? 0; const nonCachedInput = Math.max( 0, totalPrompt - cacheRead - cacheCreation, ); + const breakdown = promptDetails.cache_creation as + | { + ephemeral_5m_input_tokens?: number; + ephemeral_1h_input_tokens?: number; + } + | undefined; usage = { input_tokens: nonCachedInput, output_tokens: chunk.usage.completion_tokens ?? 0, @@ -770,6 +793,15 @@ anthropic.openapi(messages, async (c) => { // (set to 0 when inapplicable). cache_creation_input_tokens: cacheCreation, cache_read_input_tokens: cacheRead, + ...(breakdown && + cacheCreation > 0 && { + cache_creation: { + ephemeral_5m_input_tokens: + breakdown.ephemeral_5m_input_tokens ?? 0, + ephemeral_1h_input_tokens: + breakdown.ephemeral_1h_input_tokens ?? 0, + }, + }), }; } @@ -862,12 +894,19 @@ anthropic.openapi(messages, async (c) => { const usageDetails = openaiResponse.usage?.prompt_tokens_details ?? {}; const cachedTokens: number = usageDetails.cached_tokens ?? 0; - const cacheCreationTokens: number = usageDetails.cache_creation_tokens ?? 0; + const cacheCreationTokens: number = + usageDetails.cache_write_tokens ?? usageDetails.cache_creation_tokens ?? 0; const totalPromptTokens: number = openaiResponse.usage?.prompt_tokens ?? 0; const nonCachedInputTokens = Math.max( 0, totalPromptTokens - cachedTokens - cacheCreationTokens, ); + const cacheCreationBreakdown = usageDetails.cache_creation as + | { + ephemeral_5m_input_tokens?: number; + ephemeral_1h_input_tokens?: number; + } + | undefined; const anthropicResponse = { id: openaiResponse.id, @@ -887,6 +926,18 @@ anthropic.openapi(messages, async (c) => { // without optionality checks. cache_creation_input_tokens: cacheCreationTokens, cache_read_input_tokens: cachedTokens, + // Per Anthropic's spec, surface the per-TTL breakdown when upstream + // supplied one so callers can attribute spend across the 5m (1.25x) + // and 1h (2x) cache write rates. + ...(cacheCreationBreakdown && + cacheCreationTokens > 0 && { + cache_creation: { + ephemeral_5m_input_tokens: + cacheCreationBreakdown.ephemeral_5m_input_tokens ?? 0, + ephemeral_1h_input_tokens: + cacheCreationBreakdown.ephemeral_1h_input_tokens ?? 0, + }, + }), }, }; diff --git a/apps/gateway/src/chat/chat.ts b/apps/gateway/src/chat/chat.ts index bb53604a17..52d59a276b 100644 --- a/apps/gateway/src/chat/chat.ts +++ b/apps/gateway/src/chat/chat.ts @@ -899,6 +899,12 @@ const completions = createRoute({ cached_tokens: z.number(), cache_write_tokens: z.number().optional(), cache_creation_tokens: z.number().optional(), + cache_creation: z + .object({ + ephemeral_5m_input_tokens: z.number(), + ephemeral_1h_input_tokens: z.number(), + }) + .optional(), audio_tokens: z.number().optional(), video_tokens: z.number().optional(), }) @@ -920,6 +926,7 @@ const completions = createRoute({ input_cost: z.number().nullable().optional(), output_cost: z.number().nullable().optional(), cached_input_cost: z.number().nullable().optional(), + cache_write_input_cost: z.number().nullable().optional(), request_cost: z.number().nullable().optional(), web_search_cost: z.number().nullable().optional(), image_input_cost: z.number().nullable().optional(), @@ -3462,6 +3469,8 @@ chat.openapi(completions, async (c) => { let totalTokens = null; let reasoningTokens = null; let cachedTokens = null; + let cacheWriteTokens: number | null = null; + let cacheWrite1hTokens: number | null = null; let rawCachedResponseData = ""; // Raw SSE data from cached response let cachedResponseSize = 0; // Track size incrementally to avoid expensive stringify @@ -3510,6 +3519,21 @@ chat.openapi(completions, async (c) => { cachedTokens = chunkData.usage.prompt_tokens_details.cached_tokens; } + const chunkCacheWrite = + chunkData.usage.prompt_tokens_details?.cache_write_tokens ?? + chunkData.usage.prompt_tokens_details?.cache_creation_tokens; + if (chunkCacheWrite !== undefined && chunkCacheWrite !== null) { + cacheWriteTokens = chunkCacheWrite; + } + const chunkCacheWrite1h = + chunkData.usage.prompt_tokens_details?.cache_creation + ?.ephemeral_1h_input_tokens; + if ( + chunkCacheWrite1h !== undefined && + chunkCacheWrite1h !== null + ) { + cacheWrite1hTokens = chunkCacheWrite1h; + } } } catch (e) { // Skip malformed chunks @@ -3573,6 +3597,11 @@ chat.openapi(completions, async (c) => { inputImageCount, null, // webSearchCount project.organizationId, + undefined, + { + cacheWriteTokens, + cacheWrite1hTokens, + }, ); await insertLogEntry({ @@ -3596,6 +3625,7 @@ chat.openapi(completions, async (c) => { : (totalTokens?.toString() ?? null), reasoningTokens: reasoningTokens?.toString() ?? null, cachedTokens: cachedTokens?.toString() ?? null, + cacheWriteTokens: cacheWriteTokens?.toString() ?? null, hasError: false, streamed: true, canceled: false, @@ -3603,6 +3633,7 @@ chat.openapi(completions, async (c) => { inputCost: costs.inputCost ?? 0, outputCost: costs.outputCost ?? 0, cachedInputCost: costs.cachedInputCost ?? 0, + cacheWriteInputCost: costs.cacheWriteInputCost ?? 0, requestCost: costs.requestCost ?? 0, webSearchCost: costs.webSearchCost ?? 0, imageInputTokens: costs.imageInputTokens?.toString() ?? null, @@ -3726,6 +3757,17 @@ chat.openapi(completions, async (c) => { inputImageCount, null, // webSearchCount project.organizationId, + undefined, + { + cacheWriteTokens: + cachedResponse.usage?.prompt_tokens_details?.cache_write_tokens ?? + cachedResponse.usage?.prompt_tokens_details + ?.cache_creation_tokens ?? + null, + cacheWrite1hTokens: + cachedResponse.usage?.prompt_tokens_details?.cache_creation + ?.ephemeral_1h_input_tokens ?? null, + }, ); // Estimate cached response size based on content to avoid expensive stringify @@ -3763,6 +3805,11 @@ chat.openapi(completions, async (c) => { reasoningTokens: cachedResponse.usage?.reasoning_tokens ?? null, cachedTokens: cachedResponse.usage?.prompt_tokens_details?.cached_tokens ?? null, + cacheWriteTokens: + ( + cachedResponse.usage?.prompt_tokens_details?.cache_write_tokens ?? + cachedResponse.usage?.prompt_tokens_details?.cache_creation_tokens + )?.toString() ?? null, hasError: false, streamed: false, canceled: false, @@ -3770,6 +3817,7 @@ chat.openapi(completions, async (c) => { inputCost: cachedCosts.inputCost ?? 0, outputCost: cachedCosts.outputCost ?? 0, cachedInputCost: cachedCosts.cachedInputCost ?? 0, + cacheWriteInputCost: cachedCosts.cacheWriteInputCost ?? 0, requestCost: cachedCosts.requestCost ?? 0, webSearchCost: cachedCosts.webSearchCost ?? 0, imageInputTokens: cachedCosts.imageInputTokens?.toString() ?? null, @@ -4381,6 +4429,7 @@ chat.openapi(completions, async (c) => { inputCost: streamingCosts.inputCost, outputCost: streamingCosts.outputCost, cachedInputCost: streamingCosts.cachedInputCost, + cacheWriteInputCost: streamingCosts.cacheWriteInputCost, requestCost: streamingCosts.requestCost, webSearchCost: streamingCosts.webSearchCost, imageInputCost: streamingCosts.imageInputCost, @@ -5676,6 +5725,8 @@ chat.openapi(completions, async (c) => { let reasoningTokens = null; let cachedTokens = null; let cacheCreationTokens: number | null = null; + let cacheCreation5mTokens: number | null = null; + let cacheCreation1hTokens: number | null = null; let streamingToolCalls = null; let imageByteSize = 0; // Track total image data size for token estimation let outputImageCount = 0; // Track number of output images for cost calculation @@ -6098,6 +6149,10 @@ chat.openapi(completions, async (c) => { webSearchCount, project.organizationId, image_config?.image_quality, + { + cacheWriteTokens: cacheCreationTokens, + cacheWrite1hTokens: cacheCreation1hTokens, + }, ); streamingCosts.dataStorageCost = toDataStorageCostNumber( streamingCosts.promptTokens ?? finalPromptTokens, @@ -6140,6 +6195,22 @@ chat.openapi(completions, async (c) => { cacheCreationTokens > 0 && { cache_creation_tokens: cacheCreationTokens, }), + ...(cacheCreationTokens !== null && + cacheCreationTokens > 0 && + (cacheCreation5mTokens !== null || + cacheCreation1hTokens !== null) && { + cache_creation: { + ephemeral_5m_input_tokens: + cacheCreation5mTokens ?? + Math.max( + 0, + cacheCreationTokens - + (cacheCreation1hTokens ?? 0), + ), + ephemeral_1h_input_tokens: + cacheCreation1hTokens ?? 0, + }, + }), }, }), }; @@ -6149,6 +6220,8 @@ chat.openapi(completions, async (c) => { inputCost: streamingCosts.inputCost, outputCost: streamingCosts.outputCost, cachedInputCost: streamingCosts.cachedInputCost, + cacheWriteInputCost: + streamingCosts.cacheWriteInputCost, requestCost: streamingCosts.requestCost, webSearchCost: streamingCosts.webSearchCost, imageInputCost: streamingCosts.imageInputCost, @@ -6880,6 +6953,19 @@ chat.openapi(completions, async (c) => { if (usage.cacheCreationTokens !== null) { cacheCreationTokens = usage.cacheCreationTokens; } + if (usage.cacheCreation5mTokens !== null) { + cacheCreation5mTokens = usage.cacheCreation5mTokens; + } + if (usage.cacheCreation1hTokens !== null) { + cacheCreation1hTokens = usage.cacheCreation1hTokens; + } + if ( + usage.totalTokens === null && + promptTokens !== null && + completionTokens !== null + ) { + totalTokens = promptTokens + completionTokens; + } // Estimate tokens if not provided and we have a finish reason if (finishReason && (!promptTokens || !completionTokens)) { @@ -7314,6 +7400,7 @@ chat.openapi(completions, async (c) => { inputCost: null, outputCost: null, cachedInputCost: null, + cacheWriteInputCost: null, requestCost: null, webSearchCost: null, imageInputTokens: null, @@ -7324,6 +7411,7 @@ chat.openapi(completions, async (c) => { promptTokens: null, completionTokens: null, cachedTokens: null, + cacheWriteTokens: null, estimatedCost: false, discount: undefined, pricingTier: undefined, @@ -7349,6 +7437,10 @@ chat.openapi(completions, async (c) => { webSearchCount, project.organizationId, image_config?.image_quality, + { + cacheWriteTokens: cacheCreationTokens, + cacheWrite1hTokens: cacheCreation1hTokens, + }, ); if (streamingCostsEarly.totalCost !== null) { streamingCostsEarly.dataStorageCost = toDataStorageCostNumber( @@ -7414,6 +7506,22 @@ chat.openapi(completions, async (c) => { cacheCreationTokens > 0 && { cache_creation_tokens: cacheCreationTokens, }), + ...(cacheCreationTokens !== null && + cacheCreationTokens > 0 && + (cacheCreation5mTokens !== null || + cacheCreation1hTokens !== null) && { + cache_creation: { + ephemeral_5m_input_tokens: + cacheCreation5mTokens ?? + Math.max( + 0, + cacheCreationTokens - + (cacheCreation1hTokens ?? 0), + ), + ephemeral_1h_input_tokens: + cacheCreation1hTokens ?? 0, + }, + }), }, }), }; @@ -7422,6 +7530,8 @@ chat.openapi(completions, async (c) => { inputCost: streamingCostsEarly.inputCost, outputCost: streamingCostsEarly.outputCost, cachedInputCost: streamingCostsEarly.cachedInputCost, + cacheWriteInputCost: + streamingCostsEarly.cacheWriteInputCost, requestCost: streamingCostsEarly.requestCost, webSearchCost: streamingCostsEarly.webSearchCost, imageInputCost: streamingCostsEarly.imageInputCost, @@ -7604,6 +7714,7 @@ chat.openapi(completions, async (c) => { inputCost: null, outputCost: null, cachedInputCost: null, + cacheWriteInputCost: null, requestCost: null, webSearchCost: null, imageInputTokens: null, @@ -7614,6 +7725,7 @@ chat.openapi(completions, async (c) => { promptTokens: null, completionTokens: null, cachedTokens: null, + cacheWriteTokens: null, estimatedCost: false, discount: undefined, pricingTier: undefined, @@ -7639,6 +7751,10 @@ chat.openapi(completions, async (c) => { webSearchCount, project.organizationId, image_config?.image_quality, + { + cacheWriteTokens: cacheCreationTokens, + cacheWrite1hTokens: cacheCreation1hTokens, + }, )); // Use costs.promptTokens as canonical value (includes image input @@ -7757,6 +7873,9 @@ chat.openapi(completions, async (c) => { cachedTokens: shouldIncludeTokensForBilling ? (cachedTokens?.toString() ?? null) : null, + cacheWriteTokens: shouldIncludeTokensForBilling + ? (cacheCreationTokens?.toString() ?? null) + : null, hasError: streamingError !== null, errorDetails: streamingError ? { @@ -7794,6 +7913,7 @@ chat.openapi(completions, async (c) => { inputCost: costs.inputCost, outputCost: costs.outputCost, cachedInputCost: costs.cachedInputCost, + cacheWriteInputCost: costs.cacheWriteInputCost, requestCost: costs.requestCost, webSearchCost: costs.webSearchCost, imageInputTokens: costs.imageInputTokens?.toString() ?? null, @@ -9200,6 +9320,8 @@ chat.openapi(completions, async (c) => { reasoningTokens, cachedTokens, cacheCreationTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, imageInputTokens, imageOutputTokens, toolResults, @@ -9319,6 +9441,10 @@ chat.openapi(completions, async (c) => { webSearchCount, project.organizationId, image_config?.image_quality, + { + cacheWriteTokens: cacheCreationTokens, + cacheWrite1hTokens: cacheCreation1hTokens, + }, ); costs.dataStorageCost = toDataStorageCostNumber( costs.promptTokens ?? calculatedPromptTokens, @@ -9370,6 +9496,7 @@ chat.openapi(completions, async (c) => { inputCost: costs.inputCost, outputCost: costs.outputCost, cachedInputCost: costs.cachedInputCost, + cacheWriteInputCost: costs.cacheWriteInputCost, requestCost: costs.requestCost, webSearchCost: costs.webSearchCost, imageInputCost: costs.imageInputCost, @@ -9386,6 +9513,8 @@ chat.openapi(completions, async (c) => { cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ); // Extract plugin IDs for logging @@ -9502,6 +9631,7 @@ chat.openapi(completions, async (c) => { ).toString(), reasoningTokens: calculatedReasoningTokens?.toString() ?? null, cachedTokens: cachedTokens?.toString() ?? null, + cacheWriteTokens: cacheCreationTokens?.toString() ?? null, hasError: hasEmptyNonStreamingResponse, streamed: false, canceled: false, @@ -9516,6 +9646,7 @@ chat.openapi(completions, async (c) => { inputCost: costs.inputCost, outputCost: costs.outputCost, cachedInputCost: costs.cachedInputCost, + cacheWriteInputCost: costs.cacheWriteInputCost, requestCost: costs.requestCost, webSearchCost: costs.webSearchCost, imageInputTokens: costs.imageInputTokens?.toString() ?? null, diff --git a/apps/gateway/src/chat/schemas/completions.ts b/apps/gateway/src/chat/schemas/completions.ts index b0bda97351..3056b499bd 100644 --- a/apps/gateway/src/chat/schemas/completions.ts +++ b/apps/gateway/src/chat/schemas/completions.ts @@ -22,6 +22,7 @@ export const completionsRequestSchema = z.object({ cache_control: z .object({ type: z.literal("ephemeral"), + ttl: z.enum(["5m", "1h"]).optional(), }) .optional(), }), diff --git a/apps/gateway/src/chat/tools/extract-token-usage.spec.ts b/apps/gateway/src/chat/tools/extract-token-usage.spec.ts index 8cf3ec6b73..7883c60093 100644 --- a/apps/gateway/src/chat/tools/extract-token-usage.spec.ts +++ b/apps/gateway/src/chat/tools/extract-token-usage.spec.ts @@ -84,6 +84,7 @@ describe("extractTokenUsage", () => { const result = extractTokenUsage(data, "anthropic"); expect(result.cachedTokens).toBe(0); + expect(result.cacheCreationTokens).toBe(50); expect(result.promptTokens).toBe(150); // 100 + 50 + 0 expect(result.completionTokens).toBe(200); }); @@ -101,6 +102,7 @@ describe("extractTokenUsage", () => { const result = extractTokenUsage(data, "anthropic"); expect(result.cachedTokens).toBe(800); + expect(result.cacheCreationTokens).toBe(0); expect(result.promptTokens).toBe(900); // 100 + 0 + 800 }); @@ -197,6 +199,109 @@ describe("extractTokenUsage", () => { expect(result.reasoningTokens).toBe(0); expect(result.totalTokens).toBe(150); }); + + it("extracts 1h cache creation tokens from cache_creation breakdown", () => { + const data = { + usage: { + input_tokens: 10, + cache_creation_input_tokens: 1000, + cache_creation: { + ephemeral_5m_input_tokens: 400, + ephemeral_1h_input_tokens: 600, + }, + cache_read_input_tokens: 0, + output_tokens: 50, + }, + }; + + const result = extractTokenUsage(data, "anthropic"); + + expect(result.cacheCreationTokens).toBe(1000); + expect(result.cacheCreation5mTokens).toBe(400); + expect(result.cacheCreation1hTokens).toBe(600); + }); + + it("extracts cache creation tokens from Anthropic streaming message_start", () => { + const data = { + type: "message_start", + message: { + usage: { + input_tokens: 10, + cache_creation_input_tokens: 1000, + cache_creation: { + ephemeral_5m_input_tokens: 400, + ephemeral_1h_input_tokens: 600, + }, + cache_read_input_tokens: 0, + output_tokens: 1, + }, + }, + }; + + const result = extractTokenUsage(data, "anthropic"); + + expect(result.promptTokens).toBe(1010); + expect(result.completionTokens).toBe(1); + expect(result.cacheCreationTokens).toBe(1000); + expect(result.cacheCreation5mTokens).toBe(400); + expect(result.cacheCreation1hTokens).toBe(600); + }); + + it("does not clear prompt cache usage from output-only Anthropic deltas", () => { + const data = { + type: "message_delta", + usage: { + output_tokens: 50, + }, + }; + + const result = extractTokenUsage(data, "anthropic"); + + expect(result.promptTokens).toBeNull(); + expect(result.cachedTokens).toBeNull(); + expect(result.cacheCreationTokens).toBeNull(); + expect(result.cacheCreation5mTokens).toBeNull(); + expect(result.cacheCreation1hTokens).toBeNull(); + expect(result.completionTokens).toBe(50); + expect(result.totalTokens).toBeNull(); + }); + + it("returns null cacheCreation1hTokens when only 5m writes are present", () => { + const data = { + usage: { + input_tokens: 10, + cache_creation_input_tokens: 400, + cache_creation: { + ephemeral_5m_input_tokens: 400, + ephemeral_1h_input_tokens: 0, + }, + cache_read_input_tokens: 0, + output_tokens: 50, + }, + }; + + const result = extractTokenUsage(data, "anthropic"); + + expect(result.cacheCreationTokens).toBe(400); + expect(result.cacheCreation5mTokens).toBe(400); + expect(result.cacheCreation1hTokens).toBeNull(); + }); + + it("returns null cacheCreation1hTokens when cache_creation breakdown is missing", () => { + const data = { + usage: { + input_tokens: 10, + cache_creation_input_tokens: 400, + cache_read_input_tokens: 0, + output_tokens: 50, + }, + }; + + const result = extractTokenUsage(data, "anthropic"); + + expect(result.cacheCreationTokens).toBe(400); + expect(result.cacheCreation1hTokens).toBeNull(); + }); }); describe("openai (default)", () => { diff --git a/apps/gateway/src/chat/tools/extract-token-usage.ts b/apps/gateway/src/chat/tools/extract-token-usage.ts index cafd11dd90..4b5ec12d83 100644 --- a/apps/gateway/src/chat/tools/extract-token-usage.ts +++ b/apps/gateway/src/chat/tools/extract-token-usage.ts @@ -46,6 +46,8 @@ export function extractTokenUsage( let reasoningTokens = null; let cachedTokens = null; let cacheCreationTokens = null; + let cacheCreation5mTokens: number | null = null; + let cacheCreation1hTokens: number | null = null; switch (provider) { case "google-ai-studio": @@ -115,21 +117,43 @@ export function extractTokenUsage( } break; case "anthropic": - if (data.usage) { + { + const usage = data.message?.usage ?? data.usage; + if (!usage) { + break; + } // For Anthropic: input_tokens are the non-cached tokens // We need to add cache_creation_input_tokens to get total input tokens - const inputTokens = data.usage.input_tokens ?? 0; - const cacheCreation = data.usage.cache_creation_input_tokens ?? 0; - const cacheReadTokens = data.usage.cache_read_input_tokens ?? 0; + const hasInputUsage = + usage.input_tokens !== undefined || + usage.cache_creation_input_tokens !== undefined || + usage.cache_read_input_tokens !== undefined || + usage.cache_creation !== undefined; + if (hasInputUsage) { + const inputTokens = usage.input_tokens ?? 0; + // Anthropic supports two cache TTLs (5m at 1.25x, 1h at 2x). + // `cache_creation_input_tokens` is the sum; the per-TTL breakdown is in + // `usage.cache_creation.{ephemeral_5m_input_tokens, ephemeral_1h_input_tokens}`. + const cacheCreation = usage.cache_creation_input_tokens ?? 0; + const cacheCreation5m = + usage.cache_creation?.ephemeral_5m_input_tokens ?? 0; + const cacheCreation1h = + usage.cache_creation?.ephemeral_1h_input_tokens ?? 0; + const cacheReadTokens = usage.cache_read_input_tokens ?? 0; - // Total prompt tokens = non-cached + cache creation + cache read - promptTokens = inputTokens + cacheCreation + cacheReadTokens; - completionTokens = data.usage.output_tokens ?? null; - reasoningTokens = data.usage.reasoning_output_tokens ?? null; - // Cached tokens are the tokens read from cache (discount applies to these) - cachedTokens = cacheReadTokens; - cacheCreationTokens = cacheCreation; - totalTokens = (promptTokens ?? 0) + (completionTokens ?? 0); + // Total prompt tokens = non-cached + cache creation + cache read + promptTokens = inputTokens + cacheCreation + cacheReadTokens; + // Cached tokens are the tokens read from cache (discount applies to these) + cachedTokens = cacheReadTokens; + cacheCreationTokens = cacheCreation; + cacheCreation5mTokens = cacheCreation5m > 0 ? cacheCreation5m : null; + cacheCreation1hTokens = cacheCreation1h > 0 ? cacheCreation1h : null; + } + completionTokens = usage.output_tokens ?? null; + reasoningTokens = usage.reasoning_output_tokens ?? null; + if (promptTokens !== null && completionTokens !== null) { + totalTokens = promptTokens + completionTokens; + } } break; default: // OpenAI format @@ -160,5 +184,7 @@ export function extractTokenUsage( reasoningTokens, cachedTokens, cacheCreationTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, }; } diff --git a/apps/gateway/src/chat/tools/parse-provider-response.spec.ts b/apps/gateway/src/chat/tools/parse-provider-response.spec.ts index a67b6f1aaa..80cdbef83b 100644 --- a/apps/gateway/src/chat/tools/parse-provider-response.spec.ts +++ b/apps/gateway/src/chat/tools/parse-provider-response.spec.ts @@ -246,6 +246,7 @@ describe("parseProviderResponse", () => { ); expect(result.cachedTokens).toBe(0); + expect(result.cacheCreationTokens).toBe(50); expect(result.promptTokens).toBe(150); // 100 + 50 + 0 }); @@ -268,6 +269,7 @@ describe("parseProviderResponse", () => { ); expect(result.cachedTokens).toBe(800); + expect(result.cacheCreationTokens).toBe(0); expect(result.promptTokens).toBe(900); // 100 + 0 + 800 }); @@ -289,6 +291,56 @@ describe("parseProviderResponse", () => { expect(result.cachedTokens).toBe(0); }); + + it("extracts 1h cache creation tokens from cache_creation breakdown", () => { + const json = { + content: [{ type: "text", text: "Hello" }], + stop_reason: "end_turn", + usage: { + input_tokens: 10, + cache_creation_input_tokens: 1000, + cache_creation: { + ephemeral_5m_input_tokens: 400, + ephemeral_1h_input_tokens: 600, + }, + cache_read_input_tokens: 0, + output_tokens: 50, + }, + }; + + const result = parseProviderResponse( + "anthropic", + "claude-3-sonnet", + json, + ); + + expect(result.cacheCreationTokens).toBe(1000); + expect(result.cacheCreation5mTokens).toBe(400); + expect(result.cacheCreation1hTokens).toBe(600); + }); + + it("returns null cacheCreation1hTokens when cache_creation breakdown is absent", () => { + const json = { + content: [{ type: "text", text: "Hello" }], + stop_reason: "end_turn", + usage: { + input_tokens: 10, + cache_creation_input_tokens: 400, + cache_read_input_tokens: 0, + output_tokens: 50, + }, + }; + + const result = parseProviderResponse( + "anthropic", + "claude-3-sonnet", + json, + ); + + expect(result.cacheCreationTokens).toBe(400); + expect(result.cacheCreation5mTokens).toBeNull(); + expect(result.cacheCreation1hTokens).toBeNull(); + }); }); describe("minimax reasoning extraction", () => { diff --git a/apps/gateway/src/chat/tools/parse-provider-response.ts b/apps/gateway/src/chat/tools/parse-provider-response.ts index b7090f069a..5b7793f052 100644 --- a/apps/gateway/src/chat/tools/parse-provider-response.ts +++ b/apps/gateway/src/chat/tools/parse-provider-response.ts @@ -31,6 +31,8 @@ export function parseProviderResponse( let reasoningTokens = null; let cachedTokens = null; let cacheCreationTokens = null; + let cacheCreation5mTokens: number | null = null; + let cacheCreation1hTokens: number | null = null; let imageInputTokens: number | null = null; let imageOutputTokens: number | null = null; let toolResults = null; @@ -189,7 +191,14 @@ export function parseProviderResponse( // We need to add cache_creation_input_tokens to get total input tokens if (json.usage) { const inputTokens = json.usage.input_tokens ?? 0; + // Anthropic supports two cache TTLs (5m at 1.25x, 1h at 2x). + // `cache_creation_input_tokens` is the sum; the per-TTL breakdown is in + // `usage.cache_creation.{ephemeral_5m_input_tokens, ephemeral_1h_input_tokens}`. const cacheCreation = json.usage.cache_creation_input_tokens ?? 0; + const cacheCreation5m = + json.usage.cache_creation?.ephemeral_5m_input_tokens ?? 0; + const cacheCreation1h = + json.usage.cache_creation?.ephemeral_1h_input_tokens ?? 0; const cacheReadTokens = json.usage.cache_read_input_tokens ?? 0; // Total prompt tokens = non-cached + cache creation + cache read @@ -199,6 +208,8 @@ export function parseProviderResponse( // Cached tokens are the tokens read from cache (discount applies to these) cachedTokens = cacheReadTokens; cacheCreationTokens = cacheCreation; + cacheCreation5mTokens = cacheCreation5m > 0 ? cacheCreation5m : null; + cacheCreation1hTokens = cacheCreation1h > 0 ? cacheCreation1h : null; totalTokens = promptTokens && completionTokens ? promptTokens + completionTokens @@ -858,6 +869,8 @@ export function parseProviderResponse( reasoningTokens, cachedTokens, cacheCreationTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, imageInputTokens, imageOutputTokens, toolResults, diff --git a/apps/gateway/src/chat/tools/transform-response-to-openai.ts b/apps/gateway/src/chat/tools/transform-response-to-openai.ts index c9aec9018e..e83910483d 100644 --- a/apps/gateway/src/chat/tools/transform-response-to-openai.ts +++ b/apps/gateway/src/chat/tools/transform-response-to-openai.ts @@ -8,6 +8,7 @@ export interface CostData { inputCost: number | null; outputCost: number | null; cachedInputCost: number | null; + cacheWriteInputCost?: number | null; requestCost: number | null; webSearchCost: number | null; imageInputCost: number | null; @@ -22,6 +23,8 @@ export function applyExtendedUsageFields( costs?: CostData | null; cachedTokens?: number | null; cacheCreationTokens?: number | null; + cacheCreation5mTokens?: number | null; + cacheCreation1hTokens?: number | null; reasoningTokens?: number | null; imageInputTokens?: number | null; imageOutputTokens?: number | null; @@ -31,6 +34,8 @@ export function applyExtendedUsageFields( costs, cachedTokens, cacheCreationTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, reasoningTokens, imageInputTokens, imageOutputTokens, @@ -47,8 +52,9 @@ export function applyExtendedUsageFields( if (hasInferenceCosts) { const inputCost = costs.inputCost ?? 0; const cachedInputCost = costs.cachedInputCost ?? 0; + const cacheWriteInputCost = costs.cacheWriteInputCost ?? 0; const outputCost = costs.outputCost ?? 0; - const promptCost = inputCost + cachedInputCost; + const promptCost = inputCost + cachedInputCost + cacheWriteInputCost; const completionsCost = outputCost; // upstream_inference_cost intentionally excludes requestCost/webSearchCost, so usage.cost may be larger. usage.cost_details = { @@ -59,6 +65,7 @@ export function applyExtendedUsageFields( input_cost: costs.inputCost, output_cost: costs.outputCost, cached_input_cost: costs.cachedInputCost, + cache_write_input_cost: costs.cacheWriteInputCost, request_cost: costs.requestCost, web_search_cost: costs.webSearchCost, image_input_cost: costs.imageInputCost, @@ -82,6 +89,28 @@ export function applyExtendedUsageFields( 0; const resolvedPromptImageTokens = imageInputTokens ?? existingPromptDetails.image_tokens ?? 0; + // `cache_write_tokens` is the canonical field; `cache_creation_tokens` is emitted + // alongside it for backward compatibility with consumers that read the older name. + // Readers should prefer `cache_write_tokens ?? cache_creation_tokens`. + const existingBreakdown = + (existingPromptDetails.cache_creation as + | { + ephemeral_5m_input_tokens?: number; + ephemeral_1h_input_tokens?: number; + } + | undefined) ?? undefined; + const resolved1h = + cacheCreation1hTokens ?? + existingBreakdown?.ephemeral_1h_input_tokens ?? + null; + const resolved5m = + cacheCreation5mTokens ?? + existingBreakdown?.ephemeral_5m_input_tokens ?? + (resolvedCacheWrite > 0 && resolved1h !== null + ? Math.max(0, resolvedCacheWrite - resolved1h) + : null); + const includeBreakdown = + resolvedCacheWrite > 0 && (resolved5m !== null || resolved1h !== null); usage.prompt_tokens_details = { ...existingPromptDetails, cached_tokens: resolvedCacheRead, @@ -92,6 +121,12 @@ export function applyExtendedUsageFields( ...(resolvedCacheWrite > 0 && { cache_creation_tokens: resolvedCacheWrite, }), + ...(includeBreakdown && { + cache_creation: { + ephemeral_5m_input_tokens: resolved5m ?? 0, + ephemeral_1h_input_tokens: resolved1h ?? 0, + }, + }), }; const existingCompletionDetails = @@ -212,6 +247,8 @@ function buildUsageObject( cacheCreationTokens: number | null = null, imageInputTokens: number | null = null, imageOutputTokens: number | null = null, + cacheCreation5mTokens: number | null = null, + cacheCreation1hTokens: number | null = null, ) { const usage: Record = { prompt_tokens: Math.max(1, promptTokens ?? 1), @@ -233,6 +270,8 @@ function buildUsageObject( costs, cachedTokens, cacheCreationTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, reasoningTokens, imageInputTokens, imageOutputTokens, @@ -270,6 +309,8 @@ export function transformResponseToOpenai( cacheCreationTokens: number | null = null, imageInputTokens: number | null = null, imageOutputTokens: number | null = null, + cacheCreation5mTokens: number | null = null, + cacheCreation1hTokens: number | null = null, ) { let transformedResponse = json; @@ -314,6 +355,8 @@ export function transformResponseToOpenai( cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ), metadata: buildMetadata( requestedModel, @@ -364,6 +407,8 @@ export function transformResponseToOpenai( cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ), metadata: buildMetadata( requestedModel, @@ -411,6 +456,8 @@ export function transformResponseToOpenai( cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ), metadata: buildMetadata( requestedModel, @@ -502,6 +549,8 @@ export function transformResponseToOpenai( cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ), metadata: buildMetadata( requestedModel, @@ -547,6 +596,8 @@ export function transformResponseToOpenai( cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ), metadata: buildMetadata( requestedModel, @@ -644,6 +695,8 @@ export function transformResponseToOpenai( cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ), metadata: buildMetadata( requestedModel, @@ -692,6 +745,8 @@ export function transformResponseToOpenai( cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ), metadata: buildMetadata( requestedModel, @@ -788,6 +843,8 @@ export function transformResponseToOpenai( cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ), metadata: buildMetadata( requestedModel, @@ -875,6 +932,8 @@ export function transformResponseToOpenai( cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ), metadata: buildMetadata( requestedModel, @@ -963,6 +1022,8 @@ export function transformResponseToOpenai( cacheCreationTokens, imageInputTokens, imageOutputTokens, + cacheCreation5mTokens, + cacheCreation1hTokens, ), metadata: buildMetadata( requestedModel, diff --git a/apps/gateway/src/chat/tools/transform-streaming-to-openai.spec.ts b/apps/gateway/src/chat/tools/transform-streaming-to-openai.spec.ts index e170b59f24..9805ab18a5 100644 --- a/apps/gateway/src/chat/tools/transform-streaming-to-openai.spec.ts +++ b/apps/gateway/src/chat/tools/transform-streaming-to-openai.spec.ts @@ -23,6 +23,53 @@ vi.mock("@llmgateway/logger", () => ({ })); describe("transformStreamingToOpenai", () => { + it("maps Anthropic message_start usage with cache creation details", () => { + warn.mockClear(); + + const result = transformStreamingToOpenai( + "anthropic", + "claude-sonnet-4-5", + { + type: "message_start", + message: { + id: "msg_123", + model: "claude-sonnet-4-5", + usage: { + input_tokens: 10, + cache_creation_input_tokens: 1000, + cache_read_input_tokens: 0, + output_tokens: 1, + }, + }, + }, + [], + ); + + expect(result).toMatchObject({ + id: "msg_123", + object: "chat.completion.chunk", + model: "claude-sonnet-4-5", + choices: [ + { + index: 0, + delta: { role: "assistant" }, + finish_reason: null, + }, + ], + usage: { + prompt_tokens: 1010, + completion_tokens: 1, + total_tokens: 1011, + prompt_tokens_details: { + cached_tokens: 0, + cache_write_tokens: 1000, + cache_creation_tokens: 1000, + }, + }, + }); + expect(warn).not.toHaveBeenCalled(); + }); + it("ignores OpenAI keepalive events without warning", () => { warn.mockClear(); diff --git a/apps/gateway/src/chat/tools/transform-streaming-to-openai.ts b/apps/gateway/src/chat/tools/transform-streaming-to-openai.ts index 78f3a58c98..231b2b2a65 100644 --- a/apps/gateway/src/chat/tools/transform-streaming-to-openai.ts +++ b/apps/gateway/src/chat/tools/transform-streaming-to-openai.ts @@ -14,23 +14,43 @@ function normalizeAnthropicUsage(usage: any): any { if (!usage || typeof usage !== "object") { return null; } - const inputTokens = usage.input_tokens ?? 0; - const cacheCreation = usage.cache_creation_input_tokens ?? 0; - const cacheRead = usage.cache_read_input_tokens ?? 0; - const outputTokens = usage.output_tokens ?? 0; - const promptTokens = inputTokens + cacheCreation + cacheRead; - const hasCacheInfo = cacheRead > 0 || cacheCreation > 0; - return { - prompt_tokens: promptTokens, - completion_tokens: outputTokens, - total_tokens: promptTokens + outputTokens, - ...(hasCacheInfo && { - prompt_tokens_details: { - cached_tokens: cacheRead, - ...(cacheCreation > 0 && { cache_creation_tokens: cacheCreation }), - }, - }), + const hasInputUsage = + usage.input_tokens !== undefined || + usage.cache_creation_input_tokens !== undefined || + usage.cache_read_input_tokens !== undefined; + const outputTokens = usage.output_tokens; + if (!hasInputUsage && outputTokens === undefined) { + return null; + } + + const inputTokens = hasInputUsage ? (usage.input_tokens ?? 0) : null; + const cacheCreation = hasInputUsage + ? (usage.cache_creation_input_tokens ?? 0) + : null; + const cacheRead = hasInputUsage ? (usage.cache_read_input_tokens ?? 0) : null; + const promptTokens = hasInputUsage + ? (inputTokens ?? 0) + (cacheCreation ?? 0) + (cacheRead ?? 0) + : null; + const normalizedUsage: Record = { + ...(promptTokens !== null && { prompt_tokens: promptTokens }), + ...(outputTokens !== undefined && { completion_tokens: outputTokens }), + ...(promptTokens !== null && + outputTokens !== undefined && { + total_tokens: promptTokens + outputTokens, + }), + ...(cacheRead !== null && + cacheCreation !== null && + (cacheRead > 0 || cacheCreation > 0) && { + prompt_tokens_details: { + cached_tokens: cacheRead, + ...(cacheCreation > 0 && { + cache_write_tokens: cacheCreation, + cache_creation_tokens: cacheCreation, + }), + }, + }), }; + return normalizedUsage; } export function transformStreamingToOpenai( @@ -66,7 +86,25 @@ export function transformStreamingToOpenai( switch (usedProvider) { case "anthropic": { - if (data.type === "content_block_delta" && data.delta?.text) { + const usage = data.message?.usage ?? data.usage; + if (data.type === "message_start") { + transformedData = { + id: data.message?.id ?? data.id ?? `chatcmpl-${Date.now()}`, + object: "chat.completion.chunk", + created: data.created ?? Math.floor(Date.now() / 1000), + model: data.message?.model ?? data.model ?? usedModel, + choices: [ + { + index: 0, + delta: { + role: "assistant", + }, + finish_reason: null, + }, + ], + usage: normalizeAnthropicUsage(usage), + }; + } else if (data.type === "content_block_delta" && data.delta?.text) { transformedData = { id: data.id ?? `chatcmpl-${Date.now()}`, object: "chat.completion.chunk", @@ -82,7 +120,7 @@ export function transformStreamingToOpenai( finish_reason: null, }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } else if ( data.type === "content_block_delta" && @@ -104,7 +142,7 @@ export function transformStreamingToOpenai( finish_reason: null, }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } else if ( data.type === "content_block_start" && @@ -130,7 +168,7 @@ export function transformStreamingToOpenai( finish_reason: null, }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } else if ( data.type === "content_block_start" && @@ -161,7 +199,7 @@ export function transformStreamingToOpenai( finish_reason: null, }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } else if ( data.type === "content_block_delta" && @@ -187,7 +225,7 @@ export function transformStreamingToOpenai( finish_reason: null, }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } else { transformedData = { @@ -212,7 +250,7 @@ export function transformStreamingToOpenai( finish_reason: null, }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } } else if ( @@ -248,7 +286,7 @@ export function transformStreamingToOpenai( finish_reason: null, }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } else if (data.type === "message_delta" && data.delta?.stop_reason) { const stopReason = data.delta.stop_reason; @@ -266,7 +304,7 @@ export function transformStreamingToOpenai( finish_reason: mapFinishReasonToOpenai(stopReason, usedProvider), }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } else if (data.type === "message_stop" || data.stop_reason) { const stopReason = data.stop_reason ?? "end_turn"; @@ -284,7 +322,7 @@ export function transformStreamingToOpenai( finish_reason: mapFinishReasonToOpenai(stopReason, usedProvider), }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } else if (data.delta?.text) { transformedData = { @@ -302,7 +340,7 @@ export function transformStreamingToOpenai( finish_reason: null, }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } else if (data.type === "ping") { return null; @@ -328,7 +366,7 @@ export function transformStreamingToOpenai( finish_reason: null, }, ], - usage: normalizeAnthropicUsage(data.usage), + usage: normalizeAnthropicUsage(usage), }; } break; diff --git a/apps/gateway/src/lib/anthropic-pricing.spec.ts b/apps/gateway/src/lib/anthropic-pricing.spec.ts new file mode 100644 index 0000000000..5284f9ad69 --- /dev/null +++ b/apps/gateway/src/lib/anthropic-pricing.spec.ts @@ -0,0 +1,139 @@ +import { describe, expect, it } from "vitest"; + +import { models, type ProviderModelMapping } from "@llmgateway/models"; + +const FIVE_MIN_WRITE_MULTIPLIER = 1.25; +const ONE_HOUR_WRITE_MULTIPLIER = 2; +const CACHE_READ_MULTIPLIER = 0.1; +const RATIO_TOLERANCE = 1e-9; + +const LEGACY_RATIO_EXCEPTIONS = new Set(["claude-3-haiku-20240307"]); + +function assertRatio( + modelName: string, + label: string, + actual: number, + expected: number, +) { + expect( + actual, + `${modelName} ${label}: expected ${expected} (got ${actual}). If Anthropic's published price diverges from the standard multiplier, add the modelName to LEGACY_RATIO_EXCEPTIONS.`, + ).toBeCloseTo(expected, undefined); + expect(Math.abs(actual - expected)).toBeLessThan( + Math.max(expected * 1e-6, RATIO_TOLERANCE), + ); +} + +describe("Anthropic model pricing", () => { + const anthropicProviderEntries = models.flatMap((model) => + model.family === "anthropic" + ? model.providers + .filter((provider) => provider.providerId === "anthropic") + .map((provider) => ({ + modelId: model.id, + provider: provider as ProviderModelMapping, + })) + : [], + ); + + it("has at least one anthropic provider mapping to validate", () => { + expect(anthropicProviderEntries.length).toBeGreaterThan(0); + }); + + it.each(anthropicProviderEntries)( + "$modelId defines cacheWriteInputPrice1h whenever cacheWriteInputPrice is set", + ({ provider }) => { + if (provider.cacheWriteInputPrice === undefined) { + return; + } + expect( + provider.cacheWriteInputPrice1h, + `${provider.modelName}: cacheWriteInputPrice is set but cacheWriteInputPrice1h is missing — 1h cache writes would silently bill at the 5m rate`, + ).toBeDefined(); + }, + ); + + it.each(anthropicProviderEntries)( + "$modelId defines cacheWriteInputPrice1h on every pricing tier that sets cacheWriteInputPrice", + ({ provider }) => { + const tiers = provider.pricingTiers ?? []; + for (const tier of tiers) { + if (tier.cacheWriteInputPrice === undefined) { + continue; + } + expect( + tier.cacheWriteInputPrice1h, + `${provider.modelName} tier "${tier.name}": cacheWriteInputPrice is set but cacheWriteInputPrice1h is missing`, + ).toBeDefined(); + } + }, + ); + + it.each(anthropicProviderEntries)( + "$modelId cache prices follow the standard 1.25x/2x/0.1x ratios", + ({ provider }) => { + if (LEGACY_RATIO_EXCEPTIONS.has(provider.modelName)) { + return; + } + if (provider.inputPrice === undefined) { + return; + } + const base = provider.inputPrice; + if (provider.cacheWriteInputPrice !== undefined) { + assertRatio( + provider.modelName, + "cacheWriteInputPrice (5m)", + provider.cacheWriteInputPrice, + base * FIVE_MIN_WRITE_MULTIPLIER, + ); + } + if (provider.cacheWriteInputPrice1h !== undefined) { + assertRatio( + provider.modelName, + "cacheWriteInputPrice1h", + provider.cacheWriteInputPrice1h, + base * ONE_HOUR_WRITE_MULTIPLIER, + ); + } + if (provider.cachedInputPrice !== undefined) { + assertRatio( + provider.modelName, + "cachedInputPrice", + provider.cachedInputPrice, + base * CACHE_READ_MULTIPLIER, + ); + } + for (const tier of provider.pricingTiers ?? []) { + if (tier.inputPrice === undefined) { + continue; + } + const tierBase = tier.inputPrice; + const label = `tier "${tier.name}"`; + if (tier.cacheWriteInputPrice !== undefined) { + assertRatio( + provider.modelName, + `${label} cacheWriteInputPrice (5m)`, + tier.cacheWriteInputPrice, + tierBase * FIVE_MIN_WRITE_MULTIPLIER, + ); + } + if (tier.cacheWriteInputPrice1h !== undefined) { + assertRatio( + provider.modelName, + `${label} cacheWriteInputPrice1h`, + tier.cacheWriteInputPrice1h, + tierBase * ONE_HOUR_WRITE_MULTIPLIER, + ); + } + if (tier.cachedInputPrice !== undefined) { + assertRatio( + provider.modelName, + `${label} cachedInputPrice`, + tier.cachedInputPrice, + tierBase * CACHE_READ_MULTIPLIER, + ); + } + } + }, + ); +}); diff --git a/apps/gateway/src/lib/costs.spec.ts b/apps/gateway/src/lib/costs.spec.ts index 8d5d856d9c..bfab453a38 100644 --- a/apps/gateway/src/lib/costs.spec.ts +++ b/apps/gateway/src/lib/costs.spec.ts @@ -118,18 +118,88 @@ describe("calculateCosts", () => { 1663, 50, 0, + undefined, + null, + 0, + undefined, + 0, + null, + null, + undefined, + { + cacheWriteTokens: 1659, + }, ); - expect(result.inputCost).toBeCloseTo(0.004989); // 1663 * 0.000003 (all tokens charged full price) + expect(result.inputCost).toBeCloseTo(0.000012); // 4 * 0.000003 (non-cache-write tokens) expect(result.outputCost).toBeCloseTo(0.00075); // 50 * 0.000015 expect(result.cachedInputCost).toBeCloseTo(0); // 0 cache reads - expect(result.totalCost).toBeCloseTo(0.005739); // 0.004989 + 0.00075 + 0 + expect(result.cacheWriteInputCost).toBeCloseTo(0.00622125); // 1659 * 0.00000375 + expect(result.totalCost).toBeCloseTo(0.00698325); // 0.000012 + 0.00075 + 0.00622125 expect(result.promptTokens).toBe(1663); expect(result.completionTokens).toBe(50); expect(result.cachedTokens).toBe(0); + expect(result.cacheWriteTokens).toBe(1659); expect(result.estimatedCost).toBe(false); // Not estimated }); + it("should price 1h cache writes at the 1h rate when cacheWrite1hTokens is provided", async () => { + // claude-3-5-sonnet-20241022 input is 3.0/1M; 5m write 3.75/1M; 1h write 6.0/1M. + // 4 non-cached + 1000 cache creation total (300 5m + 700 1h) = 1004 prompt tokens. + const result = await calculateCosts( + "claude-3-5-sonnet-20241022", + "anthropic", + 1004, + 50, + 0, + undefined, + null, + 0, + undefined, + 0, + null, + null, + undefined, + { + cacheWriteTokens: 1000, + cacheWrite1hTokens: 700, + }, + ); + + expect(result.inputCost).toBeCloseTo(4 * (3.0 / 1e6)); + // 300 tokens at 5m rate (3.75/1M) + 700 tokens at 1h rate (6.0/1M) + const fiveMinuteCost = 300 * (3.75 / 1e6); + const oneHourCost = 700 * (6.0 / 1e6); + expect(result.cacheWriteInputCost).toBeCloseTo( + fiveMinuteCost + oneHourCost, + ); + expect(result.cacheWriteTokens).toBe(1000); + }); + + it("should fall back to the 5m rate for cache writes when no 1h count is provided", async () => { + // Pre-existing behavior: cacheWriteTokens is the sum, priced entirely at 5m rate. + const result = await calculateCosts( + "claude-3-5-sonnet-20241022", + "anthropic", + 1004, + 50, + 0, + undefined, + null, + 0, + undefined, + 0, + null, + null, + undefined, + { + cacheWriteTokens: 1000, + }, + ); + + expect(result.cacheWriteInputCost).toBeCloseTo(1000 * (3.75 / 1e6)); + }); + it("should calculate costs with cached tokens for Anthropic (subsequent request - cache read)", async () => { // For Anthropic subsequent request: 4 non-cached + 1659 cache read = 1663 total tokens, 1659 cache reads const result = await calculateCosts( @@ -143,6 +213,7 @@ describe("calculateCosts", () => { expect(result.inputCost).toBeCloseTo(0.000012); // 4 * 0.000003 (only non-cached tokens at full price) expect(result.outputCost).toBeCloseTo(0.00075); // 50 * 0.000015 expect(result.cachedInputCost).toBeCloseTo(0.0004977); // 1659 * 0.0000003 (cached token price) + expect(result.cacheWriteInputCost).toBeCloseTo(0); expect(result.totalCost).toBeCloseTo(0.0012597); // 0.000012 + 0.00075 + 0.0004977 expect(result.promptTokens).toBe(1663); expect(result.completionTokens).toBe(50); diff --git a/apps/gateway/src/lib/costs.ts b/apps/gateway/src/lib/costs.ts index 18de5f5365..f90748bcb5 100644 --- a/apps/gateway/src/lib/costs.ts +++ b/apps/gateway/src/lib/costs.ts @@ -37,11 +37,15 @@ function getPricingForTokenCount( baseInputPrice: number, baseOutputPrice: number, baseCachedInputPrice: number | undefined, + baseCacheWriteInputPrice: number | undefined, + baseCacheWriteInputPrice1h: number | undefined, promptTokens: number, ): { inputPrice: number; outputPrice: number; cachedInputPrice: number | undefined; + cacheWriteInputPrice: number | undefined; + cacheWriteInputPrice1h: number | undefined; tierName: string | undefined; } { if (!pricingTiers || pricingTiers.length === 0) { @@ -49,6 +53,8 @@ function getPricingForTokenCount( inputPrice: baseInputPrice, outputPrice: baseOutputPrice, cachedInputPrice: baseCachedInputPrice, + cacheWriteInputPrice: baseCacheWriteInputPrice, + cacheWriteInputPrice1h: baseCacheWriteInputPrice1h, tierName: undefined, }; } @@ -60,6 +66,10 @@ function getPricingForTokenCount( inputPrice: tier.inputPrice, outputPrice: tier.outputPrice, cachedInputPrice: tier.cachedInputPrice ?? baseCachedInputPrice, + cacheWriteInputPrice: + tier.cacheWriteInputPrice ?? baseCacheWriteInputPrice, + cacheWriteInputPrice1h: + tier.cacheWriteInputPrice1h ?? baseCacheWriteInputPrice1h, tierName: tier.name, }; } @@ -71,6 +81,10 @@ function getPricingForTokenCount( inputPrice: lastTier.inputPrice, outputPrice: lastTier.outputPrice, cachedInputPrice: lastTier.cachedInputPrice ?? baseCachedInputPrice, + cacheWriteInputPrice: + lastTier.cacheWriteInputPrice ?? baseCacheWriteInputPrice, + cacheWriteInputPrice1h: + lastTier.cacheWriteInputPrice1h ?? baseCacheWriteInputPrice1h, tierName: lastTier.name, }; } @@ -101,7 +115,14 @@ export async function calculateCosts( webSearchCount: number | null = null, organizationId: string | null = null, imageQuality?: string, + options?: { + cacheWriteTokens?: number | null; + cacheWrite1hTokens?: number | null; + }, ) { + const cacheWriteTokens = options?.cacheWriteTokens ?? null; + const cacheWrite1hTokens = options?.cacheWrite1hTokens ?? null; + // Find the model info - try both base model name and provider model name // Strip :region suffix if present (e.g., "deepseek-v3.2:cn-beijing" → "deepseek-v3.2") const baseModel = model.includes(":") ? model.split(":")[0] : model; @@ -122,6 +143,7 @@ export async function calculateCosts( inputCost: null, outputCost: null, cachedInputCost: null, + cacheWriteInputCost: null, requestCost: null, webSearchCost: null, imageInputTokens: null, @@ -133,6 +155,7 @@ export async function calculateCosts( promptTokens, completionTokens, cachedTokens, + cacheWriteTokens, estimatedCost: false, discount: undefined, pricingTier: undefined, @@ -194,6 +217,7 @@ export async function calculateCosts( inputCost: null, outputCost: null, cachedInputCost: null, + cacheWriteInputCost: null, requestCost: null, webSearchCost: null, imageInputTokens: null, @@ -205,6 +229,7 @@ export async function calculateCosts( promptTokens: calculatedPromptTokens, completionTokens: calculatedCompletionTokens, cachedTokens, + cacheWriteTokens, estimatedCost: isEstimated, discount: undefined, pricingTier: undefined, @@ -233,6 +258,7 @@ export async function calculateCosts( inputCost: null, outputCost: null, cachedInputCost: null, + cacheWriteInputCost: null, requestCost: null, webSearchCost: null, imageInputTokens: null, @@ -244,6 +270,7 @@ export async function calculateCosts( promptTokens: calculatedPromptTokens, completionTokens: calculatedCompletionTokens, cachedTokens, + cacheWriteTokens, estimatedCost: isEstimated, discount: undefined, pricingTier: undefined, @@ -256,6 +283,8 @@ export async function calculateCosts( providerInfo.inputPrice ?? 0, providerInfo.outputPrice ?? 0, providerInfo.cachedInputPrice, + providerInfo.cacheWriteInputPrice, + providerInfo.cacheWriteInputPrice1h, calculatedPromptTokens, ); @@ -264,6 +293,17 @@ export async function calculateCosts( const cachedInputPrice = new Decimal( pricing.cachedInputPrice ?? pricing.inputPrice, ); + const cacheWriteInputPrice = + pricing.cacheWriteInputPrice !== undefined + ? new Decimal(pricing.cacheWriteInputPrice) + : null; + // 1-hour cache writes fall back to the 5m rate when no separate price is set, + // so providers without an explicit 1h price (e.g., non-Anthropic) keep + // their existing behavior. + const cacheWriteInputPrice1h = + pricing.cacheWriteInputPrice1h !== undefined + ? new Decimal(pricing.cacheWriteInputPrice1h) + : cacheWriteInputPrice; const requestPrice = new Decimal(providerInfo.requestPrice ?? 0); // Get effective discount (checks org-specific, global, then hardcoded) @@ -315,9 +355,16 @@ export async function calculateCosts( // For Anthropic: calculatedPromptTokens includes all tokens, but we need to subtract cached tokens // that get charged at the discounted rate // For other providers (like OpenAI), prompt_tokens includes cached tokens, so we subtract them too - const uncachedPromptTokens = cachedTokens - ? calculatedPromptTokens - cachedTokens - : calculatedPromptTokens; + const cachedReadTokens = cachedTokens ?? 0; + const separatelyPricedCacheWriteTokens = cacheWriteInputPrice + ? (cacheWriteTokens ?? 0) + : 0; + const uncachedPromptTokens = Math.max( + 0, + calculatedPromptTokens - + cachedReadTokens - + separatelyPricedCacheWriteTokens, + ); // inputCost includes both text and image input costs when applicable const inputCost = new Decimal(uncachedPromptTokens) .times(inputPrice) @@ -373,6 +420,29 @@ export async function calculateCosts( .times(cachedInputPrice) .times(discountMultiplier) : new Decimal(0); + // `cacheWriteTokens` is the total cache-creation tokens (5m + 1h). + // `cacheWrite1hTokens` is the 1h subset; the remainder is treated as 5m. + // Each TTL is priced at its own rate; non-Anthropic providers without a + // separate 1h rate fall back to the 5m rate for both, matching prior behavior. + const totalCacheWriteTokens = cacheWriteTokens ?? 0; + const oneHourCacheWriteTokens = Math.min( + cacheWrite1hTokens ?? 0, + totalCacheWriteTokens, + ); + const fiveMinuteCacheWriteTokens = Math.max( + 0, + totalCacheWriteTokens - oneHourCacheWriteTokens, + ); + const cacheWriteInputCost = cacheWriteInputPrice + ? new Decimal(fiveMinuteCacheWriteTokens) + .times(cacheWriteInputPrice) + .plus( + new Decimal(oneHourCacheWriteTokens).times( + cacheWriteInputPrice1h ?? cacheWriteInputPrice, + ), + ) + .times(discountMultiplier) + : new Decimal(0); const requestCost = requestPrice.times(discountMultiplier); // Calculate web search cost @@ -387,6 +457,7 @@ export async function calculateCosts( const totalCost = inputCost .plus(outputCost) .plus(cachedInputCost) + .plus(cacheWriteInputCost) .plus(requestCost) .plus(webSearchCost); @@ -394,6 +465,7 @@ export async function calculateCosts( inputCost: inputCost.toNumber(), outputCost: outputCost.toNumber(), cachedInputCost: cachedInputCost.toNumber(), + cacheWriteInputCost: cacheWriteInputCost.toNumber(), requestCost: requestCost.toNumber(), webSearchCost: webSearchCost.toNumber(), imageInputTokens, @@ -415,6 +487,7 @@ export async function calculateCosts( : calculatedPromptTokens, completionTokens: calculatedCompletionTokens, cachedTokens, + cacheWriteTokens, estimatedCost: isEstimated, discount: discount !== 0 ? discount : undefined, pricingTier: pricing.tierName, diff --git a/apps/gateway/src/models/models.ts b/apps/gateway/src/models/models.ts index 6387de5f33..a03730c447 100644 --- a/apps/gateway/src/models/models.ts +++ b/apps/gateway/src/models/models.ts @@ -62,6 +62,7 @@ const modelSchema = z.object({ request: z.string().optional(), input_cache_read: z.string().optional(), input_cache_write: z.string().optional(), + input_cache_write_1h: z.string().optional(), web_search: z.string().optional(), internal_reasoning: z.string().optional(), }), @@ -250,7 +251,10 @@ modelsApi.openapi(listModels, async (c) => { request: firstProviderWithPricing?.requestPrice?.toString() ?? "0", input_cache_read: firstProviderWithPricing?.cachedInputPrice?.toString() ?? "0", - input_cache_write: "0", // Not defined in model definitions yet + input_cache_write: + firstProviderWithPricing?.cacheWriteInputPrice?.toString() ?? "0", + input_cache_write_1h: + firstProviderWithPricing?.cacheWriteInputPrice1h?.toString() ?? "0", web_search: "0", // Not defined in model definitions yet internal_reasoning: "0", // Not defined in model definitions yet }, diff --git a/apps/gateway/src/native-anthropic-cache.e2e.ts b/apps/gateway/src/native-anthropic-cache.e2e.ts index ae263cba35..8e24cc016b 100644 --- a/apps/gateway/src/native-anthropic-cache.e2e.ts +++ b/apps/gateway/src/native-anthropic-cache.e2e.ts @@ -518,4 +518,74 @@ describe("e2e native /v1/messages cache", getConcurrentTestOptions(), () => { ).toBeGreaterThan(0); }, ); + + // 1h cache TTL via /v1/messages: opts into Anthropic's 1h cache write rate + // (2x base) and asserts the gateway round-trips both the request opt-in + // and the response breakdown (usage.cache_creation.ephemeral_1h_input_tokens) + // per Anthropic's spec, so SDK clients can attribute spend across rates. + (hasAnthropicKey ? test : test.skip)( + "native messages forwards 1h ttl and surfaces cache_creation breakdown", + getTestOptions(), + async () => { + const longText = buildLongSystemPrompt(); + const body = { + model: "anthropic/claude-haiku-4-5", + max_tokens: 50, + system: [ + { + type: "text" as const, + text: longText, + cache_control: { type: "ephemeral" as const, ttl: "1h" as const }, + }, + ], + messages: [ + { + role: "user" as const, + content: "Just reply OK.", + }, + ], + }; + + const send = async () => { + const requestId = generateTestRequestId(); + const res = await app.request("/v1/messages", { + method: "POST", + headers: { + "Content-Type": "application/json", + "x-request-id": requestId, + Authorization: `Bearer real-token`, + }, + body: JSON.stringify(body), + }); + const json = await res.json(); + if (logMode) { + console.log( + "native /v1/messages 1h", + requestId, + "status", + res.status, + "usage", + JSON.stringify(json.usage), + ); + } + return { status: res.status, json }; + }; + + const first = await send(); + expect(first.status).toBe(200); + // On the priming call Anthropic should write to the 1h cache. + // If the schema strips ttl, this falls back to 5m and the breakdown + // either omits ephemeral_1h_input_tokens or reports 0. + const firstBreakdown = first.json.usage?.cache_creation; + if (first.json.usage?.cache_creation_input_tokens > 0) { + expect(firstBreakdown).toBeDefined(); + expect(firstBreakdown.ephemeral_1h_input_tokens).toBeGreaterThan(0); + expect(firstBreakdown.ephemeral_5m_input_tokens).toBe(0); + expect( + firstBreakdown.ephemeral_5m_input_tokens + + firstBreakdown.ephemeral_1h_input_tokens, + ).toBe(first.json.usage.cache_creation_input_tokens); + } + }, + ); }); diff --git a/apps/gateway/src/responses/tools/convert-chat-to-responses.ts b/apps/gateway/src/responses/tools/convert-chat-to-responses.ts index b1d5d5b945..c734e11c03 100644 --- a/apps/gateway/src/responses/tools/convert-chat-to-responses.ts +++ b/apps/gateway/src/responses/tools/convert-chat-to-responses.ts @@ -49,6 +49,7 @@ interface ChatCompletionsResponse { input_cost?: number | null; output_cost?: number | null; cached_input_cost?: number | null; + cache_write_input_cost?: number | null; request_cost?: number | null; web_search_cost?: number | null; image_input_cost?: number | null; @@ -84,6 +85,7 @@ export interface ResponsesApiUsage { input_cost?: number | null; output_cost?: number | null; cached_input_cost?: number | null; + cache_write_input_cost?: number | null; request_cost?: number | null; web_search_cost?: number | null; image_input_cost?: number | null; diff --git a/apps/gateway/src/responses/tools/convert-streaming-to-responses.ts b/apps/gateway/src/responses/tools/convert-streaming-to-responses.ts index 752ac4db3e..bbb8bfcd42 100644 --- a/apps/gateway/src/responses/tools/convert-streaming-to-responses.ts +++ b/apps/gateway/src/responses/tools/convert-streaming-to-responses.ts @@ -41,6 +41,7 @@ interface StreamingState { input_cost?: number | null; output_cost?: number | null; cached_input_cost?: number | null; + cache_write_input_cost?: number | null; request_cost?: number | null; web_search_cost?: number | null; image_input_cost?: number | null; diff --git a/apps/playground/src/lib/api/v1.d.ts b/apps/playground/src/lib/api/v1.d.ts index c87e5a8647..0c6bd0f1a2 100644 --- a/apps/playground/src/lib/api/v1.d.ts +++ b/apps/playground/src/lib/api/v1.d.ts @@ -903,6 +903,7 @@ export interface paths { completionTokens: string | null; totalTokens: string | null; reasoningTokens: string | null; + cacheWriteTokens?: string | null; messages?: unknown; temperature: number | null; maxTokens: number | null; @@ -963,6 +964,7 @@ export interface paths { outputCost: number | null; requestCost: number | null; cachedInputCost?: number | null; + cacheWriteInputCost?: number | null; webSearchCost?: number | null; imageInputTokens: string | null; imageOutputTokens: string | null; @@ -1151,6 +1153,7 @@ export interface paths { completionTokens: string | null; totalTokens: string | null; reasoningTokens: string | null; + cacheWriteTokens?: string | null; messages?: unknown; temperature: number | null; maxTokens: number | null; @@ -1211,6 +1214,7 @@ export interface paths { outputCost: number | null; requestCost: number | null; cachedInputCost?: number | null; + cacheWriteInputCost?: number | null; webSearchCost?: number | null; imageInputTokens: string | null; imageOutputTokens: string | null; @@ -1340,6 +1344,7 @@ export interface paths { inputTokens: number; outputTokens: number; cachedTokens: number; + cacheWriteTokens: number; totalTokens: number; cost: number; inputCost: number; @@ -1350,6 +1355,7 @@ export interface paths { imageOutputCost: number; videoOutputCost: number; cachedInputCost: number; + cacheWriteInputCost: number; errorCount: number; errorRate: number; cacheCount: number; @@ -1605,6 +1611,8 @@ export interface paths { outputCost: number; cachedTokens: number; cachedCost: number; + cacheWriteTokens: number; + cacheWriteCost: number; mostUsedModel: string | null; mostUsedProvider: string | null; mostUsedModelCost: number; @@ -1928,6 +1936,8 @@ export interface paths { outputCost: number; cachedTokens: number; cachedCost: number; + cacheWriteTokens: number; + cacheWriteCost: number; mostUsedModel: string | null; mostUsedProvider: string | null; mostUsedModelCost: number; @@ -2002,12 +2012,14 @@ export interface paths { totalTokens: string | null; reasoningTokens: string | null; cachedTokens: string | null; + cacheWriteTokens: string | null; imageInputTokens: string | null; imageOutputTokens: string | null; cost: number | null; inputCost: number | null; outputCost: number | null; cachedInputCost: number | null; + cacheWriteInputCost: number | null; requestCost: number | null; webSearchCost: number | null; imageInputCost: number | null; @@ -3405,6 +3417,8 @@ export interface paths { inputPrice: string | null; outputPrice: string | null; cachedInputPrice: string | null; + cacheWriteInputPrice: string | null; + cacheWriteInputPrice1h: string | null; imageInputPrice: string | null; requestPrice: string | null; contextSize: number | null; @@ -8684,6 +8698,8 @@ export interface operations { inputPrice: string | null; outputPrice: string | null; cachedInputPrice: string | null; + cacheWriteInputPrice: string | null; + cacheWriteInputPrice1h: string | null; imageInputPrice: string | null; imageOutputPrice: string | null; imageInputTokensByResolution: { diff --git a/apps/playground/src/lib/fetch-models.ts b/apps/playground/src/lib/fetch-models.ts index 124b44a920..e281fe439f 100644 --- a/apps/playground/src/lib/fetch-models.ts +++ b/apps/playground/src/lib/fetch-models.ts @@ -23,6 +23,8 @@ export interface ApiModelProviderMapping { inputPrice: string | null; outputPrice: string | null; cachedInputPrice: string | null; + cacheWriteInputPrice: string | null; + cacheWriteInputPrice1h: string | null; imageInputPrice: string | null; imageOutputPrice: string | null; imageInputTokensByResolution: Record | null; diff --git a/apps/ui/src/app/providers/[id]/page.tsx b/apps/ui/src/app/providers/[id]/page.tsx index cd5bb700c3..bff184de1f 100644 --- a/apps/ui/src/app/providers/[id]/page.tsx +++ b/apps/ui/src/app/providers/[id]/page.tsx @@ -68,6 +68,9 @@ export default async function ProviderPage({ params }: ProviderPageProps) { inputPrice: map.inputPrice?.toString() ?? null, outputPrice: map.outputPrice?.toString() ?? null, cachedInputPrice: map.cachedInputPrice?.toString() ?? null, + cacheWriteInputPrice: map.cacheWriteInputPrice?.toString() ?? null, + cacheWriteInputPrice1h: + map.cacheWriteInputPrice1h?.toString() ?? null, imageInputPrice: map.imageInputPrice?.toString() ?? null, imageOutputPrice: map.imageOutputPrice?.toString() ?? null, imageInputTokensByResolution: diff --git a/apps/ui/src/components/models-supported.tsx b/apps/ui/src/components/models-supported.tsx index 62ad66bfb9..3737572ef7 100644 --- a/apps/ui/src/components/models-supported.tsx +++ b/apps/ui/src/components/models-supported.tsx @@ -113,6 +113,9 @@ const convertToApiModel = ( inputPrice: map.inputPrice?.toString() ?? null, outputPrice: map.outputPrice?.toString() ?? null, cachedInputPrice: map.cachedInputPrice?.toString() ?? null, + cacheWriteInputPrice: map.cacheWriteInputPrice?.toString() ?? null, + cacheWriteInputPrice1h: + map.cacheWriteInputPrice1h?.toString() ?? null, imageInputPrice: map.imageInputPrice?.toString() ?? null, imageOutputPrice: map.imageOutputPrice?.toString() ?? null, imageInputTokensByResolution: diff --git a/apps/ui/src/components/models/adapt-model.ts b/apps/ui/src/components/models/adapt-model.ts index a3d960245e..b408d91821 100644 --- a/apps/ui/src/components/models/adapt-model.ts +++ b/apps/ui/src/components/models/adapt-model.ts @@ -46,6 +46,8 @@ export function adaptProviderMapping( inputPrice: toStr(p.inputPrice), outputPrice: toStr(p.outputPrice), cachedInputPrice: toStr(p.cachedInputPrice), + cacheWriteInputPrice: toStr(p.cacheWriteInputPrice), + cacheWriteInputPrice1h: toStr(p.cacheWriteInputPrice1h), imageInputPrice: toStr(p.imageInputPrice), imageOutputPrice: toStr(p.imageOutputPrice), imageInputTokensByResolution: p.imageInputTokensByResolution ?? null, diff --git a/apps/ui/src/lib/api/v1.d.ts b/apps/ui/src/lib/api/v1.d.ts index c87e5a8647..0c6bd0f1a2 100644 --- a/apps/ui/src/lib/api/v1.d.ts +++ b/apps/ui/src/lib/api/v1.d.ts @@ -903,6 +903,7 @@ export interface paths { completionTokens: string | null; totalTokens: string | null; reasoningTokens: string | null; + cacheWriteTokens?: string | null; messages?: unknown; temperature: number | null; maxTokens: number | null; @@ -963,6 +964,7 @@ export interface paths { outputCost: number | null; requestCost: number | null; cachedInputCost?: number | null; + cacheWriteInputCost?: number | null; webSearchCost?: number | null; imageInputTokens: string | null; imageOutputTokens: string | null; @@ -1151,6 +1153,7 @@ export interface paths { completionTokens: string | null; totalTokens: string | null; reasoningTokens: string | null; + cacheWriteTokens?: string | null; messages?: unknown; temperature: number | null; maxTokens: number | null; @@ -1211,6 +1214,7 @@ export interface paths { outputCost: number | null; requestCost: number | null; cachedInputCost?: number | null; + cacheWriteInputCost?: number | null; webSearchCost?: number | null; imageInputTokens: string | null; imageOutputTokens: string | null; @@ -1340,6 +1344,7 @@ export interface paths { inputTokens: number; outputTokens: number; cachedTokens: number; + cacheWriteTokens: number; totalTokens: number; cost: number; inputCost: number; @@ -1350,6 +1355,7 @@ export interface paths { imageOutputCost: number; videoOutputCost: number; cachedInputCost: number; + cacheWriteInputCost: number; errorCount: number; errorRate: number; cacheCount: number; @@ -1605,6 +1611,8 @@ export interface paths { outputCost: number; cachedTokens: number; cachedCost: number; + cacheWriteTokens: number; + cacheWriteCost: number; mostUsedModel: string | null; mostUsedProvider: string | null; mostUsedModelCost: number; @@ -1928,6 +1936,8 @@ export interface paths { outputCost: number; cachedTokens: number; cachedCost: number; + cacheWriteTokens: number; + cacheWriteCost: number; mostUsedModel: string | null; mostUsedProvider: string | null; mostUsedModelCost: number; @@ -2002,12 +2012,14 @@ export interface paths { totalTokens: string | null; reasoningTokens: string | null; cachedTokens: string | null; + cacheWriteTokens: string | null; imageInputTokens: string | null; imageOutputTokens: string | null; cost: number | null; inputCost: number | null; outputCost: number | null; cachedInputCost: number | null; + cacheWriteInputCost: number | null; requestCost: number | null; webSearchCost: number | null; imageInputCost: number | null; @@ -3405,6 +3417,8 @@ export interface paths { inputPrice: string | null; outputPrice: string | null; cachedInputPrice: string | null; + cacheWriteInputPrice: string | null; + cacheWriteInputPrice1h: string | null; imageInputPrice: string | null; requestPrice: string | null; contextSize: number | null; @@ -8684,6 +8698,8 @@ export interface operations { inputPrice: string | null; outputPrice: string | null; cachedInputPrice: string | null; + cacheWriteInputPrice: string | null; + cacheWriteInputPrice1h: string | null; imageInputPrice: string | null; imageOutputPrice: string | null; imageInputTokensByResolution: { diff --git a/apps/ui/src/lib/fetch-models.ts b/apps/ui/src/lib/fetch-models.ts index dd5f933bdc..27503953ee 100644 --- a/apps/ui/src/lib/fetch-models.ts +++ b/apps/ui/src/lib/fetch-models.ts @@ -25,6 +25,8 @@ export interface ApiModelProviderMapping { inputPrice: string | null; outputPrice: string | null; cachedInputPrice: string | null; + cacheWriteInputPrice: string | null; + cacheWriteInputPrice1h: string | null; imageInputPrice: string | null; imageOutputPrice: string | null; imageInputTokensByResolution: Record | null; diff --git a/apps/ui/src/types/activity.ts b/apps/ui/src/types/activity.ts index 2e91f57cdb..aefee18b3d 100644 --- a/apps/ui/src/types/activity.ts +++ b/apps/ui/src/types/activity.ts @@ -16,6 +16,7 @@ export interface DailyActivity { inputTokens: number; outputTokens: number; cachedTokens: number; + cacheWriteTokens: number; totalTokens: number; cost: number; outputCost: number; @@ -26,6 +27,7 @@ export interface DailyActivity { imageOutputCost: number; videoOutputCost: number; cachedInputCost: number; + cacheWriteInputCost: number; errorCount: number; errorRate: number; cacheCount: number; @@ -52,6 +54,7 @@ export type ActivitT = inputTokens: number; outputTokens: number; cachedTokens: number; + cacheWriteTokens: number; totalTokens: number; cost: number; inputCost: number; @@ -62,6 +65,7 @@ export type ActivitT = imageOutputCost: number; videoOutputCost: number; cachedInputCost: number; + cacheWriteInputCost: number; errorCount: number; errorRate: number; cacheCount: number; diff --git a/apps/worker/src/services/project-stats-aggregator.ts b/apps/worker/src/services/project-stats-aggregator.ts index 531025aed1..4fb706e2a5 100644 --- a/apps/worker/src/services/project-stats-aggregator.ts +++ b/apps/worker/src/services/project-stats-aggregator.ts @@ -125,6 +125,10 @@ function getCommonAggregationFields() { sql`coalesce(sum(cast(${log.cachedTokens} as numeric)), 0)`.as( "cachedTokens", ), + cacheWriteTokens: + sql`coalesce(sum(cast(${log.cacheWriteTokens} as numeric)), 0)`.as( + "cacheWriteTokens", + ), // Costs cost: sql`coalesce(sum(${log.cost}), 0)`.as("cost"), inputCost: sql`coalesce(sum(${log.inputCost}), 0)`.as("inputCost"), @@ -160,6 +164,10 @@ function getCommonAggregationFields() { cachedInputCost: sql`coalesce(sum(${log.cachedInputCost}), 0)`.as( "cachedInputCost", ), + cacheWriteInputCost: + sql`coalesce(sum(${log.cacheWriteInputCost}), 0)`.as( + "cacheWriteInputCost", + ), // Per-mode breakdowns creditsRequestCount: sql`sum(case when ${log.usedMode} = 'credits' then 1 else 0 end)::int`.as( diff --git a/apps/worker/src/services/sync-models.ts b/apps/worker/src/services/sync-models.ts index b8ed44ed98..b620b06901 100644 --- a/apps/worker/src/services/sync-models.ts +++ b/apps/worker/src/services/sync-models.ts @@ -138,6 +138,16 @@ export async function syncProvidersAndModels() { mapping.cachedInputPrice !== undefined ? mapping.cachedInputPrice.toString() : null, + cacheWriteInputPrice: + "cacheWriteInputPrice" in mapping && + mapping.cacheWriteInputPrice !== undefined + ? mapping.cacheWriteInputPrice.toString() + : null, + cacheWriteInputPrice1h: + "cacheWriteInputPrice1h" in mapping && + mapping.cacheWriteInputPrice1h !== undefined + ? mapping.cacheWriteInputPrice1h.toString() + : null, imageInputPrice: "imageInputPrice" in mapping && mapping.imageInputPrice !== undefined @@ -223,6 +233,16 @@ export async function syncProvidersAndModels() { mapping.cachedInputPrice !== undefined ? mapping.cachedInputPrice.toString() : undefined, + cacheWriteInputPrice: + "cacheWriteInputPrice" in mapping && + mapping.cacheWriteInputPrice !== undefined + ? mapping.cacheWriteInputPrice.toString() + : undefined, + cacheWriteInputPrice1h: + "cacheWriteInputPrice1h" in mapping && + mapping.cacheWriteInputPrice1h !== undefined + ? mapping.cacheWriteInputPrice1h.toString() + : undefined, imageInputPrice: "imageInputPrice" in mapping && mapping.imageInputPrice !== undefined diff --git a/apps/worker/src/worker.ts b/apps/worker/src/worker.ts index f56d228d88..d11777b744 100644 --- a/apps/worker/src/worker.ts +++ b/apps/worker/src/worker.ts @@ -187,9 +187,11 @@ const schema = z.object({ total_tokens: z.string().nullable(), reasoning_tokens: z.string().nullable(), cached_tokens: z.string().nullable(), + cache_write_tokens: z.string().nullable(), input_cost: z.number().nullable(), output_cost: z.number().nullable(), cached_input_cost: z.number().nullable(), + cache_write_input_cost: z.number().nullable(), estimated_cost: z.boolean().nullable(), error_details: z .object({ @@ -706,9 +708,11 @@ export async function batchProcessLogs(): Promise { total_tokens: log.totalTokens, reasoning_tokens: log.reasoningTokens, cached_tokens: log.cachedTokens, + cache_write_tokens: log.cacheWriteTokens, input_cost: log.inputCost, output_cost: log.outputCost, cached_input_cost: log.cachedInputCost, + cache_write_input_cost: log.cacheWriteInputCost, estimated_cost: log.estimatedCost, error_details: log.errorDetails, trace_id: log.traceId, @@ -752,6 +756,7 @@ export async function batchProcessLogs(): Promise { inputCost: row.input_cost, outputCost: row.output_cost, cachedInputCost: row.cached_input_cost, + cacheWriteInputCost: row.cache_write_input_cost, estimatedCost: row.estimated_cost, error: !!row.hasError, cached: row.cached, @@ -770,6 +775,7 @@ export async function batchProcessLogs(): Promise { totalTokens: row.total_tokens, reasoningTokens: row.reasoning_tokens, cachedTokens: row.cached_tokens, + cacheWriteTokens: row.cache_write_tokens, errorDetails: row.error_details, traceId: row.trace_id, unifiedFinishReason: row.unified_finish_reason, diff --git a/ee/admin/src/app/organizations/[orgId]/org-metrics.tsx b/ee/admin/src/app/organizations/[orgId]/org-metrics.tsx index 6c40974782..6151c60a5e 100644 --- a/ee/admin/src/app/organizations/[orgId]/org-metrics.tsx +++ b/ee/admin/src/app/organizations/[orgId]/org-metrics.tsx @@ -298,6 +298,13 @@ export function OrgMetricsSection({ orgId }: { orgId: string }) { icon={} accent="purple" /> + } + accent="purple" + /> } accent="purple" /> + } + accent="purple" + /> = []; // Detect whether any text block in the incoming system messages has diff --git a/packages/db/migrations/1778083846_early_excalibur.sql b/packages/db/migrations/1778083846_early_excalibur.sql new file mode 100644 index 0000000000..5ad57d04c4 --- /dev/null +++ b/packages/db/migrations/1778083846_early_excalibur.sql @@ -0,0 +1,12 @@ +ALTER TABLE "api_key_hourly_model_stats" ADD COLUMN "cache_write_tokens" numeric DEFAULT '0' NOT NULL;--> statement-breakpoint +ALTER TABLE "api_key_hourly_model_stats" ADD COLUMN "cache_write_input_cost" real DEFAULT 0 NOT NULL;--> statement-breakpoint +ALTER TABLE "api_key_hourly_stats" ADD COLUMN "cache_write_tokens" numeric DEFAULT '0' NOT NULL;--> statement-breakpoint +ALTER TABLE "api_key_hourly_stats" ADD COLUMN "cache_write_input_cost" real DEFAULT 0 NOT NULL;--> statement-breakpoint +ALTER TABLE "log" ADD COLUMN "cache_write_tokens" numeric;--> statement-breakpoint +ALTER TABLE "log" ADD COLUMN "cache_write_input_cost" real;--> statement-breakpoint +ALTER TABLE "model_provider_mapping" ADD COLUMN "cache_write_input_price" numeric;--> statement-breakpoint +ALTER TABLE "model_provider_mapping" ADD COLUMN "cache_write_input_price1h" numeric;--> statement-breakpoint +ALTER TABLE "project_hourly_model_stats" ADD COLUMN "cache_write_tokens" numeric DEFAULT '0' NOT NULL;--> statement-breakpoint +ALTER TABLE "project_hourly_model_stats" ADD COLUMN "cache_write_input_cost" real DEFAULT 0 NOT NULL;--> statement-breakpoint +ALTER TABLE "project_hourly_stats" ADD COLUMN "cache_write_tokens" numeric DEFAULT '0' NOT NULL;--> statement-breakpoint +ALTER TABLE "project_hourly_stats" ADD COLUMN "cache_write_input_cost" real DEFAULT 0 NOT NULL; \ No newline at end of file diff --git a/packages/db/migrations/meta/1778083846_snapshot.json b/packages/db/migrations/meta/1778083846_snapshot.json new file mode 100644 index 0000000000..edd5672900 --- /dev/null +++ b/packages/db/migrations/meta/1778083846_snapshot.json @@ -0,0 +1,14203 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "efe567e7-e675-497d-9405-474aacdf5237", + "prevId": "b1c22dd3-3921-4f6b-a36c-a6fbe78e5fba", + "ddl": [ + { + "isRlsEnabled": false, + "name": "account", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "api_key", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "api_key_hourly_model_stats", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "api_key_hourly_stats", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "api_key_iam_rule", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "audit_log", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "chat", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "chat_support_conversation", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "chat_support_message", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "chat_support_read_status", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "discount", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "enterprise_contact_submission", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "follow_up_email", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "guardrail_config", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "guardrail_rule", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "guardrail_violation", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "installation", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "lock", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "log", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "message", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "model", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "model_history", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "model_provider_mapping", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "model_provider_mapping_history", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "organization", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "organization_action", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "passkey", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "payment_failure", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "payment_method", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "project", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "project_hourly_model_stats", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "project_hourly_stats", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "provider", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "provider_key", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "rate_limit", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "referral", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "session", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "transaction", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "user", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "user_organization", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "verification", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "video_job", + "entityType": "tables", + "schema": "public" + }, + { + "isRlsEnabled": false, + "name": "webhook_delivery_log", + "entityType": "tables", + "schema": "public" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "account_id", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "provider_id", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_id", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "access_token", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "refresh_token", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id_token", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "access_token_expires_at", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "refresh_token_expires_at", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "password", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "account" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "token", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "description", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "'active'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "usage_limit", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "usage", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "period_usage_limit", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "period_usage_duration_value", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "period_usage_duration_unit", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "current_period_usage", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_period_started_at", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "project_id", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "created_by", + "entityType": "columns", + "schema": "public", + "table": "api_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "api_key_id", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "project_id", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "hour_timestamp", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_model", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_provider", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "request_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "error_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "streamed_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "non_streamed_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "completed_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "length_limit_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "content_filter_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "tool_calls_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "canceled_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "unknown_finish_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "client_error_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "gateway_error_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "upstream_error_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "input_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "output_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "reasoning_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_write_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "input_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "output_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "request_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "discount_savings", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "image_input_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "image_output_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "video_output_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_input_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_write_input_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_request_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_request_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "api_key_id", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "project_id", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "hour_timestamp", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "request_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "error_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "streamed_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "non_streamed_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "completed_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "length_limit_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "content_filter_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "tool_calls_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "canceled_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "unknown_finish_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "client_error_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "gateway_error_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "upstream_error_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "input_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "output_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "reasoning_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_write_tokens", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "input_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "output_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "request_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "discount_savings", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "image_input_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "image_output_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "video_output_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_input_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_write_input_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_request_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_request_count", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "api_key_id", + "entityType": "columns", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rule_type", + "entityType": "columns", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "type": "json", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rule_value", + "entityType": "columns", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'active'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "audit_log" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "audit_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "audit_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_id", + "entityType": "columns", + "schema": "public", + "table": "audit_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action", + "entityType": "columns", + "schema": "public", + "table": "audit_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resource_type", + "entityType": "columns", + "schema": "public", + "table": "audit_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resource_id", + "entityType": "columns", + "schema": "public", + "table": "audit_log" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "metadata", + "entityType": "columns", + "schema": "public", + "table": "audit_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "chat" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "chat" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "chat" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "title", + "entityType": "columns", + "schema": "public", + "table": "chat" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_id", + "entityType": "columns", + "schema": "public", + "table": "chat" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "model", + "entityType": "columns", + "schema": "public", + "table": "chat" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "'active'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "chat" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "web_search", + "entityType": "columns", + "schema": "public", + "table": "chat" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "name", + "entityType": "columns", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "email", + "entityType": "columns", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ip_address", + "entityType": "columns", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_agent", + "entityType": "columns", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "message_count", + "entityType": "columns", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "escalated_at", + "entityType": "columns", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "archived_at", + "entityType": "columns", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "chat_support_message" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "chat_support_message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conversation_id", + "entityType": "columns", + "schema": "public", + "table": "chat_support_message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "role", + "entityType": "columns", + "schema": "public", + "table": "chat_support_message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "content", + "entityType": "columns", + "schema": "public", + "table": "chat_support_message" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "sequence", + "entityType": "columns", + "schema": "public", + "table": "chat_support_message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "chat_support_read_status" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conversation_id", + "entityType": "columns", + "schema": "public", + "table": "chat_support_read_status" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "admin_user_id", + "entityType": "columns", + "schema": "public", + "table": "chat_support_read_status" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "last_read_message_count", + "entityType": "columns", + "schema": "public", + "table": "chat_support_read_status" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "read_at", + "entityType": "columns", + "schema": "public", + "table": "chat_support_read_status" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "discount" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "discount" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "discount" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "discount" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "provider", + "entityType": "columns", + "schema": "public", + "table": "discount" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "model", + "entityType": "columns", + "schema": "public", + "table": "discount" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "discount_percent", + "entityType": "columns", + "schema": "public", + "table": "discount" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "public", + "table": "discount" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "public", + "table": "discount" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "name", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "email", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "country", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "size", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "message", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "honeypot", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "client_timestamp_ms", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ip_address", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_agent", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'pending'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "spam_filter_status", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rejection_reason", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "archived_at", + "entityType": "columns", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "follow_up_email" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "follow_up_email" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "follow_up_email" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "email_type", + "entityType": "columns", + "schema": "public", + "table": "follow_up_email" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "sent_to", + "entityType": "columns", + "schema": "public", + "table": "follow_up_email" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "guardrail_config" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "guardrail_config" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "true", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "enabled", + "entityType": "columns", + "schema": "public", + "table": "guardrail_config" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "type": "unknown", + "value": "'{\"prompt_injection\":{\"enabled\":true,\"action\":\"block\"},\"jailbreak\":{\"enabled\":true,\"action\":\"block\"},\"pii_detection\":{\"enabled\":true,\"action\":\"redact\"},\"secrets\":{\"enabled\":true,\"action\":\"block\"},\"file_types\":{\"enabled\":true,\"action\":\"block\"},\"document_leakage\":{\"enabled\":false,\"action\":\"warn\"}}'" + }, + "generated": null, + "identity": null, + "name": "system_rules", + "entityType": "columns", + "schema": "public", + "table": "guardrail_config" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "10", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "max_file_size_mb", + "entityType": "columns", + "schema": "public", + "table": "guardrail_config" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 1, + "default": { + "value": "'{image/jpeg,image/png,image/gif,image/webp}'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "allowed_file_types", + "entityType": "columns", + "schema": "public", + "table": "guardrail_config" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "'redact'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "pii_action", + "entityType": "columns", + "schema": "public", + "table": "guardrail_config" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "guardrail_config" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "guardrail_config" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "guardrail_rule" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "guardrail_rule" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "name", + "entityType": "columns", + "schema": "public", + "table": "guardrail_rule" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "type", + "entityType": "columns", + "schema": "public", + "table": "guardrail_rule" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "config", + "entityType": "columns", + "schema": "public", + "table": "guardrail_rule" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "100", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "priority", + "entityType": "columns", + "schema": "public", + "table": "guardrail_rule" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "true", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "enabled", + "entityType": "columns", + "schema": "public", + "table": "guardrail_rule" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'block'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "action", + "entityType": "columns", + "schema": "public", + "table": "guardrail_rule" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "guardrail_rule" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "guardrail_rule" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "log_id", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rule_id", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rule_name", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "category", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_taken", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "matched_pattern", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "matched_content", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "content_hash", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "api_key_id", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "model", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "guardrail_violation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "installation" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "installation" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "installation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "uuid", + "entityType": "columns", + "schema": "public", + "table": "installation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "type", + "entityType": "columns", + "schema": "public", + "table": "installation" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "lock" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "lock" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "lock" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "key", + "entityType": "columns", + "schema": "public", + "table": "lock" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_id", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "project_id", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "api_key_id", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "duration", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "time_to_first_token", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "time_to_first_reasoning_token", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_model", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_provider", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_model", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_model_mapping", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_provider", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "response_size", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "content", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reasoning_content", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tools", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tool_choice", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tool_results", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "finish_reason", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unified_finish_reason", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "prompt_tokens", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "completion_tokens", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "total_tokens", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reasoning_tokens", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "cached_tokens", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "cache_write_tokens", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "messages", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "temperature", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "max_tokens", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "top_p", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "frequency_penalty", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "presence_penalty", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reasoning_effort", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reasoning_max_tokens", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effort", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "response_format", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "has_error", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "error_details", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "input_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "output_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "cached_input_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "cache_write_input_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "web_search_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "image_input_tokens", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "image_output_tokens", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "image_input_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "image_output_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "video_output_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "video_download_count", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "last_video_downloaded_at", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "estimated_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "discount", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "pricing_tier", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "canceled", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "streamed", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mode", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_mode", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "custom_headers", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "routing_metadata", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "processed_at", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "raw_request", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "raw_response", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "upstream_request", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "upstream_response", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "trace_id", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "data_retention_cleaned_up", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "params", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_agent", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "plugins", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "plugin_results", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "retried", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retried_by_log_id", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "internal_content_filter", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "gateway_content_filter_response", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "responses_api_id", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "responses_api_data", + "entityType": "columns", + "schema": "public", + "table": "log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "message" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "message" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "chat_id", + "entityType": "columns", + "schema": "public", + "table": "message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "role", + "entityType": "columns", + "schema": "public", + "table": "message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "content", + "entityType": "columns", + "schema": "public", + "table": "message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "images", + "entityType": "columns", + "schema": "public", + "table": "message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reasoning", + "entityType": "columns", + "schema": "public", + "table": "message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tools", + "entityType": "columns", + "schema": "public", + "table": "message" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "sequence", + "entityType": "columns", + "schema": "public", + "table": "message" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'(empty)'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "name", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "json", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "type": "unknown", + "value": "'[]'" + }, + "generated": null, + "identity": null, + "name": "aliases", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'(empty)'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "description", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "family", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "free", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "json", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "type": "unknown", + "value": "'[\"text\"]'" + }, + "generated": null, + "identity": null, + "name": "output", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "image_input_required", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'stable'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "stability", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'active'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "logs_count", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "errors_count", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "client_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "gateway_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "upstream_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_count", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "avg_time_to_first_token", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "avg_time_to_first_reasoning_token", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stats_updated_at", + "entityType": "columns", + "schema": "public", + "table": "model" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "model_id", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "minute_timestamp", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "logs_count", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "client_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "gateway_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "upstream_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_count", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_input_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_output_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_reasoning_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_cached_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_duration", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_time_to_first_token", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_time_to_first_reasoning_token", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_cost", + "entityType": "columns", + "schema": "public", + "table": "model_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "model_id", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "provider_id", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "model_name", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "region", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "input_price", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "output_price", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "cached_input_price", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "cache_write_input_price", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "cache_write_input_price1h", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "image_input_price", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_price", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "context_size", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "max_output", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "streaming", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "vision", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reasoning", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "reasoning_max_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reasoning_output", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tools", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "json_output", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "json_output_schema", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "web_search", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "web_search_price", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "discount", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'stable'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "stability", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "json", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "supported_parameters", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "test", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "deprecated_at", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "deactivated_at", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'active'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "logs_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "client_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "gateway_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "upstream_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "avg_time_to_first_token", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "avg_time_to_first_reasoning_token", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "routing_uptime", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "routing_latency", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "routing_throughput", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "routing_total_requests", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stats_updated_at", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "model_id", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "provider_id", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "model_provider_mapping_id", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "minute_timestamp", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "logs_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "client_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "gateway_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "upstream_errors_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_count", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_input_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_output_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_reasoning_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_cached_tokens", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_duration", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_time_to_first_token", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_time_to_first_reasoning_token", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_cost", + "entityType": "columns", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "name", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "billing_email", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "billing_company", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "billing_address", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "billing_tax_id", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "billing_notes", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stripe_customer_id", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stripe_subscription_id", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "auto_top_up_enabled", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "'10'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "auto_top_up_threshold", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "'10'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "auto_top_up_amount", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'free'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "plan", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "plan_expires_at", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "subscription_cancelled", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "trial_start_date", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "trial_end_date", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "is_trial_active", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'none'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "retention_level", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "'active'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "referral_earnings", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "payment_failure_count", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "last_payment_failure_at", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "payment_failure_started_at", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "is_personal", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'none'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "dev_plan", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "dev_plan_credits_used", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "dev_plan_credits_limit", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "dev_plan_billing_cycle_start", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "dev_plan_stripe_subscription_id", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "dev_plan_cancelled", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "dev_plan_expires_at", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'monthly'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "dev_plan_cycle", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "dev_plan_allow_all_models", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "last_top_up_amount", + "entityType": "columns", + "schema": "public", + "table": "organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "organization_action" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "organization_action" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "organization_action" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "organization_action" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "type", + "entityType": "columns", + "schema": "public", + "table": "organization_action" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "amount", + "entityType": "columns", + "schema": "public", + "table": "organization_action" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "description", + "entityType": "columns", + "schema": "public", + "table": "organization_action" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "name", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "public_key", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_id", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "credential_id", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "counter", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "device_type", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backed_up", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transports", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "aaguid", + "entityType": "columns", + "schema": "public", + "table": "passkey" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_email", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "amount", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'USD'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "currency", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decline_code", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "error_code", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "failure_message", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stripe_payment_intent_id", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source", + "entityType": "columns", + "schema": "public", + "table": "payment_failure" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "payment_method" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "payment_method" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "payment_method" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stripe_payment_method_id", + "entityType": "columns", + "schema": "public", + "table": "payment_method" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "payment_method" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "type", + "entityType": "columns", + "schema": "public", + "table": "payment_method" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "is_default", + "entityType": "columns", + "schema": "public", + "table": "payment_method" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "project" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "project" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "project" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "name", + "entityType": "columns", + "schema": "public", + "table": "project" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "project" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "caching_enabled", + "entityType": "columns", + "schema": "public", + "table": "project" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "60", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_duration_seconds", + "entityType": "columns", + "schema": "public", + "table": "project" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'hybrid'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "mode", + "entityType": "columns", + "schema": "public", + "table": "project" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "'active'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "project" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "project_id", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "hour_timestamp", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_model", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_provider", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "request_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "error_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "streamed_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "non_streamed_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "completed_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "length_limit_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "content_filter_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "tool_calls_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "canceled_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "unknown_finish_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "client_error_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "gateway_error_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "upstream_error_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "input_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "output_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "reasoning_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_write_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "input_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "output_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "request_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "discount_savings", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "image_input_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "image_output_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "video_output_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_input_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_write_input_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_request_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_request_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "project_id", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "hour_timestamp", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "request_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "error_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "streamed_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "non_streamed_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "completed_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "length_limit_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "content_filter_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "tool_calls_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "canceled_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "unknown_finish_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "client_error_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "gateway_error_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "upstream_error_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "input_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "output_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "total_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "reasoning_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'0'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_write_tokens", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "input_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "output_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "request_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "discount_savings", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "image_input_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "image_output_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "video_output_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_input_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cache_write_input_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_request_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_request_count", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "credits_data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "real", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "api_keys_data_storage_cost", + "entityType": "columns", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "name", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "description", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "streaming", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "cancellation", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "color", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "website", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "announcement", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'active'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "logs_count", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "errors_count", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "client_errors_count", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "gateway_errors_count", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "upstream_errors_count", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "cached_count", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "avg_time_to_first_token", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "real", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "avg_time_to_first_reasoning_token", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stats_updated_at", + "entityType": "columns", + "schema": "public", + "table": "provider" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "provider_key" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "provider_key" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "provider_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "token", + "entityType": "columns", + "schema": "public", + "table": "provider_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "provider", + "entityType": "columns", + "schema": "public", + "table": "provider_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "name", + "entityType": "columns", + "schema": "public", + "table": "provider_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "base_url", + "entityType": "columns", + "schema": "public", + "table": "provider_key" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "options", + "entityType": "columns", + "schema": "public", + "table": "provider_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": { + "value": "'active'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "provider_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "provider_key" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "rate_limit" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "rate_limit" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "rate_limit" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "rate_limit" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "provider", + "entityType": "columns", + "schema": "public", + "table": "rate_limit" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "model", + "entityType": "columns", + "schema": "public", + "table": "rate_limit" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "max_rpm", + "entityType": "columns", + "schema": "public", + "table": "rate_limit" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "max_rpd", + "entityType": "columns", + "schema": "public", + "table": "rate_limit" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "public", + "table": "rate_limit" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "referral" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "referral" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "referral" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "referrer_organization_id", + "entityType": "columns", + "schema": "public", + "table": "referral" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "referred_organization_id", + "entityType": "columns", + "schema": "public", + "table": "referral" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "session" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "public", + "table": "session" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "token", + "entityType": "columns", + "schema": "public", + "table": "session" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "session" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "session" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ip_address", + "entityType": "columns", + "schema": "public", + "table": "session" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_agent", + "entityType": "columns", + "schema": "public", + "table": "session" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_id", + "entityType": "columns", + "schema": "public", + "table": "session" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "type", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "amount", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "numeric", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "credit_amount", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'USD'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "currency", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'completed'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stripe_payment_intent_id", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stripe_invoice_id", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "description", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "related_transaction_id", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "refund_reason", + "entityType": "columns", + "schema": "public", + "table": "transaction" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "user" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "user" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "user" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "name", + "entityType": "columns", + "schema": "public", + "table": "user" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "email", + "entityType": "columns", + "schema": "public", + "table": "user" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "email_verified", + "entityType": "columns", + "schema": "public", + "table": "user" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "image", + "entityType": "columns", + "schema": "public", + "table": "user" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "onboarding_completed", + "entityType": "columns", + "schema": "public", + "table": "user" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "false", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "newsletter_subscribed", + "entityType": "columns", + "schema": "public", + "table": "user" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'active'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "user" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "user_organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "user_organization" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "user_organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "user_id", + "entityType": "columns", + "schema": "public", + "table": "user_organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "user_organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'owner'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "role", + "entityType": "columns", + "schema": "public", + "table": "user_organization" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "verification" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier", + "entityType": "columns", + "schema": "public", + "table": "verification" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "value", + "entityType": "columns", + "schema": "public", + "table": "verification" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "public", + "table": "verification" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "verification" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "verification" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_id", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "organization_id", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "project_id", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "api_key_id", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mode", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_mode", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "model", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_provider", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_provider", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "used_model", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "provider_config_index", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "upstream_id", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "prompt", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'queued'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "progress", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "error", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "content_url", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storage_provider", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storage_bucket", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storage_object_path", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storage_uri", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storage_expires_at", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "content_type", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "completed_at", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "last_polled_at", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "next_poll_at", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "0", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "poll_attempt_count", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "callback_url", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "callback_secret", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'none'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "callback_status", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "callback_event_id", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "callback_event_type", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "callback_delivered_at", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "result_logged_at", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "routing_metadata", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "upstream_create_response", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "upstream_status_response", + "entityType": "columns", + "schema": "public", + "table": "video_job" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "id", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "video_job_id", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "event_id", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "event_type", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "target_url", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "1", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "attempt", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "'pending'", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "last_tried_at", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": { + "value": "now()", + "type": "unknown" + }, + "generated": null, + "identity": null, + "name": "next_retry_at", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "timestamp", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "delivered_at", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_headers", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_body", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "response_status", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "response_body", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "error", + "entityType": "columns", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "user_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "account_user_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "account" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "project_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_project_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "created_by", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_created_by_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "api_key_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_hourly_model_stats_api_key_id_hour_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "project_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_hourly_model_stats_project_id_hour_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_hourly_model_stats_hour_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "api_key_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_hourly_stats_api_key_id_hour_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "project_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_hourly_stats_project_id_hour_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_hourly_stats_hour_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "api_key_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_iam_rule_api_key_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "rule_type", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_iam_rule_rule_type_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "api_key_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "api_key_iam_rule_api_key_id_status_idx", + "entityType": "indexes", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "audit_log_organization_id_created_at_idx", + "entityType": "indexes", + "schema": "public", + "table": "audit_log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "user_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "audit_log_user_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "audit_log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "action", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "audit_log_action_idx", + "entityType": "indexes", + "schema": "public", + "table": "audit_log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "resource_type", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "audit_log_resource_type_idx", + "entityType": "indexes", + "schema": "public", + "table": "audit_log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "user_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "chat_user_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "chat" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "chat_support_conversation_created_at_idx", + "entityType": "indexes", + "schema": "public", + "table": "chat_support_conversation" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "conversation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "chat_support_message_conversation_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "chat_support_message" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "conversation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "admin_user_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "chat_support_read_status_conv_admin_idx", + "entityType": "indexes", + "schema": "public", + "table": "chat_support_read_status" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "discount_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "discount" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "provider", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "discount_provider_idx", + "entityType": "indexes", + "schema": "public", + "table": "discount" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "model", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "discount_model_idx", + "entityType": "indexes", + "schema": "public", + "table": "discount" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "enterprise_contact_submission_created_at_idx", + "entityType": "indexes", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "email", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "enterprise_contact_submission_email_idx", + "entityType": "indexes", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "spam_filter_status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "enterprise_contact_submission_status_idx", + "entityType": "indexes", + "schema": "public", + "table": "enterprise_contact_submission" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "follow_up_email_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "follow_up_email" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "guardrail_config_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "guardrail_config" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "guardrail_rule_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "guardrail_rule" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "priority", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "guardrail_rule_priority_idx", + "entityType": "indexes", + "schema": "public", + "table": "guardrail_rule" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "guardrail_violation_org_created_idx", + "entityType": "indexes", + "schema": "public", + "table": "guardrail_violation" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "rule_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "guardrail_violation_rule_created_idx", + "entityType": "indexes", + "schema": "public", + "table": "guardrail_violation" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "project_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "log_project_id_created_at_idx", + "entityType": "indexes", + "schema": "public", + "table": "log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "request_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "log_request_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "used_model", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "used_provider", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "log_created_at_used_model_used_provider_idx", + "entityType": "indexes", + "schema": "public", + "table": "log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "data_retention_cleaned_up = false", + "with": "", + "method": "btree", + "concurrently": false, + "name": "log_data_retention_pending_idx", + "entityType": "indexes", + "schema": "public", + "table": "log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "project_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "used_model", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "log_project_id_used_model_idx", + "entityType": "indexes", + "schema": "public", + "table": "log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "processed_at IS NULL", + "with": "", + "method": "btree", + "concurrently": false, + "name": "log_processed_at_null_idx", + "entityType": "indexes", + "schema": "public", + "table": "log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "chat_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "message_chat_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "message" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "model_status_idx", + "entityType": "indexes", + "schema": "public", + "table": "model" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "minute_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "model_history_minute_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "model_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "model_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "minute_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "model_history_model_id_minute_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "model_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "model_provider_mapping_status_idx", + "entityType": "indexes", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "minute_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "model_provider_mapping_history_minute_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "minute_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "provider_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "model_provider_mapping_history_minute_timestamp_provider_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "minute_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "model_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "model_provider_mapping_history_minute_timestamp_model_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "model_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "minute_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "model_provider_mapping_history_model_id_minute_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "provider_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "model_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "minute_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "model_provider_mapping_history_id_ts_idx", + "entityType": "indexes", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "organization_action_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "organization_action" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "user_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "passkey_user_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "passkey" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "payment_failure_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "payment_failure" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "payment_failure_created_at_idx", + "entityType": "indexes", + "schema": "public", + "table": "payment_failure" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "decline_code", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "payment_failure_decline_code_idx", + "entityType": "indexes", + "schema": "public", + "table": "payment_failure" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "payment_method_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "payment_method" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "project_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "project" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "project_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "project_hourly_model_stats_project_id_hour_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "project_hourly_model_stats_hour_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "used_model", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "project_hourly_model_stats_used_model_hour_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "used_provider", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "used_model", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "project_hourly_model_stats_p_m_time_idx", + "entityType": "indexes", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "hour_timestamp", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "project_hourly_stats_hour_timestamp_idx", + "entityType": "indexes", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "provider_status_idx", + "entityType": "indexes", + "schema": "public", + "table": "provider" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "provider_key_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "provider_key" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "coalesce(\"organization_id\", '__global__')", + "isExpression": true, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "coalesce(\"provider\", '__all_providers__')", + "isExpression": true, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "coalesce(\"model\", '__all_models__')", + "isExpression": true, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "rate_limit_org_provider_model_unique", + "entityType": "indexes", + "schema": "public", + "table": "rate_limit" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "rate_limit_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "rate_limit" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "provider", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "rate_limit_provider_idx", + "entityType": "indexes", + "schema": "public", + "table": "rate_limit" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "model", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "rate_limit_model_idx", + "entityType": "indexes", + "schema": "public", + "table": "rate_limit" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "referrer_organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "referral_referrer_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "referral" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "referred_organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "referral_referred_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "referral" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "user_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "session_user_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "session" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "transaction_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "transaction" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "user_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "user_organization_user_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "user_organization" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "organization_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "user_organization_organization_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "user_organization" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "project_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "created_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "video_job_project_id_created_at_idx", + "entityType": "indexes", + "schema": "public", + "table": "video_job" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "next_poll_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "video_job_status_next_poll_at_idx", + "entityType": "indexes", + "schema": "public", + "table": "video_job" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "upstream_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "video_job_upstream_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "video_job" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "callback_status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "video_job_callback_status_idx", + "entityType": "indexes", + "schema": "public", + "table": "video_job" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "video_job_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "webhook_delivery_log_video_job_id_idx", + "entityType": "indexes", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "next_retry_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "webhook_delivery_log_status_next_retry_at_idx", + "entityType": "indexes", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "nameExplicit": false, + "columns": [ + "user_id" + ], + "schemaTo": "public", + "tableTo": "user", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "account_user_id_user_id_fk", + "entityType": "fks", + "schema": "public", + "table": "account" + }, + { + "nameExplicit": false, + "columns": [ + "project_id" + ], + "schemaTo": "public", + "tableTo": "project", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "api_key_project_id_project_id_fk", + "entityType": "fks", + "schema": "public", + "table": "api_key" + }, + { + "nameExplicit": false, + "columns": [ + "created_by" + ], + "schemaTo": "public", + "tableTo": "user", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "api_key_created_by_user_id_fk", + "entityType": "fks", + "schema": "public", + "table": "api_key" + }, + { + "nameExplicit": false, + "columns": [ + "api_key_id" + ], + "schemaTo": "public", + "tableTo": "api_key", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "api_key_iam_rule_api_key_id_api_key_id_fk", + "entityType": "fks", + "schema": "public", + "table": "api_key_iam_rule" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "audit_log_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "audit_log" + }, + { + "nameExplicit": false, + "columns": [ + "user_id" + ], + "schemaTo": "public", + "tableTo": "user", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "audit_log_user_id_user_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "audit_log" + }, + { + "nameExplicit": false, + "columns": [ + "user_id" + ], + "schemaTo": "public", + "tableTo": "user", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "chat_user_id_user_id_fk", + "entityType": "fks", + "schema": "public", + "table": "chat" + }, + { + "nameExplicit": false, + "columns": [ + "conversation_id" + ], + "schemaTo": "public", + "tableTo": "chat_support_conversation", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "chat_support_message_Wd0B6G0H0z05_fkey", + "entityType": "fks", + "schema": "public", + "table": "chat_support_message" + }, + { + "nameExplicit": false, + "columns": [ + "conversation_id" + ], + "schemaTo": "public", + "tableTo": "chat_support_conversation", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "chat_support_read_status_oDVimXRR0BL9_fkey", + "entityType": "fks", + "schema": "public", + "table": "chat_support_read_status" + }, + { + "nameExplicit": false, + "columns": [ + "admin_user_id" + ], + "schemaTo": "public", + "tableTo": "user", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "chat_support_read_status_admin_user_id_user_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "chat_support_read_status" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "discount_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "discount" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "follow_up_email_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "follow_up_email" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "guardrail_config_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "guardrail_config" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "guardrail_rule_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "guardrail_rule" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "guardrail_violation_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "guardrail_violation" + }, + { + "nameExplicit": false, + "columns": [ + "chat_id" + ], + "schemaTo": "public", + "tableTo": "chat", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "message_chat_id_chat_id_fk", + "entityType": "fks", + "schema": "public", + "table": "message" + }, + { + "nameExplicit": false, + "columns": [ + "model_id" + ], + "schemaTo": "public", + "tableTo": "model", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "model_provider_mapping_model_id_model_id_fk", + "entityType": "fks", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "nameExplicit": false, + "columns": [ + "provider_id" + ], + "schemaTo": "public", + "tableTo": "provider", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "model_provider_mapping_provider_id_provider_id_fk", + "entityType": "fks", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "organization_action_organization_id_organization_id_fk", + "entityType": "fks", + "schema": "public", + "table": "organization_action" + }, + { + "nameExplicit": false, + "columns": [ + "user_id" + ], + "schemaTo": "public", + "tableTo": "user", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "passkey_user_id_user_id_fk", + "entityType": "fks", + "schema": "public", + "table": "passkey" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "payment_failure_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "payment_failure" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "payment_method_organization_id_organization_id_fk", + "entityType": "fks", + "schema": "public", + "table": "payment_method" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "project_organization_id_organization_id_fk", + "entityType": "fks", + "schema": "public", + "table": "project" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "provider_key_organization_id_organization_id_fk", + "entityType": "fks", + "schema": "public", + "table": "provider_key" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "rate_limit_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "rate_limit" + }, + { + "nameExplicit": false, + "columns": [ + "referrer_organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "referral_referrer_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "referral" + }, + { + "nameExplicit": false, + "columns": [ + "referred_organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "referral_referred_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "referral" + }, + { + "nameExplicit": false, + "columns": [ + "user_id" + ], + "schemaTo": "public", + "tableTo": "user", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "session_user_id_user_id_fk", + "entityType": "fks", + "schema": "public", + "table": "session" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "transaction_organization_id_organization_id_fk", + "entityType": "fks", + "schema": "public", + "table": "transaction" + }, + { + "nameExplicit": false, + "columns": [ + "user_id" + ], + "schemaTo": "public", + "tableTo": "user", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "user_organization_user_id_user_id_fk", + "entityType": "fks", + "schema": "public", + "table": "user_organization" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "user_organization_organization_id_organization_id_fk", + "entityType": "fks", + "schema": "public", + "table": "user_organization" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "schemaTo": "public", + "tableTo": "organization", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "video_job_organization_id_organization_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "video_job" + }, + { + "nameExplicit": false, + "columns": [ + "project_id" + ], + "schemaTo": "public", + "tableTo": "project", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "video_job_project_id_project_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "video_job" + }, + { + "nameExplicit": false, + "columns": [ + "api_key_id" + ], + "schemaTo": "public", + "tableTo": "api_key", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "video_job_api_key_id_api_key_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "video_job" + }, + { + "nameExplicit": false, + "columns": [ + "video_job_id" + ], + "schemaTo": "public", + "tableTo": "video_job", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "name": "webhook_delivery_log_video_job_id_video_job_id_fkey", + "entityType": "fks", + "schema": "public", + "table": "webhook_delivery_log" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "account_pkey", + "schema": "public", + "table": "account", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "api_key_pkey", + "schema": "public", + "table": "api_key", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "api_key_hourly_model_stats_pkey", + "schema": "public", + "table": "api_key_hourly_model_stats", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "api_key_hourly_stats_pkey", + "schema": "public", + "table": "api_key_hourly_stats", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "api_key_iam_rule_pkey", + "schema": "public", + "table": "api_key_iam_rule", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "audit_log_pkey", + "schema": "public", + "table": "audit_log", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "chat_pkey", + "schema": "public", + "table": "chat", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "chat_support_conversation_pkey", + "schema": "public", + "table": "chat_support_conversation", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "chat_support_message_pkey", + "schema": "public", + "table": "chat_support_message", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "chat_support_read_status_pkey", + "schema": "public", + "table": "chat_support_read_status", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "discount_pkey", + "schema": "public", + "table": "discount", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "enterprise_contact_submission_pkey", + "schema": "public", + "table": "enterprise_contact_submission", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "follow_up_email_pkey", + "schema": "public", + "table": "follow_up_email", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "guardrail_config_pkey", + "schema": "public", + "table": "guardrail_config", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "guardrail_rule_pkey", + "schema": "public", + "table": "guardrail_rule", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "guardrail_violation_pkey", + "schema": "public", + "table": "guardrail_violation", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "installation_pkey", + "schema": "public", + "table": "installation", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "lock_pkey", + "schema": "public", + "table": "lock", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "log_pkey", + "schema": "public", + "table": "log", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "message_pkey", + "schema": "public", + "table": "message", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "model_pkey", + "schema": "public", + "table": "model", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "model_history_pkey", + "schema": "public", + "table": "model_history", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "model_provider_mapping_pkey", + "schema": "public", + "table": "model_provider_mapping", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "model_provider_mapping_history_pkey", + "schema": "public", + "table": "model_provider_mapping_history", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "organization_pkey", + "schema": "public", + "table": "organization", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "organization_action_pkey", + "schema": "public", + "table": "organization_action", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "passkey_pkey", + "schema": "public", + "table": "passkey", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "payment_failure_pkey", + "schema": "public", + "table": "payment_failure", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "payment_method_pkey", + "schema": "public", + "table": "payment_method", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "project_pkey", + "schema": "public", + "table": "project", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "project_hourly_model_stats_pkey", + "schema": "public", + "table": "project_hourly_model_stats", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "project_hourly_stats_pkey", + "schema": "public", + "table": "project_hourly_stats", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "provider_pkey", + "schema": "public", + "table": "provider", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "provider_key_pkey", + "schema": "public", + "table": "provider_key", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "rate_limit_pkey", + "schema": "public", + "table": "rate_limit", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "referral_pkey", + "schema": "public", + "table": "referral", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "session_pkey", + "schema": "public", + "table": "session", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "transaction_pkey", + "schema": "public", + "table": "transaction", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "user_pkey", + "schema": "public", + "table": "user", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "user_organization_pkey", + "schema": "public", + "table": "user_organization", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "verification_pkey", + "schema": "public", + "table": "verification", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "video_job_pkey", + "schema": "public", + "table": "video_job", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "webhook_delivery_log_pkey", + "schema": "public", + "table": "webhook_delivery_log", + "entityType": "pks" + }, + { + "nameExplicit": false, + "columns": [ + "api_key_id", + "hour_timestamp", + "used_model", + "used_provider" + ], + "nullsNotDistinct": false, + "name": "api_key_hourly_model_stats_api_key_id_hour_timestamp_used_model_used_provider_unique", + "entityType": "uniques", + "schema": "public", + "table": "api_key_hourly_model_stats" + }, + { + "nameExplicit": false, + "columns": [ + "api_key_id", + "hour_timestamp" + ], + "nullsNotDistinct": false, + "name": "api_key_hourly_stats_api_key_id_hour_timestamp_unique", + "entityType": "uniques", + "schema": "public", + "table": "api_key_hourly_stats" + }, + { + "nameExplicit": true, + "columns": [ + "organization_id", + "provider", + "model" + ], + "nullsNotDistinct": false, + "name": "discount_org_provider_model_unique", + "entityType": "uniques", + "schema": "public", + "table": "discount" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id", + "email_type" + ], + "nullsNotDistinct": false, + "name": "follow_up_email_organization_id_email_type_unique", + "entityType": "uniques", + "schema": "public", + "table": "follow_up_email" + }, + { + "nameExplicit": false, + "columns": [ + "model_id", + "minute_timestamp" + ], + "nullsNotDistinct": false, + "name": "model_history_model_id_minute_timestamp_unique", + "entityType": "uniques", + "schema": "public", + "table": "model_history" + }, + { + "nameExplicit": false, + "columns": [ + "model_id", + "provider_id", + "region" + ], + "nullsNotDistinct": false, + "name": "model_provider_mapping_model_id_provider_id_region_unique", + "entityType": "uniques", + "schema": "public", + "table": "model_provider_mapping" + }, + { + "nameExplicit": false, + "columns": [ + "model_provider_mapping_id", + "minute_timestamp" + ], + "nullsNotDistinct": false, + "name": "model_provider_mapping_history_model_provider_mapping_id_minute_timestamp_unique", + "entityType": "uniques", + "schema": "public", + "table": "model_provider_mapping_history" + }, + { + "nameExplicit": true, + "columns": [ + "stripe_payment_intent_id" + ], + "nullsNotDistinct": false, + "name": "payment_failure_stripe_pi_idx", + "entityType": "uniques", + "schema": "public", + "table": "payment_failure" + }, + { + "nameExplicit": false, + "columns": [ + "project_id", + "hour_timestamp", + "used_model", + "used_provider" + ], + "nullsNotDistinct": false, + "name": "project_hourly_model_stats_project_id_hour_timestamp_used_model_used_provider_unique", + "entityType": "uniques", + "schema": "public", + "table": "project_hourly_model_stats" + }, + { + "nameExplicit": false, + "columns": [ + "project_id", + "hour_timestamp" + ], + "nullsNotDistinct": false, + "name": "project_hourly_stats_project_id_hour_timestamp_unique", + "entityType": "uniques", + "schema": "public", + "table": "project_hourly_stats" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id", + "name" + ], + "nullsNotDistinct": false, + "name": "provider_key_organization_id_name_unique", + "entityType": "uniques", + "schema": "public", + "table": "provider_key" + }, + { + "nameExplicit": false, + "columns": [ + "token" + ], + "nullsNotDistinct": false, + "name": "api_key_token_unique", + "schema": "public", + "table": "api_key", + "entityType": "uniques" + }, + { + "nameExplicit": false, + "columns": [ + "organization_id" + ], + "nullsNotDistinct": false, + "name": "guardrail_config_organization_id_key", + "schema": "public", + "table": "guardrail_config", + "entityType": "uniques" + }, + { + "nameExplicit": false, + "columns": [ + "uuid" + ], + "nullsNotDistinct": false, + "name": "installation_uuid_unique", + "schema": "public", + "table": "installation", + "entityType": "uniques" + }, + { + "nameExplicit": false, + "columns": [ + "key" + ], + "nullsNotDistinct": false, + "name": "lock_key_unique", + "schema": "public", + "table": "lock", + "entityType": "uniques" + }, + { + "nameExplicit": false, + "columns": [ + "stripe_customer_id" + ], + "nullsNotDistinct": false, + "name": "organization_stripe_customer_id_key", + "schema": "public", + "table": "organization", + "entityType": "uniques" + }, + { + "nameExplicit": false, + "columns": [ + "stripe_subscription_id" + ], + "nullsNotDistinct": false, + "name": "organization_stripe_subscription_id_key", + "schema": "public", + "table": "organization", + "entityType": "uniques" + }, + { + "nameExplicit": false, + "columns": [ + "dev_plan_stripe_subscription_id" + ], + "nullsNotDistinct": false, + "name": "organization_dev_plan_stripe_subscription_id_key", + "schema": "public", + "table": "organization", + "entityType": "uniques" + }, + { + "nameExplicit": false, + "columns": [ + "referred_organization_id" + ], + "nullsNotDistinct": false, + "name": "referral_referred_organization_id_key", + "schema": "public", + "table": "referral", + "entityType": "uniques" + }, + { + "nameExplicit": false, + "columns": [ + "token" + ], + "nullsNotDistinct": false, + "name": "session_token_unique", + "schema": "public", + "table": "session", + "entityType": "uniques" + }, + { + "nameExplicit": false, + "columns": [ + "email" + ], + "nullsNotDistinct": false, + "name": "user_email_unique", + "schema": "public", + "table": "user", + "entityType": "uniques" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/packages/db/migrations/meta/_journal.json b/packages/db/migrations/meta/_journal.json index b53be1c737..ef4a69974e 100644 --- a/packages/db/migrations/meta/_journal.json +++ b/packages/db/migrations/meta/_journal.json @@ -848,6 +848,13 @@ "when": 1777809234902, "tag": "1777809234_unique_madame_hydra", "breakpoints": true + }, + { + "idx": 121, + "version": "8", + "when": 1778083846277, + "tag": "1778083846_early_excalibur", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts index f4f8278a46..2180d62736 100644 --- a/packages/db/src/schema.ts +++ b/packages/db/src/schema.ts @@ -546,6 +546,7 @@ export const log = pgTable( totalTokens: decimal(), reasoningTokens: decimal(), cachedTokens: decimal(), + cacheWriteTokens: decimal(), messages: json(), temperature: real(), maxTokens: integer(), @@ -562,6 +563,7 @@ export const log = pgTable( inputCost: real(), outputCost: real(), cachedInputCost: real(), + cacheWriteInputCost: real(), requestCost: real(), webSearchCost: real(), imageInputTokens: decimal(), @@ -1137,6 +1139,8 @@ export const modelProviderMapping = pgTable( inputPrice: decimal(), outputPrice: decimal(), cachedInputPrice: decimal(), + cacheWriteInputPrice: decimal(), + cacheWriteInputPrice1h: decimal(), imageInputPrice: decimal(), requestPrice: decimal(), contextSize: integer(), @@ -1663,6 +1667,7 @@ export const projectHourlyStats = pgTable( totalTokens: decimal().notNull().default("0"), reasoningTokens: decimal().notNull().default("0"), cachedTokens: decimal().notNull().default("0"), + cacheWriteTokens: decimal().notNull().default("0"), // Costs cost: real().notNull().default(0), inputCost: real().notNull().default(0), @@ -1674,6 +1679,7 @@ export const projectHourlyStats = pgTable( imageOutputCost: real().notNull().default(0), videoOutputCost: real().notNull().default(0), cachedInputCost: real().notNull().default(0), + cacheWriteInputCost: real().notNull().default(0), // Per-mode breakdowns creditsRequestCount: integer().notNull().default(0), apiKeysRequestCount: integer().notNull().default(0), @@ -1727,6 +1733,7 @@ export const projectHourlyModelStats = pgTable( totalTokens: decimal().notNull().default("0"), reasoningTokens: decimal().notNull().default("0"), cachedTokens: decimal().notNull().default("0"), + cacheWriteTokens: decimal().notNull().default("0"), // Costs cost: real().notNull().default(0), inputCost: real().notNull().default(0), @@ -1738,6 +1745,7 @@ export const projectHourlyModelStats = pgTable( imageOutputCost: real().notNull().default(0), videoOutputCost: real().notNull().default(0), cachedInputCost: real().notNull().default(0), + cacheWriteInputCost: real().notNull().default(0), // Per-mode breakdowns creditsRequestCount: integer().notNull().default(0), apiKeysRequestCount: integer().notNull().default(0), @@ -1813,6 +1821,7 @@ export const apiKeyHourlyStats = pgTable( totalTokens: decimal().notNull().default("0"), reasoningTokens: decimal().notNull().default("0"), cachedTokens: decimal().notNull().default("0"), + cacheWriteTokens: decimal().notNull().default("0"), // Costs cost: real().notNull().default(0), inputCost: real().notNull().default(0), @@ -1824,6 +1833,7 @@ export const apiKeyHourlyStats = pgTable( imageOutputCost: real().notNull().default(0), videoOutputCost: real().notNull().default(0), cachedInputCost: real().notNull().default(0), + cacheWriteInputCost: real().notNull().default(0), // Per-mode breakdowns creditsRequestCount: integer().notNull().default(0), apiKeysRequestCount: integer().notNull().default(0), @@ -1888,6 +1898,7 @@ export const apiKeyHourlyModelStats = pgTable( totalTokens: decimal().notNull().default("0"), reasoningTokens: decimal().notNull().default("0"), cachedTokens: decimal().notNull().default("0"), + cacheWriteTokens: decimal().notNull().default("0"), // Costs cost: real().notNull().default(0), inputCost: real().notNull().default(0), @@ -1899,6 +1910,7 @@ export const apiKeyHourlyModelStats = pgTable( imageOutputCost: real().notNull().default(0), videoOutputCost: real().notNull().default(0), cachedInputCost: real().notNull().default(0), + cacheWriteInputCost: real().notNull().default(0), // Per-mode breakdowns creditsRequestCount: integer().notNull().default(0), apiKeysRequestCount: integer().notNull().default(0), diff --git a/packages/db/src/seed.ts b/packages/db/src/seed.ts index cc0bb0157c..814abf8358 100644 --- a/packages/db/src/seed.ts +++ b/packages/db/src/seed.ts @@ -1046,6 +1046,16 @@ function generateSeedModelProviderMappings() { p.cachedInputPrice !== undefined && p.cachedInputPrice !== null ? String(p.cachedInputPrice) : null, + cacheWriteInputPrice: + p.cacheWriteInputPrice !== undefined && + p.cacheWriteInputPrice !== null + ? String(p.cacheWriteInputPrice) + : null, + cacheWriteInputPrice1h: + p.cacheWriteInputPrice1h !== undefined && + p.cacheWriteInputPrice1h !== null + ? String(p.cacheWriteInputPrice1h) + : null, imageInputPrice: p.imageInputPrice !== undefined && p.imageInputPrice !== null ? String(p.imageInputPrice) diff --git a/packages/models/src/models.ts b/packages/models/src/models.ts index cc85e69ad6..bc32dccc98 100644 --- a/packages/models/src/models.ts +++ b/packages/models/src/models.ts @@ -45,6 +45,17 @@ export interface PricingTier { * Price per cached input token in USD for this tier */ cachedInputPrice?: number; + /** + * Price per cache write input token in USD for this tier (5-minute TTL). + * For Anthropic, this is the 1.25x base-input rate. + */ + cacheWriteInputPrice?: number; + /** + * Price per cache write input token in USD for this tier (1-hour TTL). + * For Anthropic, this is the 2x base-input rate. When unset, 1-hour writes + * fall back to `cacheWriteInputPrice` (the 5-minute rate). + */ + cacheWriteInputPrice1h?: number; } /** @@ -72,6 +83,15 @@ export interface ProviderRegion { * Price per cached input token in USD for this region */ cachedInputPrice?: number; + /** + * Price per cache write input token in USD for this region (5-minute TTL) + */ + cacheWriteInputPrice?: number; + /** + * Price per cache write input token in USD for this region (1-hour TTL). + * When unset, 1-hour writes fall back to `cacheWriteInputPrice`. + */ + cacheWriteInputPrice1h?: number; /** * Context-length based pricing tiers for this region. * When absent, falls back to the mapping-level pricingTiers. @@ -133,6 +153,17 @@ export interface ProviderModelMapping { * Price per cached input token in USD */ cachedInputPrice?: number; + /** + * Price per cache write input token in USD (5-minute TTL). + * For Anthropic, this is the 1.25x base-input rate. + */ + cacheWriteInputPrice?: number; + /** + * Price per cache write input token in USD (1-hour TTL). + * For Anthropic, this is the 2x base-input rate. When unset, 1-hour writes + * fall back to `cacheWriteInputPrice` (the 5-minute rate). + */ + cacheWriteInputPrice1h?: number; /** * Minimum number of tokens required for a segment to be cacheable. * Prompts smaller than this threshold won't be cached even with cache_control set. diff --git a/packages/models/src/models/anthropic.ts b/packages/models/src/models/anthropic.ts index 999d114c9b..a39d94358d 100644 --- a/packages/models/src/models/anthropic.ts +++ b/packages/models/src/models/anthropic.ts @@ -16,6 +16,8 @@ export const anthropicModels = [ inputPrice: 3.0 / 1e6, outputPrice: 15.0 / 1e6, cachedInputPrice: 0.3 / 1e6, + cacheWriteInputPrice: 3.75 / 1e6, + cacheWriteInputPrice1h: 6.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -66,6 +68,8 @@ export const anthropicModels = [ inputPrice: 0.8 / 1e6, outputPrice: 4.0 / 1e6, cachedInputPrice: 0.08 / 1e6, + cacheWriteInputPrice: 1.0 / 1e6, + cacheWriteInputPrice1h: 1.6 / 1e6, minCacheableTokens: 2048, requestPrice: 0, contextSize: 200000, @@ -96,6 +100,8 @@ export const anthropicModels = [ inputPrice: 3.0 / 1e6, outputPrice: 15.0 / 1e6, cachedInputPrice: 0.3 / 1e6, + cacheWriteInputPrice: 3.75 / 1e6, + cacheWriteInputPrice1h: 6.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -125,6 +131,8 @@ export const anthropicModels = [ inputPrice: 3.0 / 1e6, outputPrice: 15.0 / 1e6, cachedInputPrice: 0.3 / 1e6, + cacheWriteInputPrice: 3.75 / 1e6, + cacheWriteInputPrice1h: 6.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -195,6 +203,8 @@ export const anthropicModels = [ inputPrice: 3.0 / 1e6, outputPrice: 15.0 / 1e6, cachedInputPrice: 0.3 / 1e6, + cacheWriteInputPrice: 3.75 / 1e6, + cacheWriteInputPrice1h: 6.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -244,6 +254,8 @@ export const anthropicModels = [ inputPrice: 3.0 / 1e6, outputPrice: 15.0 / 1e6, cachedInputPrice: 0.3 / 1e6, + cacheWriteInputPrice: 3.75 / 1e6, + cacheWriteInputPrice1h: 6.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -293,6 +305,8 @@ export const anthropicModels = [ inputPrice: 3.0 / 1e6, outputPrice: 15.0 / 1e6, cachedInputPrice: 0.3 / 1e6, + cacheWriteInputPrice: 3.75 / 1e6, + cacheWriteInputPrice1h: 6.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -341,6 +355,8 @@ export const anthropicModels = [ inputPrice: 3.0 / 1e6, outputPrice: 15.0 / 1e6, cachedInputPrice: 0.3 / 1e6, + cacheWriteInputPrice: 3.75 / 1e6, + cacheWriteInputPrice1h: 6.0 / 1e6, minCacheableTokens: 2048, requestPrice: 0, contextSize: 200000, @@ -407,6 +423,8 @@ export const anthropicModels = [ inputPrice: 1.0 / 1e6, outputPrice: 5.0 / 1e6, cachedInputPrice: 0.1 / 1e6, + cacheWriteInputPrice: 1.25 / 1e6, + cacheWriteInputPrice1h: 2.0 / 1e6, minCacheableTokens: 4096, requestPrice: 0, contextSize: 200000, @@ -452,6 +470,8 @@ export const anthropicModels = [ inputPrice: 1.0 / 1e6, outputPrice: 5.0 / 1e6, cachedInputPrice: 0.1 / 1e6, + cacheWriteInputPrice: 1.25 / 1e6, + cacheWriteInputPrice1h: 2.0 / 1e6, minCacheableTokens: 4096, requestPrice: 0, contextSize: 200000, @@ -498,6 +518,8 @@ export const anthropicModels = [ inputPrice: 15.0 / 1e6, outputPrice: 75.0 / 1e6, cachedInputPrice: 1.5 / 1e6, + cacheWriteInputPrice: 18.75 / 1e6, + cacheWriteInputPrice1h: 30.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -546,6 +568,8 @@ export const anthropicModels = [ inputPrice: 15.0 / 1e6, outputPrice: 75.0 / 1e6, cachedInputPrice: 1.5 / 1e6, + cacheWriteInputPrice: 18.75 / 1e6, + cacheWriteInputPrice1h: 30.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -595,6 +619,8 @@ export const anthropicModels = [ inputPrice: 3.0 / 1e6, outputPrice: 15.0 / 1e6, cachedInputPrice: 0.3 / 1e6, + cacheWriteInputPrice: 3.75 / 1e6, + cacheWriteInputPrice1h: 6.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -621,6 +647,8 @@ export const anthropicModels = [ inputPrice: 3.0 / 1e6, outputPrice: 15.0 / 1e6, cachedInputPrice: 0.3 / 1e6, + cacheWriteInputPrice: 3.75 / 1e6, + cacheWriteInputPrice1h: 6.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -647,6 +675,8 @@ export const anthropicModels = [ inputPrice: 0.8 / 1e6, outputPrice: 4.0 / 1e6, cachedInputPrice: 0.08 / 1e6, + cacheWriteInputPrice: 1.0 / 1e6, + cacheWriteInputPrice1h: 1.6 / 1e6, minCacheableTokens: 2048, requestPrice: 0, contextSize: 200000, @@ -694,6 +724,8 @@ export const anthropicModels = [ inputPrice: 15.0 / 1e6, outputPrice: 75.0 / 1e6, cachedInputPrice: 1.5 / 1e6, + cacheWriteInputPrice: 18.75 / 1e6, + cacheWriteInputPrice1h: 30.0 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -718,6 +750,8 @@ export const anthropicModels = [ inputPrice: 0.25 / 1e6, outputPrice: 1.25 / 1e6, cachedInputPrice: 0.03 / 1e6, + cacheWriteInputPrice: 0.3 / 1e6, + cacheWriteInputPrice1h: 0.5 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -744,6 +778,8 @@ export const anthropicModels = [ inputPrice: 0.25 / 1e6, outputPrice: 1.25 / 1e6, cachedInputPrice: 0.03 / 1e6, + cacheWriteInputPrice: 0.3 / 1e6, + cacheWriteInputPrice1h: 0.5 / 1e6, minCacheableTokens: 1024, requestPrice: 0, contextSize: 200000, @@ -771,6 +807,8 @@ export const anthropicModels = [ inputPrice: 5.0 / 1e6, outputPrice: 25.0 / 1e6, cachedInputPrice: 0.5 / 1e6, + cacheWriteInputPrice: 6.25 / 1e6, + cacheWriteInputPrice1h: 10.0 / 1e6, minCacheableTokens: 4096, requestPrice: 0, contextSize: 200000, @@ -840,6 +878,8 @@ export const anthropicModels = [ inputPrice: 5.0 / 1e6, outputPrice: 25.0 / 1e6, cachedInputPrice: 0.5 / 1e6, + cacheWriteInputPrice: 6.25 / 1e6, + cacheWriteInputPrice1h: 10.0 / 1e6, minCacheableTokens: 4096, pricingTiers: [ { @@ -848,6 +888,8 @@ export const anthropicModels = [ inputPrice: 5.0 / 1e6, outputPrice: 25.0 / 1e6, cachedInputPrice: 0.5 / 1e6, + cacheWriteInputPrice: 6.25 / 1e6, + cacheWriteInputPrice1h: 10.0 / 1e6, }, { name: "Over 200K", @@ -855,6 +897,8 @@ export const anthropicModels = [ inputPrice: 10.0 / 1e6, outputPrice: 37.5 / 1e6, cachedInputPrice: 1.0 / 1e6, + cacheWriteInputPrice: 12.5 / 1e6, + cacheWriteInputPrice1h: 20.0 / 1e6, }, ], requestPrice: 0, @@ -905,6 +949,8 @@ export const anthropicModels = [ inputPrice: 5.0 / 1e6, outputPrice: 25.0 / 1e6, cachedInputPrice: 0.5 / 1e6, + cacheWriteInputPrice: 6.25 / 1e6, + cacheWriteInputPrice1h: 10.0 / 1e6, minCacheableTokens: 4096, pricingTiers: [ { @@ -913,6 +959,8 @@ export const anthropicModels = [ inputPrice: 5.0 / 1e6, outputPrice: 25.0 / 1e6, cachedInputPrice: 0.5 / 1e6, + cacheWriteInputPrice: 6.25 / 1e6, + cacheWriteInputPrice1h: 10.0 / 1e6, }, { name: "Over 200K", @@ -920,6 +968,8 @@ export const anthropicModels = [ inputPrice: 10.0 / 1e6, outputPrice: 37.5 / 1e6, cachedInputPrice: 1.0 / 1e6, + cacheWriteInputPrice: 12.5 / 1e6, + cacheWriteInputPrice1h: 20.0 / 1e6, }, ], requestPrice: 0, diff --git a/packages/models/src/types.ts b/packages/models/src/types.ts index 4b6e015f34..5996f2e28e 100644 --- a/packages/models/src/types.ts +++ b/packages/models/src/types.ts @@ -10,6 +10,7 @@ export interface TextContent { text: string; cache_control?: { type: "ephemeral"; + ttl?: "5m" | "1h"; }; } @@ -267,6 +268,7 @@ export interface AnthropicSystemContent { text: string; cache_control?: { type: "ephemeral"; + ttl?: "5m" | "1h"; }; }