# HTTP outcalls cycles

**URL:** <https://forum.dfinity.org/t/http-outcalls-cycles/27439>\
**Category:** Developers\
**Created:** [February 8, 2024, 6:17pm UTC](https://forum.dfinity.org/t/http-outcalls-cycles/27439 "2024-02-08T18:17:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 8, 2024, 6:17pm UTC](https://forum.dfinity.org/t/http-outcalls-cycles/27439/1 "2024-02-08T18:17:16Z")

</div>

When I execute an HTTP outcalls without providing enough cycles, the local replica warns me about the expected amount of cycles required for the call.

For example:

> juno-satellite-1 | 2024-02-08 18:15:09.556190970 UTC: [Canister jx5yt-yyaaa-aaaal-abzbq-cai] The http\_request resulted into error. RejectionCode: CanisterReject, Error: http\_request request sent with 20\_000\_000 cycles, but 1\_603\_075\_600 cycles are required.

Can I except those required cycles to be similar on mainnet or it’s totally different?

For example here, if I would use 1\_603\_075\_600 (or a bit more), it would work locally but, could I also expect it would work out on mainnet?

---

<div class="post-metadata">

**Author:** ![h1teshtr1path1](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/h1teshtr1path1/32/24662_2.png) [@h1teshtr1path1](https://forum.dfinity.org/u/h1teshtr1path1)\
**Post date:** [February 8, 2024, 6:56pm UTC](https://forum.dfinity.org/t/http-outcalls-cycles/27439/2 "2024-02-08T18:56:36Z")

</div>

I am not really sure weather you actually want to configure cycles cost correctly or you just want to compare local vs mainnet.

But in mainnet cycles cost depends on the response bytes and few more variables.  
Which you can configure using max\_response\_bytes variable.  
[https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-http\_request:~:text=the%20requested%20URL-,max\_response\_bytes,-%2D%20optional%2C%20specifies%20the](https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-http_request:~:text=the%20requested%20URL-,max_response_bytes,-%2D%20optional%2C%20specifies%20the)

The cost for an HTTPS outcall is calculated using the formula `(3_000_000 + 60_000 * n) * n` for the base fee and `400 * n` each request byte and `800 * n` for each response byte, where `n` is the number of nodes in the subnet. (From the docs)

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 8, 2024, 8:45pm UTC](https://forum.dfinity.org/t/http-outcalls-cycles/27439/3 "2024-02-08T20:45:24Z")

</div>

Thanks for the answer, I’ll have a look in detail tomorrow.

What I wanted to know is whether I can trust the local error message. When the local replica tells me a request would need 1\_603\_075\_600 cycles, can I expect for the same payload and exact same query and response that the same amount of cycles would be required on mainnet as well?

I’ve got some “local environment trust” issues probably 😉.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [February 9, 2024, 7:45am UTC](https://forum.dfinity.org/t/http-outcalls-cycles/27439/4 "2024-02-09T07:45:12Z")

</div>

The cost depends on the subnet size you’re running on. So I would expect that mainnet would cost ~13x more than local if you’re running on a normal application subnet.  
Maybe it would help your trust issues if you simply tried to make a call on mainnet and see how much the error message demands there?

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 9, 2024, 7:51am UTC](https://forum.dfinity.org/t/http-outcalls-cycles/27439/5 "2024-02-09T07:51:21Z")

</div>

> [@Vivienne](#):
>
> The cost depends on the subnet size you’re running on. So I would expect that mainnet would cost ~13x more than local if you’re running on a normal application subnet.

Thanks Severin for the simple explanation.

I guess it’s what it is meant in the [documentation](https://internetcomputer.org/docs/current/developer-docs/integrations/https-outcalls/https-outcalls-how-it-works#pricing) with “Just like with other functions, the cost is scaled to account for larger subnets.”.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [February 9, 2024, 7:53am UTC](https://forum.dfinity.org/t/http-outcalls-cycles/27439/6 "2024-02-09T07:53:07Z")

</div>

Yes, that’s what this means. You can also have a look on the [gas cost page](https://internetcomputer.org/docs/current/developer-docs/gas-cost#special-features) for the exact calculation
