diff --git a/apps/docs/content/docs/copilot/index.mdx b/apps/docs/content/docs/copilot/index.mdx index df622565c..b08ebb5a7 100644 --- a/apps/docs/content/docs/copilot/index.mdx +++ b/apps/docs/content/docs/copilot/index.mdx @@ -91,4 +91,26 @@ Copilot is your in-editor assistant that helps you build, understand, and improv >
Maximum reasoning for deep planning, debugging, and complex architectural changes.
- \ No newline at end of file + + +## Billing and Cost Calculation + +### How Costs Are Calculated + +Copilot usage is billed per token from the underlying LLM: + +- **Input tokens**: billed at the provider's base rate (**at-cost**) +- **Output tokens**: billed at **1.5×** the provider's base output rate + +```javascript +copilotCost = (inputTokens × inputPrice + outputTokens × (outputPrice × 1.5)) / 1,000,000 +``` + +| Component | Rate Applied | +|----------|----------------------| +| Input | inputPrice | +| Output | outputPrice × 1.5 | + + + Model prices are per million tokens. The calculation divides by 1,000,000 to get the actual cost. See Logging and Cost Calculation for background and examples. + diff --git a/apps/sim/app/api/copilot/chat/route.ts b/apps/sim/app/api/copilot/chat/route.ts index 31503ed1e..af18aa02c 100644 --- a/apps/sim/app/api/copilot/chat/route.ts +++ b/apps/sim/app/api/copilot/chat/route.ts @@ -372,6 +372,7 @@ export async function POST(req: NextRequest) { streamToolCalls: true, mode: mode, messageId: userMessageIdToUse, + chatId: actualChatId, ...(providerConfig ? { provider: providerConfig } : {}), ...(effectiveConversationId ? { conversationId: effectiveConversationId } : {}), ...(typeof effectiveDepth === 'number' ? { depth: effectiveDepth } : {}),