Skip to content

Commit e8cdd7c

Browse files
docs: Improve PPE examples, and add PPR vs PPE section
1 parent 954740d commit e8cdd7c

File tree

2 files changed

+227
-37
lines changed

2 files changed

+227
-37
lines changed

sources/platform/actors/publishing/monetize/pay_per_event.mdx

Lines changed: 155 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ If you want to use the synthetic start event, remove the existing start event fr
191191

192192
Charge for things like URLs that appear valid but lead to errors (like 404s) since you had to open the page to discover the error. Return error items with proper error codes and messages instead of failing the entire Actor run.
193193

194+
:::info One call vs two calls
195+
196+
The following code snippets show the single call option to both return error item and charge for the work done.
197+
198+
If you prefer to return error item and charge for the work done in two calls, you can use the two calls option where you charge for the work done with `Actor.charge( ... )` and return the error item with `Actor.pushData( ... )`.
199+
200+
:::
201+
194202
<Tabs groupId="main">
195203
<TabItem value="JavaScript" label="JavaScript">
196204

@@ -294,35 +302,158 @@ You can display a status message or push a record to the dataset to inform users
294302

295303
If you're not using the Apify SDKs (JS/Python), you need to handle idempotency (ensuring the same operation produces the same result when called multiple times) manually to prevent charging the same event multiple times.
296304

297-
## Example of a PPE pricing model
298-
299-
You make your Actor PPE and set the following pricing:
305+
## Examples of a PPE pricing model
306+
307+
### Example: simple PPE pricing
308+
309+
- `scraped-product`: $0.01 per product - count every product record you return.
310+
- `scraped-product-detail`: $0.05 per detail - count every enriched product detail you provide.
311+
312+
#### Pricing breakdown by user
313+
314+
<table>
315+
<thead>
316+
<tr>
317+
<th>User</th>
318+
<th style={{whiteSpace: 'nowrap'}}>Plan</th>
319+
<th style={{width: '40%'}}>Events</th>
320+
<th style={{width: '35%'}}>Charges</th>
321+
<th style={{whiteSpace: 'nowrap'}}>Total</th>
322+
<th style={{whiteSpace: 'nowrap'}}>Cost</th>
323+
</tr>
324+
</thead>
325+
<tbody>
326+
<tr>
327+
<td>1</td>
328+
<td style={{whiteSpace: 'nowrap'}}>Paid plan</td>
329+
<td>
330+
<div style={{marginBottom: '4px'}}>1,000 × <code>scraped-product</code></div>
331+
<div>50 × <code>scraped-product-detail</code></div>
332+
</td>
333+
<td>
334+
<div style={{marginBottom: '4px'}}>1,000 × $0.01 = $10.00</div>
335+
<div>50 × $0.05 = $2.50</div>
336+
</td>
337+
<td><strong>$12.50</strong></td>
338+
<td>$3.20</td>
339+
</tr>
340+
<tr>
341+
<td>2</td>
342+
<td style={{whiteSpace: 'nowrap'}}>Paid plan</td>
343+
<td>
344+
<div style={{marginBottom: '4px'}}>500 × <code>scraped-product</code></div>
345+
<div>20 × <code>scraped-product-detail</code></div>
346+
</td>
347+
<td>
348+
<div style={{marginBottom: '4px'}}>500 × $0.01 = $5.00</div>
349+
<div>20 × $0.05 = $1.00</div>
350+
</td>
351+
<td><strong>$6.00</strong></td>
352+
<td>$1.50</td>
353+
</tr>
354+
<tr>
355+
<td>3</td>
356+
<td style={{whiteSpace: 'nowrap'}}>Free plan</td>
357+
<td>
358+
<div>5 × <code>scraped-product-detail</code></div>
359+
</td>
360+
<td>
361+
<div style={{marginBottom: '4px'}}>100 × $0.01 = $1.00</div>
362+
<div>5 × $0.05 = $0.25</div>
363+
</td>
364+
<td><strong>$1.25</strong></td>
365+
<td>$0.40</td>
366+
</tr>
367+
</tbody>
368+
</table>
369+
370+
The platform usage costs are just examples, but you can see the actual costs in the [Computing your costs for PPE and PPR Actors](/platform/actors/publishing/monetize/pricing-and-costs#computing-your-costs-for-ppe-and-ppr-actors) section.
371+
372+
#### Revenue breakdown
373+
374+
- **Revenue (paid users only)**: $12.50 + $6.00 = **$18.50**
375+
- **Underlying cost (paid users only)**: $3.20 + $1.50 = **$4.70**
376+
- **Profit**: 0.8 × $18.50 − $4.70 = **$10.10**
377+
378+
### Example: usage-indexed PPE pricing
379+
380+
- `llm-token-cent`: $0.02 per $0.01 LLM spend - emit one event for each cent billed by your LLM provider.
381+
382+
:::info Simplified example
383+
384+
For the simplicity of the example, we show only the LLM-token-cent event. In reality, you can charge for any event you want.
300385

301-
- _`actor-start` event_: $0.10 per start
302-
- _`scraped-product` event_: $0.01 per product
303-
- _`scraped-product-detail` event_: $0.05 per detail
304-
- _`ai-analysis` event_: $0.15 per analysis
305-
306-
During the first month, three users use your Actor:
307-
308-
- _User 1 (paid plan)_: Starts Actor 5 times, scrapes 1,000 products, makes 50 product details, runs 30 AI analyses
309-
- Charges: 5 × $0.10 + 1,000 × $0.01 + 50 × $0.05 + 30 × $0.15 = $0.50 + $10.00 + $2.50 + $4.50 = $17.50
310-
- _User 2 (paid plan)_: Starts Actor 2 times, scrapes 500 products, makes 20 product details, runs 10 AI analyses
311-
- Charges: 2 × $0.10 + 500 × $0.01 + 20 × $0.05 + 10 × $0.15 = $0.20 + $5.00 + $1.00 + $1.50 = $7.70
312-
- _User 3 (free plan)_: Starts Actor 1 time, scrapes 100 products, makes 5 product details, runs 3 AI analyses
313-
- Charges: 1 × $0.10 + 100 × $0.01 + 5 × $0.05 + 3 × $0.15 = $0.10 + $1.00 + $0.25 + $0.45 = $1.80
314-
315-
Let's say the underlying platform usage for the first user is $3.20, for the second $1.50, and for the third $0.40.
316-
317-
Your profit is computed only from the first two users, since they are on Apify paid plans. The revenue breakdown is:
386+
:::
318387

319-
- _Total revenue_: $17.50 + $7.70 = $25.20
320-
- _Total underlying cost_: $3.20 + $1.50 = $4.70
321-
- _Your profit_: 80% of revenue minus costs = 0.8 × $25.20 - $4.70 = $15.46
388+
#### Pricing breakdown by user
389+
390+
<table>
391+
<thead>
392+
<tr>
393+
<th>User</th>
394+
<th style={{whiteSpace: 'nowrap'}}>Plan</th>
395+
<th style={{width: '45%'}}>Events</th>
396+
<th style={{width: '35%'}}>Charges</th>
397+
<th style={{whiteSpace: 'nowrap'}}>Total</th>
398+
<th style={{whiteSpace: 'nowrap'}}>Cost</th>
399+
</tr>
400+
</thead>
401+
<tbody>
402+
<tr>
403+
<td>1</td>
404+
<td style={{whiteSpace: 'nowrap'}}>Paid plan</td>
405+
<td>
406+
<div style={{marginBottom: '4px'}}>$25.40 LLM usage:</div>
407+
<div>2,540 × <code>llm-token-cent</code></div>
408+
</td>
409+
<td>
410+
<div>2,540 × $0.02 = $50.80</div>
411+
</td>
412+
<td><strong>$50.80</strong></td>
413+
<td>$2.60</td>
414+
</tr>
415+
<tr>
416+
<td>2</td>
417+
<td style={{whiteSpace: 'nowrap'}}>Paid plan</td>
418+
<td>
419+
<div style={{marginBottom: '4px'}}>$12.10 LLM usage:</div>
420+
<div>1,210 × <code>llm-token-cent</code></div>
421+
</td>
422+
<td>
423+
<div>1,210 × $0.02 = $24.20</div>
424+
</td>
425+
<td><strong>$24.20</strong></td>
426+
<td>$1.20</td>
427+
</tr>
428+
<tr>
429+
<td>3</td>
430+
<td style={{whiteSpace: 'nowrap'}}>Free plan</td>
431+
<td>
432+
<div style={{marginBottom: '4px'}}>$3.90 LLM usage:</div>
433+
<div>390 × <code>llm-token-cent</code></div>
434+
</td>
435+
<td>
436+
<div>390 × $0.02 = $7.80</div>
437+
</td>
438+
<td><strong>$7.80</strong></td>
439+
<td>$0.35</td>
440+
</tr>
441+
</tbody>
442+
</table>
443+
444+
The platform usage costs are just examples, but you can see the actual costs in the [Computing your costs for PPE and PPR Actors](/platform/actors/publishing/monetize/pricing-and-costs#computing-your-costs-for-ppe-and-ppr-actors) section.
445+
446+
#### Revenue breakdown
447+
448+
- **Revenue (paid users only)**: $50.80 + $24.20 = **$75.00**
449+
- **Underlying cost (paid users only)**: $2.60 + $1.20 = **$3.80**
450+
- **Profit**: 0.8 × $75.00 − $3.80 = **$56.20**
451+
452+
This example illustrates the key trade-off of PPE pricing: while it's harder for users to predict exact costs upfront, it provides developers with a safer and more scalable revenue model that grows with actual usage.
322453

323454
## Event names
324455

325-
To implement PPE pricing, you need to define specific events in your Actor code. You can retrieve the list of available pricing event names using the [Get Actor](https://apify.com/docs/api/v2/act-get) API endpoint.
456+
If you need to know your event names, you can retrieve the list of available pricing event names using the [Get Actor](https://apify.com/docs/api/v2/act-get) API endpoint.
326457

327458
## Next steps
328459

sources/platform/actors/publishing/monetize/pay_per_result.mdx

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ where:
3535

3636
Only revenue and cost for Apify customers on paid plans are taken into consideration when computing your profit. Users on free plans are not reflected there.
3737

38+
## PPR vs PPE
39+
40+
PPR charges based on the number of results produced. PPE lets you define pricing for individual events, and help you to make your pricing more flexible. You can charge for specific events directly from your Actor by calling the PPE charging API.
41+
42+
:::info Learn more about PPE
43+
44+
If you want to learn more about PPE, please refer to the [Pay per event](/platform/actors/publishing/monetize/pay-per-event) section.
45+
46+
:::
47+
3848
## Best practices for PPR Actors
3949

4050
To ensure profitability, check the following best practices.
@@ -201,19 +211,68 @@ This ensures that every run generates at least one result, guaranteeing that use
201211

202212
## Example of PPR pricing model
203213

204-
You make your Actor PPR and set the price to be _$1/1,000 results_. During the first month, three users use your Actor:
205-
206-
- _User 1 (paid plan)_: Gets 50,000 results, costing them $50
207-
- _User 2 (paid plan)_: Gets 20,000 results, costing them $20
208-
- _User 3 (free plan)_: Gets 5,000 results, costing them $0
209-
210-
Let's say the underlying platform usage for the first user is $5, for the second $2, and for the third $0.5.
211-
212-
Your profit is computed only from the first two users, since they are on Apify paid plans. The revenue breakdown is:
213-
214-
- _Total revenue_: $50 + $20 = $70
215-
- _Total underlying cost_: $5 + $2 = $7
216-
- _Your profit_: 80% of revenue minus costs = 0.8 × $70 - $7 = $49
214+
You make your Actor PPR and set the price to be _$1/1,000 results_. During the first month, three users use your Actor.
215+
216+
#### Pricing breakdown by user
217+
218+
<table>
219+
<thead>
220+
<tr>
221+
<th>User</th>
222+
<th style={{whiteSpace: 'nowrap'}}>Plan</th>
223+
<th style={{width: '35%'}}>Results</th>
224+
<th style={{width: '45%'}}>Charges</th>
225+
<th style={{whiteSpace: 'nowrap'}}>Total</th>
226+
<th style={{whiteSpace: 'nowrap'}}>Cost</th>
227+
</tr>
228+
</thead>
229+
<tbody>
230+
<tr>
231+
<td>1</td>
232+
<td style={{whiteSpace: 'nowrap'}}>Paid plan</td>
233+
<td>
234+
<div>50,000 results</div>
235+
</td>
236+
<td>
237+
<div>50,000 ÷ 1,000 × $1.00 = $50.00</div>
238+
</td>
239+
<td><strong>$50.00</strong></td>
240+
<td>$5.00</td>
241+
</tr>
242+
<tr>
243+
<td>2</td>
244+
<td style={{whiteSpace: 'nowrap'}}>Paid plan</td>
245+
<td>
246+
<div>20,000 results</div>
247+
</td>
248+
<td>
249+
<div>20,000 ÷ 1,000 × $1.00 = $20.00</div>
250+
</td>
251+
<td><strong>$20.00</strong></td>
252+
<td>$2.00</td>
253+
</tr>
254+
<tr>
255+
<td>3</td>
256+
<td style={{whiteSpace: 'nowrap'}}>Free plan</td>
257+
<td>
258+
<div>5,000 results</div>
259+
</td>
260+
<td>
261+
<div>5,000 ÷ 1,000 × $1.00 = $5.00</div>
262+
</td>
263+
<td><strong>$0.00</strong></td>
264+
<td>$0.50</td>
265+
</tr>
266+
</tbody>
267+
</table>
268+
269+
The platform usage costs are just examples, but you can see the actual costs in the [Computing your costs for PPE and PPR Actors](/platform/actors/publishing/monetize/pricing-and-costs#computing-your-costs-for-ppe-and-ppr-actors) section.
270+
271+
#### Revenue breakdown
272+
273+
- **Revenue (paid users only)**: $50.00 + $20.00 = **$70.00**
274+
- **Underlying cost (paid users only)**: $5.00 + $2.00 = **$7.00**
275+
- **Profit**: 0.8 × $70.00 − $7.00 = **$49.00**
217276

218277
## Next steps
219278

0 commit comments

Comments
 (0)