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

# consumeRateLimit

[API Reference](/api-reference/modelence/server/functions/../../../index) / [modelence](/api-reference/modelence/server/functions/../../index) / [server](/api-reference/modelence/server/functions/../index) / consumeRateLimit

> **consumeRateLimit**(`options`): `Promise`\<`void`>

Defined in: [packages/modelence/src/rate-limit/rules.ts:30](https://github.com/modelence/modelence/blob/dcea4170315a023a7e8f0c3c5d551c26b7adecf3/packages/modelence/src/rate-limit/rules.ts#L30)

This function will check all rate limit rules on the specified bucket and type,
throw an error if any of them are exceeded and increase the count of the rate limit record.

## Example

```ts theme={null}
await consumeRateLimit({ bucket: 'api', type: 'ip', value: '127.0.0.1' });
```

## Parameters

| Parameter          | Type                                                                                                                                                                  | Description                                                    |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| `options`          | \{ `bucket`: `string`; `message?`: `string`; `type`: [`RateLimitType`](/api-reference/modelence/server/functions/../type-aliases/RateLimitType); `value`: `string`; } | -                                                              |
| `options.bucket`   | `string`                                                                                                                                                              | The bucket for the rate limit.                                 |
| `options.message?` | `string`                                                                                                                                                              | Optional custom error message when the rate limit is exceeded. |
| `options.type`     | [`RateLimitType`](/api-reference/modelence/server/functions/../type-aliases/RateLimitType)                                                                            | The type of the rate limit.                                    |
| `options.value`    | `string`                                                                                                                                                              | The value for the rate limit.                                  |

## Returns

`Promise`\<`void`>
