Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/docs/content/docs/platform/costs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ Current monthly pricing and allocations are:

Pro and Max are available for individuals or teams. Team subscriptions pool credits across internal seats. For example, Max for Teams with three seats has a 75,000-credit monthly allocation and a 12,000-credit weekly refresh allowance. External collaborators do not add seats, but their work in an organization-owned workspace is billed to that organization.

### Pro free trial

A new individual Pro subscriber gets a 14-day free trial. Checkout requires a card, which is charged for Pro when the trial ends unless you cancel first under **Settings → Subscription**. During the trial you get Pro features and Sim-hosted models and tools, with a fixed allowance of 2,000 credits: there is no weekly refresh, the usage limit cannot be raised, and nothing is billed past it. When the trial converts, the full Pro allowance applies.

Each account and each card can start one trial. A checkout whose card already started a trial is charged right away instead. Team plans and Max don't include a trial.

See [current pricing](https://www.sim.ai/pricing) and **Settings → Subscription** for the plan available to your account. Internal membership, external eligibility, and workspace migration are explained in [Roles and permissions](/platform/permissions#internal-and-external-membership).

### Weekly refresh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
DEFAULT_FREE_CREDITS,
MAX_CREDIT_TIER,
PRO_CREDIT_TIER,
PRO_TRIAL_DAYS,
PRO_TRIAL_USAGE_LIMIT_DOLLARS,
} from '@/lib/billing/constants'
import { SITE_URL } from '@/lib/core/utils/urls'
import { JsonLd } from '@/app/(landing)/components/json-ld'
Expand All @@ -22,6 +24,10 @@ const PRICING_FAQS = [
question: 'Is Sim free?',
answer: `Yes. The Free plan costs $0 and includes ${formatCredits(DEFAULT_FREE_CREDITS * CREDITS_PER_DOLLAR)} one-time credits, one workspace, and all ${INTEGRATION_COUNT_LABEL} integrations, with no credit card required. On Free, models and tools run on your own provider keys; Sim-hosted keys come with paid plans. Sim is also open source, so you can self-host it for free.`,
},
{
question: 'Does Sim have a free trial?',
answer: `Yes. New Pro subscribers get a ${PRO_TRIAL_DAYS}-day free trial with ${formatCredits(PRO_TRIAL_USAGE_LIMIT_DOLLARS * CREDITS_PER_DOLLAR)} credits, including Sim-hosted models and tools. A card is required at checkout and is charged for Pro when the trial ends unless you cancel first. Each account and card can start one trial.`,
},
{
question: 'How much does Sim cost?',
answer: `Pro is $${PRO_CREDIT_TIER.dollars} per user per month with ${formatCredits(PRO_CREDIT_TIER.credits)} credits a month and a weekly refresh of ${formatCredits(PRO_CREDIT_TIER.weeklyRefreshCredits)} more. Max is $${MAX_CREDIT_TIER.dollars} per user per month with ${formatCredits(MAX_CREDIT_TIER.credits)} credits a month and a weekly refresh of ${formatCredits(MAX_CREDIT_TIER.weeklyRefreshCredits)}. Annual billing costs ${ANNUAL_DISCOUNT_RATE * 100}% less for the same credits. Enterprise pricing is custom.`,
Expand Down
12 changes: 6 additions & 6 deletions apps/sim/app/api/billing/update-cost/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
toBillingContext,
} from '@/lib/billing/core/attribution'
import {
isFreeRunPayer,
isCappedRunPayer,
type MidRunUsageVerdict,
readMidRunAccountUsageVerdict,
readMidRunUsageVerdict,
Expand Down Expand Up @@ -88,7 +88,7 @@ function invalidBillingProtocolResponse(requestId: string, span: Span): NextResp
* A duplicate callback answers too: it is often a retry whose first answer was lost. The charge
* is already recorded when this runs.
*
* A free payer's spend past its limit is never billed, so its standing is read from the ledger
* A capped payer's spend past its limit is never billed, so its standing is read from the ledger
* on every callback, and a standing that cannot be read (a gate that cannot answer, or a read
* that outlasts {@link USAGE_STANDING_TIMEOUT_MS}) pauses the run. A paid payer's admission is
* cached per payer and actor (briefly once near the limit) and a refusal is always re-read, so
Expand All @@ -101,20 +101,20 @@ async function readUsageStanding(
billingAttribution: BillingAttributionSnapshot | undefined,
accountDecision: AccountBillingDecision | undefined
): Promise<BillingUsageVerdict> {
const readOptions = { uncachedForFreePayer: true }
const readOptions = { uncachedForCappedPayer: true }
const payer = billingAttribution ?? accountDecision
const readVerdict = billingAttribution
? () => readMidRunUsageVerdict(billingAttribution, 0, readOptions)
: accountDecision
? () => readMidRunAccountUsageVerdict(accountDecision, readOptions)
: null
if (!isHosted || !payer || !readVerdict) return { usageExceeded: false }
const freePayer = isFreeRunPayer(payer)
const cappedPayer = isCappedRunPayer(payer)
let verdict: MidRunUsageVerdict
try {
verdict = await withinDeadline(readVerdict, Date.now() + USAGE_STANDING_TIMEOUT_MS)
} catch {
logger.warn('Usage standing read outlasted the callback budget', { freePayer })
logger.warn('Usage standing read outlasted the callback budget', { cappedPayer })
verdict = { status: 'unknown' }
}
if (verdict.status === 'exceeded') {
Expand All @@ -129,7 +129,7 @@ async function readUsageStanding(
}
// A blocked account is refused at the run's next continuation or re-check, with
// blocked-account copy rather than the upgrade card.
if (verdict.status !== 'unknown' || !freePayer) return { usageExceeded: false }
if (verdict.status !== 'unknown' || !cappedPayer) return { usageExceeded: false }
return {
usageExceeded: true,
usageUpgrade: await resolveUsageUpgradePayload(userId, {
Expand Down
8 changes: 6 additions & 2 deletions apps/sim/app/api/copilot/api-keys/validate/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const ATTRIBUTION = {
payerSubscription: null,
}

const ACCOUNT_SUBSCRIPTION = { id: 'account-subscription' }
const ACCOUNT_SUBSCRIPTION = { id: 'account-subscription', plan: 'pro_6000', status: 'active' }
const ACCOUNT_BILLING_DECISION = {
userId: 'user-1',
billingEntity: { type: 'organization' as const, id: 'account-org' },
Expand Down Expand Up @@ -463,7 +463,11 @@ describe('POST /api/copilot/api-keys/validate billing protocols', () => {
expect(mockGetWorkspaceBillingSettings).not.toHaveBeenCalled()
expect(
JSON.parse(decodeURIComponent(res.headers.get('x-sim-billing-account-decision') ?? ''))
).toEqual({ ...ACCOUNT_BILLING_DECISION, payerSubscriptionId: ACCOUNT_SUBSCRIPTION.id })
).toEqual({
...ACCOUNT_BILLING_DECISION,
payerSubscriptionId: ACCOUNT_SUBSCRIPTION.id,
payerBillsOverage: true,
})
})

it('fails direct-v1 admission closed when its payer cannot be resolved', async () => {
Expand Down
14 changes: 8 additions & 6 deletions apps/sim/app/api/copilot/api-keys/validate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ import {
} from '@/lib/billing/core/attribution'
import { payerHasChatAccess } from '@/lib/billing/core/chat-access'
import {
isFreeRunPayer,
isCappedRunPayer,
readMidRunAccountUsageVerdict,
readMidRunUsageVerdict,
} from '@/lib/billing/core/mid-run-usage'
import { getHighestPrioritySubscription } from '@/lib/billing/core/plan'
import { isEnterprisePlan } from '@/lib/billing/core/subscription'
import { deriveBillingContext } from '@/lib/billing/core/usage-log'
import { billsOverage } from '@/lib/billing/subscriptions/utils'
import { resolveUsageUpgradePayload, type UsageUpgradePayer } from '@/lib/billing/usage-upgrade'
import { isBillingEnabled, isHosted } from '@/lib/core/config/env-flags'
import { asOrchestrationError } from '@/lib/core/orchestration/types'
Expand Down Expand Up @@ -292,6 +293,7 @@ async function checkAdmissionUsage(admission: AdmissionBillingDecision): Promise
: {}),
},
...(subscription ? { payerSubscriptionId: subscription.id } : {}),
payerBillsOverage: billsOverage(subscription),
},
}
}
Expand Down Expand Up @@ -431,7 +433,7 @@ export const POST = withRouteHandler((req: NextRequest) =>
})
// A continuation, and a worker's periodic re-check of a long run, also reads the
// original payer's spend through the cached execution usage gate. A read that fails
// refuses a free payer, whose spend past the limit is never billed, and admits a paid
// refuses a capped payer, whose spend past the limit is never billed, and admits a paid
// one: the run is already under way, and the next re-check reads again.
const verdict =
!blocked?.blocked && purpose === COPILOT_VALIDATION_PURPOSE.continuation && billing
Expand All @@ -458,14 +460,14 @@ export const POST = withRouteHandler((req: NextRequest) =>
{ status: 402 }
)
}
const unreadFreePayer =
const unreadCappedPayer =
verdict?.status === 'unknown' &&
billing !== null &&
isFreeRunPayer(billing.kind === 'attributed' ? billing.attribution : billing.decision)
if (verdict?.status === 'exceeded' || unreadFreePayer) {
isCappedRunPayer(billing.kind === 'attributed' ? billing.attribution : billing.decision)
if (verdict?.status === 'exceeded' || unreadCappedPayer) {
logger.info('[API VALIDATION] Continuation usage exceeded', {
userId,
unread: unreadFreePayer,
unread: unreadCappedPayer,
})
span.setAttribute(
TraceAttr.CopilotValidateOutcome,
Expand Down
9 changes: 9 additions & 0 deletions apps/sim/app/api/users/me/subscription/[id]/transfer/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { isOrgPlan } from '@/lib/billing/plan-helpers'
import {
ENTITLED_SUBSCRIPTION_STATUSES,
hasPaidSubscriptionStatus,
isTrialingSubscription,
} from '@/lib/billing/subscriptions/utils'
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
import { captureServerEvent } from '@/lib/posthog/server'
Expand Down Expand Up @@ -70,6 +71,14 @@ export const POST = withRouteHandler(
}
}

if (isTrialingSubscription(sub)) {
return {
kind: 'error',
status: 400,
error: 'A subscription in its free trial can be transferred once the trial ends.',
}
}

const [org] = await tx
.select({ id: organization.id })
.from(organization)
Expand Down
3 changes: 1 addition & 2 deletions apps/sim/app/api/v1/admin/credits/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export const POST = withRouteHandler(

let entityType: 'user' | 'organization'
let entityId: string
const plan = userSubscription.plan
let seats: number | null = null

// Route admin credits to the subscription's entity (org if org-scoped).
Expand Down Expand Up @@ -181,7 +180,7 @@ export const POST = withRouteHandler(
newCreditBalance = Number.parseFloat(stats?.creditBalance || '0')
}

await setUsageLimitForCredits(entityType, entityId, plan, seats, newCreditBalance)
await setUsageLimitForCredits(entityType, entityId, userSubscription, seats, newCreditBalance)

let newUsageLimit: number
if (entityType === 'organization') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
getDisplayPlanName,
getPlanTierCredits,
getPlanTierDollars,
getPlanWeeklyRefreshDollars,
isEnterprise,
isFree,
isPaid,
Expand All @@ -40,8 +39,10 @@ import {
} from '@/lib/billing/plan-helpers'
import {
getEffectiveSeats,
getSubscriptionWeeklyRefreshDollars,
hasPaidSubscriptionStatus,
hasUsableSubscriptionAccess,
isTrialingSubscription,
} from '@/lib/billing/subscriptions/utils'
import { buildUpgradeHref } from '@/lib/billing/upgrade-reasons'
import { getBaseUrl } from '@/lib/core/utils/urls'
Expand Down Expand Up @@ -81,6 +82,12 @@ const INVOICE_STATUS_BADGES: Record<string, InvoiceStatusBadge> = {
void: { variant: 'gray', label: 'Void' },
}

function getPeriodEndLabel(isCancelledAtPeriodEnd: boolean, isTrialing: boolean): string {
if (isCancelledAtPeriodEnd) return 'Access until'
if (isTrialing) return 'Free trial ends'
return 'Next billing date'
}

/** Resolve a Stripe invoice status to its badge presentation. */
function getInvoiceStatusBadge(status: string | null): InvoiceStatusBadge {
return (
Expand Down Expand Up @@ -337,7 +344,7 @@ export function Billing({ scope, organizationId, creditUsageHref }: BillingProps
}

const handleOpenBillingPortal = () => {
if (!permissions.canEditUsageLimit) {
if (!permissions.canManageBilling) {
toast.error("Can't manage payment method", {
description: 'Only organization admins can manage billing.',
})
Expand Down Expand Up @@ -375,7 +382,7 @@ export function Billing({ scope, organizationId, creditUsageHref }: BillingProps
}

const handleCancelSubscription = async () => {
if (!permissions.canEditUsageLimit) {
if (!permissions.canManageBilling) {
toast.error("Can't cancel subscription", {
description: 'Only organization admins can cancel the subscription.',
})
Expand Down Expand Up @@ -403,7 +410,7 @@ export function Billing({ scope, organizationId, creditUsageHref }: BillingProps
}

const handleRestoreSubscription = async () => {
if (!permissions.canEditUsageLimit) {
if (!permissions.canManageBilling) {
toast.error("Can't restore subscription", {
description: 'Only organization admins can restore the subscription.',
})
Expand Down Expand Up @@ -475,8 +482,9 @@ export function Billing({ scope, organizationId, creditUsageHref }: BillingProps
? organizationBilling?.cancelAtPeriodEnd === true
: subscriptionData?.data?.cancelAtPeriodEnd === true

const isTrialing = isTrialingSubscription(subscription)
const weeklyRefreshDollars =
getPlanWeeklyRefreshDollars(subscription.plan) *
getSubscriptionWeeklyRefreshDollars(subscription) *
(isOrganizationScope ? subscription.seats || 1 : 1)

const invoices = (invoicesData?.invoices ?? []).map((invoice) => ({
Expand All @@ -488,10 +496,10 @@ export function Billing({ scope, organizationId, creditUsageHref }: BillingProps
url: invoice.hostedInvoiceUrl ?? invoice.invoicePdf,
}))

const canManageBilling = permissions.canEditUsageLimit
const canManageBilling = permissions.canManageBilling
const canExplorePlans = permissions.showUpgradePlans
const showUsageLimit = subscription.isPaid && !subscription.isEnterprise
const showOnDemand = hasUsablePaidAccess && !subscription.isEnterprise
const showOnDemand = hasUsablePaidAccess && !subscription.isEnterprise && !isTrialing

const usageLimitCurrent =
subscription.isOrgScoped && organizationBilling
Expand Down Expand Up @@ -614,7 +622,7 @@ export function Billing({ scope, organizationId, creditUsageHref }: BillingProps
{periodEnd && (
<div className='flex items-center justify-between'>
<span className='text-[var(--text-body)] text-small'>
{isCancelledAtPeriodEnd ? 'Access until' : 'Next billing date'}
{getPeriodEndLabel(isCancelledAtPeriodEnd, isTrialing)}
</span>
<span className='text-[var(--text-muted)] text-small'>
{new Date(periodEnd).toLocaleDateString()}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { isTrialingSubscription } from '@/lib/billing/subscriptions/utils'

export interface SubscriptionPermissions {
canUpgradeToPro: boolean
canUpgradeToTeam: boolean
canViewEnterprise: boolean
canManageTeam: boolean
/** Manage payment method and cancel or restore the plan. */
canManageBilling: boolean
/** Change the usage limit or on-demand usage; a trial's allowance is fixed. */
canEditUsageLimit: boolean
canCancelSubscription: boolean
showTeamMemberView: boolean
Expand Down Expand Up @@ -37,6 +42,7 @@ export function getSubscriptionPermissions(
userRole: UserRole
): SubscriptionPermissions {
const { isFree, isPro, isEnterprise, isPaid, isOrgScoped } = subscription
const isTrialing = isTrialingSubscription(subscription)
const { isTeamAdmin } = userRole

// Non-admin org members see the "team member" view: no edit / no cancel
Expand All @@ -45,14 +51,17 @@ export function getSubscriptionPermissions(
const orgAdminOrSolo = !isOrgScoped || isTeamAdmin

const isEnterpriseMember = isEnterprise && !isTeamAdmin
const canManageBilling = (isFree || (isPaid && !isEnterprise)) && orgAdminOrSolo
const canViewUsageInfo = !isEnterpriseMember

return {
canUpgradeToPro: isFree,
canUpgradeToTeam: isFree || (isPro && !isOrgScoped),
// A trial becomes a team plan only after it converts.
canUpgradeToTeam: isFree || (isPro && !isOrgScoped && !isTrialing),
canViewEnterprise: !isEnterprise && !orgMemberOnly,
canManageTeam: isOrgScoped && isTeamAdmin && !isEnterprise,
canEditUsageLimit: (isFree || (isPaid && !isEnterprise)) && orgAdminOrSolo,
canManageBilling,
canEditUsageLimit: canManageBilling && !isTrialing,
canCancelSubscription: isPaid && !isEnterprise && orgAdminOrSolo,
showTeamMemberView: orgMemberOnly,
showUpgradePlans:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { DEFAULT_BILLING_CONCURRENCY_LIMITS } from '@/lib/billing/concurrency-defaults'
import { CREDIT_TIERS, CREDITS_PER_DOLLAR, DEFAULT_FREE_CREDITS } from '@/lib/billing/constants'
import {
CREDIT_TIERS,
CREDITS_PER_DOLLAR,
DEFAULT_FREE_CREDITS,
PRO_TRIAL_DAYS,
} from '@/lib/billing/constants'

/**
* Looks up a credit tier by name, so a column binds to the right tier even if
Expand Down Expand Up @@ -84,6 +89,10 @@ export const COMPARISON_SECTIONS: ComparisonSection[] = [
'Custom',
],
},
{
label: 'Free trial for new subscribers',
values: [false, `${PRO_TRIAL_DAYS} days`, false, false],
},
{
label: 'Weekly refresh',
values: [
Expand Down
20 changes: 18 additions & 2 deletions apps/sim/components/emails/billing/plan-welcome-email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ interface PlanWelcomeEmailProps {
planName: string
userName?: string
loginLink?: string
trial?: {
/** When the trial ends and the card is first charged, already formatted for display. */
endsOn: string
/** Credits the trial includes, already formatted for display. */
credits: string
}
}

export function PlanWelcomeEmail({ planName, userName, loginLink }: PlanWelcomeEmailProps) {
export function PlanWelcomeEmail({ planName, userName, loginLink, trial }: PlanWelcomeEmailProps) {
const baseUrl = getBaseUrl()
const cta = loginLink || `${baseUrl}/login`

const previewText = `Sim: Your ${planName} plan is active`
const previewText = trial
? `Sim: Your ${planName} free trial has started`
: `Sim: Your ${planName} plan is active`

return (
<EmailLayout preview={previewText} showUnsubscribe={true}>
Expand All @@ -23,6 +31,14 @@ export function PlanWelcomeEmail({ planName, userName, loginLink }: PlanWelcomeE
your workflows.
</Text>

{trial && (
<Text style={baseStyles.paragraph}>
Your free trial includes <EmailStrong>{trial.credits} credits</EmailStrong> and runs until{' '}
<EmailStrong>{trial.endsOn}</EmailStrong>. Your card is charged for {planName} when the
trial ends unless you cancel before then in Settings → Subscription.
</Text>
)}

<EmailButton href={cta}>Open Sim</EmailButton>

<Text style={baseStyles.paragraph}>
Expand Down
Loading
Loading