Core concepts
Rate limits
How many requests a minute the API accepts, the headers that report your limit, how to handle a 429, and the limit on agent runs in progress at once.
Rate limits keep the API responsive for every workspace. Each limit counts requests over a sliding window of one minute, and a request over the limit is refused with 429 before it runs, so it is never charged.
The limits#
| What is counted | Default limit |
|---|---|
| Requests to one endpoint, per workspace | 60 a minute |
| Requests to one polling endpoint, per workspace | 600 a minute |
An endpoint is one method and path, such as POST /v1/search, so each has its own allowance: 60 searches a minute leave your 60 record lookups untouched. Requests from all of a workspace's keys count toward the same workspace limit.
Polling endpoints are the reads you repeat while waiting for long-running work: listing agent runs and reading a run's status, results and events; listing enrichment jobs and reading a job and its results; and listing tool runs and reading a run and its events. Their higher limit lets you poll without running out.
Sprouts Data can set a different limit for a workspace, for one endpoint or for one API key. When a key has its own limit, a request must fit both the key's limit and the workspace's. Your current limit is always in the response headers, so read it from there rather than assuming the default.
Rate-limit headers#
Every response to a rate-limited request, successful or not, carries the limit that applied, in two sets of headers with the same values:
| Header | What it holds |
|---|---|
X-RateLimit-Limit and RateLimit-Limit | Requests allowed in the window. |
X-RateLimit-Remaining and RateLimit-Remaining | Requests left in the current window. |
X-RateLimit-Reset and RateLimit-Reset | Seconds until the window has room again. |
Use whichever set your HTTP tooling already understands. Watching Remaining lets you slow down before you are refused.
When you are refused#
A request over the limit gets 429 with the code quota.burst_exceeded and a Retry-After header saying how many seconds to wait. The body's extra says which limit was hit:
{
"type": "https://dashboard.sproutsdata.ai/errors/quota-burst-exceeded",
"title": "Too many requests",
"status": 429,
"code": "quota.burst_exceeded",
"detail": "This workspace may call POST /v1/search 60 times a minute. Retry after 12 seconds.",
"instance": "/v1/search",
"request_id": "9d2e6f0b7c3a43f9c2a7e1b4d4c8e9a5",
"next_step": "Retry after the `Retry-After` header's seconds; the request was not run.",
"extra": {
"limit": 60,
"window": "minute",
"operation": "POST /v1/search",
"scope": "workspace",
"retry_after": 12
}
}scope is workspace for the workspace's limit, api_key for a key's own limit, or user for a cap on a dashboard member.
Wait at least Retry-After seconds, then send the request again. Do not retry at once: a refused request is not counted, but a burst of immediate retries only meets the same limit. If many workers share a workspace, add a little random jitter so they do not all retry at the same moment.
import os
import random
import time
import requests
def post(url, body, attempts=5):
headers = {"X-API-Key": os.environ["SPROUTS_API_KEY"]}
for attempt in range(attempts):
response = requests.post(url, headers=headers, json=body)
if response.status_code != 429:
response.raise_for_status()
return response.json()
wait = int(response.headers.get("Retry-After", 2**attempt))
time.sleep(wait + random.random())
raise RuntimeError("Still rate limited after several attempts")
answer = post(
"https://api.sproutsdata.ai/v1/search",
{"category": "company", "query": "payments companies in Germany", "limit": 10},
)To stay under the limit in the first place, spread requests evenly over the minute instead of sending them in bursts, and fetch larger pages (up to limit: 100 on searches) rather than many small ones.
Runs in progress at once#
Agent runs take minutes, so they have a second limit: how many can be in progress at the same time. By default one credential (one API key) may have 2 agent runs going at once. Starting a third answers 429 quota.concurrency_exceeded, with a Retry-After. The same code is returned when the research engine itself is at capacity. Wait for one of your runs to finish (or for the Retry-After seconds), then start the next.
The Tools API has a similar limit per workspace: when the workspace already has as many tool runs in progress as it may, starting another answers 429 tools.too_many_runs with a Retry-After.
Neither of these is about request rate: polling a run's status while it works counts only toward the polling limit above.
Capacity#
Separately from your limits, the API can answer 503 service.overloaded when it is at capacity. The request was not run. Wait for the Retry-After seconds and retry, as for a 429.