> For the complete documentation index, see [llms.txt](https://synapse-labs.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://synapse-labs.gitbook.io/docs/info/limits.md).

# Limits

Some API endpoints, which are expensive to run, may have limits. These limitations are subject to change often. When changes occur, updates will be made on this page to reflect the new limits.

If you'd like to get rid of API limits, consider upgrading!&#x20;

{% hint style="danger" %}
**Warning** - Not up to date!

API limits are updated and changed often based on demand and availability, and this page is not always updated to match current limits.

You should always check using the API first! You do not need an API Key for the limits endpoint!
{% endhint %}

## Get Limits

<mark style="color:green;">`GET`</mark> `/limits`

This endpoint lets you get a list of rate limits for specific endpoints and their features.\
The number value associated with a limit is the number of milliseconds you must wait between requests.

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "llm": {
    "gpt-3.5-turbo-16k": 15000,
    "gemini-pro": 15000,
    "claude-3-sonnet": {
      "premium": 5000,
      "free": -1,
    },
    "gpt-4": { "premium": 5000, "free": -1 },
  },
  "sdxl": 20000,
  "playground": 90000,
  "dalle": 120000,
  "whisper": 600000,
  "tts": 60000,
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

[*Note: Some models have premium limits (usually low). If a limit is -1 that means it cannot be used!*](#user-content-fn-1)[^1]

## Example: Fetching and Updating Rate Limits

To get specific rate limits and update them every hour automatically, you can use the following example code. This script fetches the rate limits, updates them every hour, and saves the updated values to be referenced later if needed.

```javascript
let rateLimits = {};

// Function to fetch rate limits
async function fetchRateLimits() {
  try {
    const response = await fetch('https://synapselabs.onrender.com/limits', {
      headers: {
        'Content-Type': 'application/json'
      }
    });
    if (!response.ok) {
      throw new Error('Network response was not ok');
    }
    const data = await response.json();
    // Update the global variable with the latest rate limits
    rateLimits = data;
    console.log('Rate limits updated:', rateLimits);
  } catch (error) {
    console.error('Error fetching rate limits:', error);
  }
}

// Fetch rate limits immediately and then update every hour
fetchRateLimits();
setInterval(fetchRateLimits, 3600000); // 3600000 milliseconds = 1 hour
```

This script performs an initial fetch of the rate limits and then sets an interval to automatically update the limits every hour.

[^1]: Usually only models with premium limits are not available for free
