> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Midjourney Billing Model

> Deconstruct Midjourney's GPU-time subscription with Relax Mode fallback and build the same model using Dodo Payments.

Midjourney एक generative AI platform है, जो image count के बजाय GPU time के आधार पर billing करता है। एक जटिल, high-resolution render में अधिक GPU time लगता है और इसलिए quick low-resolution draft की तुलना में plan का अधिक हिस्सा उपयोग होता है।

## Midjourney कैसे बिल करता है

हर Midjourney subscription में "Fast GPU Time" का monthly allowance शामिल होता है, यानी आपकी generations के लिए उपयोग होने वाला computing time। नीचे दिए गए आंकड़े [Midjourney's plan comparison](https://docs.midjourney.com/hc/en-us/articles/27870484040333-Comparing-Midjourney-Plans) से लिए गए हैं।

| योजना | मूल्य | Fast GPU Hours | Relax Mode | Stealth Mode |
| :- | :- | :- | :- | :- |
| Basic | \$10/month | \~3.3 hrs | No | No |
| Standard | \$30/month | 15 hrs | Unlimited | No |
| Pro | \$60/month | 30 hrs | Unlimited | Yes |
| Mega | \$120/month | 60 hrs | Unlimited | Yes |

1. **Pricing Tiers**: Midjourney $10 से $120 प्रति माह तक के चार subscription levels प्रदान करता है। प्रत्येक में Fast GPU time की एक निर्धारित मात्रा शामिल होती है।
2. **Relax Mode**: Standard और उससे ऊपर के plans में Fast time समाप्त होने के बाद low-priority queue में unlimited image generations शामिल होती हैं, इसलिए users को अचानक पूरी तरह रोका नहीं जाता।
3. **Extra GPU Hours**: अपने monthly allowance का उपयोग करने के बाद fast results की आवश्यकता होने पर users \$4 प्रति घंटे की दर से अतिरिक्त Fast GPU time खरीद सकते हैं।
4. **Metering in GPU Seconds**: Usage को प्रत्येक generation में लगने वाले GPU time के रूप में मापा जाता है, इसलिए complex renders की cost simple drafts से अधिक होती है।
5. **Community Loop**: Users images को rate करके free GPU time कमा सकते हैं, जिससे Midjourney के models को train करने में भी सहायता मिलती है।

## इसे अनोखा क्या बनाता है

Midjourney model user द्वारा भुगतान की जाने वाली राशि को उनके द्वारा उपयोग किए जाने वाले resources से जोड़ता है:

* **GPU-time billing** complex renders की pricing simple drafts से अधिक रखती है, जो उनकी compute cost के अनुरूप है।
* **Relax Mode** एक unlimited fallback है, जो churn कम करता है, क्योंकि monthly allowance समाप्त होने के बाद भी users की access बनी रहती है।
* **Fast vs Relax split** उन users को priority processing बेचकर upgrades के लिए प्रोत्साहित करता है जो speed को महत्व देते हैं।
* **Extra GPU Hours** power users को high-priority capacity के लिए mid-month top-up प्रदान करते हैं।

## इसे Dodo Payments के साथ बनाएं

आप subscriptions, usage meters और अपने application में logic को मिलाकर Dodo Payments के साथ यह model बना सकते हैं।

**1. Create a Usage Meter**

प्रत्येक customer द्वारा उपयोग किए गए GPU seconds को track करने वाला meter बनाएं।

* **Event name**: `gpu.fast_seconds`
* **Aggregation**: **Sum**, जिसमें `gpu_seconds` **Over Property** के रूप में हो

केवल Fast mode generations के लिए events भेजें। Relax mode generations को billing के लिए meter न करें।

**2. Create Subscription Products with Usage Pricing**

अपने subscription products बनाएं और plan के Fast GPU allowance के बराबर **Free Threshold** वाला usage meter जोड़ें।

| Product | Base Price | Free Threshold (seconds) | Overage Rate |
| :- | :- | :- | :- |
| Basic | \$10/month | 12,000 (3.3 hrs) | N/A (Hard Cap) |
| Standard | \$30/month | 54,000 (15 hrs) | \$0.00 (Relax Mode) |
| Pro | \$60/month | 108,000 (30 hrs) | \$0.00 (Relax Mode) |
| Mega | \$120/month | 216,000 (60 hrs) | \$0.00 (Relax Mode) |

हर plan पर price per unit को \$0 पर set करें, ताकि threshold से अधिक usage के लिए charge न लिया जाए। Dodo Payments threshold पर usage को रोकता नहीं है। आपका application Basic plan का hard cap लागू करता है और meter के threshold पार करने के बाद अन्य plans को Relax Mode पर भेजता है।

**3. Implement Application-Level Relax Mode**

Relax Mode billing feature नहीं है। जब Dodo Payments usage meter दिखाता है कि customer plan के threshold को पार कर चुका है, तब आपका application requests को slower queue पर भेजता है।

```typescript theme={null}
// getCustomerUsage, getSubscription, getThresholdForPlan, and queueGeneration are
// your application's own functions. getCustomerUsage can sum this cycle's events
// from client.usageEvents.list() or read a counter your app maintains.
async function handleGenerationRequest(customerId: string, prompt: string) {
  const usage = await getCustomerUsage(customerId, 'gpu.fast_seconds');
  const subscription = await getSubscription(customerId);
  const threshold = getThresholdForPlan(subscription.product_id);
  
  if (usage.current >= threshold) {
    if (subscription.product_id === 'pdt_basic') {
      throw new Error('Fast GPU hours exhausted. Upgrade to Standard for Relax Mode.');
    }
    
    // Relax Mode. Route to low-priority queue
    return await queueGeneration(customerId, prompt, {
      priority: 'low',
      mode: 'relax',
      model: 'standard'
    });
  }
  
  // Fast Mode. Priority processing
  return await queueGeneration(customerId, prompt, {
    priority: 'high',
    mode: 'fast',
    model: 'premium'
  });
}
```

**4. Send Usage Events (Fast Mode Only)**

केवल तब Dodo Payments को usage event भेजें, जब generation Fast mode में चले।

```typescript theme={null}
import DodoPayments from 'dodopayments';

async function trackFastGeneration(customerId: string, gpuSeconds: number, jobId: string) {
  // Only track Fast mode generations. Relax mode is free and unlimited
  const client = new DodoPayments({
    bearerToken: process.env.DODO_PAYMENTS_API_KEY,
  });

  await client.usageEvents.ingest({
    events: [{
      event_id: `gen_${jobId}`,
      customer_id: customerId,
      event_name: 'gpu.fast_seconds',
      timestamp: new Date().toISOString(),
      metadata: {
        gpu_seconds: gpuSeconds,
        resolution: '1024x1024',
        mode: 'fast'
      }
    }]
  });
}
```

**5. Sell Extra Fast Hours (One-Time Top-Up)**

"Extra Fast GPU Hour" नाम का एक one-time payment product बनाएं, जिसकी कीमत \$4 हो। जब कोई customer इसे खरीदे, तो अपने application में उनके threshold को खरीदे गए प्रत्येक घंटे के लिए 3,600 seconds बढ़ाएं।

```typescript theme={null}
// After customer purchases extra hours
const session = await client.checkoutSessions.create({
  product_cart: [
    { product_id: 'pdt_extra_gpu_hour', quantity: 5 }
  ],
  customer: { customer_id: customerId },
  return_url: 'https://yourapp.com/dashboard'
});
```

**6. Create Checkout for Subscription**

Subscription plan के लिए checkout session बनाएं।

```typescript theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    { product_id: 'pdt_mj_standard', quantity: 1 }
  ],
  customer: { email: 'artist@example.com' },
  return_url: 'https://yourapp.com/studio'
});
```

## Time Range Ingestion Blueprint के साथ तेज़ी लाएं

[Time Range Ingestion Blueprint](https://docs.dodopayments.com/developer-resources/ingestion-blueprints/time-range.md) duration-based billing के लिए ऐसे helpers प्रदान करता है, जो GPU time tracking लिखने को अधिक संक्षिप्त बनाते हैं।

```bash theme={null}
npm install @dodopayments/ingestion-blueprints
```

```typescript theme={null}
import { Ingestion, trackTimeRange } from '@dodopayments/ingestion-blueprints';

const ingestion = new Ingestion({
  apiKey: process.env.DODO_PAYMENTS_API_KEY,
  environment: 'live_mode',
  eventName: 'gpu.fast_seconds',
});

// runGeneration, prompt, settings, and customerId come from your application.
const startTime = Date.now();
const result = await runGeneration(prompt, settings);
const durationMs = Date.now() - startTime;

await trackTimeRange(ingestion, {
  customerId: customerId,
  durationMs: durationMs,
  metadata: {
    mode: 'fast',
    resolution: '1024x1024',
  },
});
```

Blueprint event बनाता है और duration को उसके metadata में भेजता है। आपको customer ID और elapsed time देना होता है। यह example `durationMs` भेजता है, इसलिए meter का **Over Property** `durationMs` पर set करें, या seconds पर आधारित meter से match करने के लिए `durationSeconds` भेजें।

> [!TIP]
>
> Time Range Blueprint durations को milliseconds, seconds या minutes में स्वीकार करता है। सभी duration options और best practices के लिए [full blueprint documentation](https://docs.dodopayments.com/developer-resources/ingestion-blueprints/time-range.md) देखें।

## Fast vs Relax Architecture

दोनों queues प्रत्येक request को customer के current usage के आधार पर route करती हैं।

```mermaid theme={null}
flowchart TD
    A[Generation Request] --> B{GPU Usage < Threshold?}
    B -->|Yes| C[Fast Queue]
    C --> D[Priority Processing]
    D --> E[Meter GPU Seconds]
    B -->|No| F{Plan Has Relax Mode?}
    F -->|Yes| G[Relax Queue]
    G --> H[Low Priority, Unmetered]
    F -->|No| I[Request Blocked]
```

1. सभी requests आपके application से होकर गुजरती हैं।
2. Application customer के Fast GPU usage की तुलना plan के free threshold से करता है।
3. यदि usage threshold से कम है, तो request Fast queue में जाती है और उसका metering किया जाता है।
4. यदि usage threshold से अधिक है, तो request Relax queue में जाती है, जो unmetered और lower priority होती है।
5. Basic plan में कोई Relax fallback नहीं है, इसलिए limit पूरी होने पर application requests को block कर देता है।

> [!NOTE]
>
> Relax Mode application-level pattern है, Dodo Payments billing feature नहीं। Dodo Payments आपके customers के Fast GPU usage को record करता है। User को block करना है या slower queue पर भेजना है, यह आपका application तय करता है।

## उपयोग की गई Dodo की प्रमुख सुविधाएं

> [card] [Subscriptions](https://docs.dodopayments.com/features/subscription.md)
>
> Recurring billing और plan tiers manage करें।

> [card] [Usage-Based Billing](https://docs.dodopayments.com/features/usage-based-billing/introduction.md)
>
> Actual resource consumption के आधार पर track और bill करें।

> [card] [Event Ingestion](https://docs.dodopayments.com/features/usage-based-billing/event-ingestion.md)
>
> Dodo Payments API को high-volume usage events भेजें।

> [card] [Meters](https://docs.dodopayments.com/features/usage-based-billing/meters.md)
>
> Define करें कि usage events को किस तरह aggregate और bill किया जाए।

> [card] [One-Time Payments](https://docs.dodopayments.com/features/one-time-payment-products.md)
>
> Extra hours या top-ups को one-time purchases के रूप में बेचें।

> [card] [Time Range Blueprint](https://docs.dodopayments.com/developer-resources/ingestion-blueprints/time-range.md)
>
> Duration-based helpers के साथ GPU time tracking को सरल बनाएं।


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.