Guides
Reliability
This guide covers what to do when a call does not go as planned. It explains which errors to retry, what a timeout costs, and where to get help.
Which Errors to Retry
In short, retry a 429 and a 500, and nothing else until you have changed something. Every other error will fail the same way if you send the request again.
| Status | type | Retry? |
|---|---|---|
| 400 | invalid_request | No. Fix the request first. |
| 401 | invalid_api_key | No. Send a valid key. |
| 402 | insufficient_credit | After you add credit. |
| 403 | account_suspended | No. Contact support. |
| 404 | not_found | No. Fix the URL. |
| 413 | text_too_large | No. Split the text first. |
| 429 | rate_limited | Yes, after the Retry-After delay. |
| 500 | internal_error | Yes. Wait a moment first. |
Retrying Safely
For a 429, wait the number of seconds in the Retry-After header. For a 500, wait a moment and try again, a little longer each time. Add a little random jitter, so that several workers do not retry at the same instant, and give up after a few tries.
import os
import random
import time
import requests
URL = "https://platform-api.getellora.com/v1/detect"
HEADERS = {"Authorization": f"Bearer {os.environ['ELLORA_API_KEY']}"}
def detect_with_retries(text: str, attempts: int = 4) -> dict:
for attempt in range(attempts):
try:
response = requests.post(URL, headers=HEADERS, json={"text": text}, timeout=10)
except (requests.ConnectionError, requests.Timeout):
# No answer. The call may still have finished and been charged, so retry sparingly.
response = None
if response is not None:
if response.status_code == 200:
return response.json()
if response.status_code == 429:
wait = int(response.headers.get("Retry-After", 5))
elif response.status_code == 500:
wait = 2**attempt
else:
response.raise_for_status() # 400, 401, 402, 403, 413: sending it again cannot help
else:
wait = 2**attempt
time.sleep(wait + random.random()) # a little jitter, so parallel workers do not retry together
raise RuntimeError("The API did not answer after several tries.")Timeouts and Charging
Set your client's timeout to at least 10 seconds. If your client gives up before the answer arrives, the call may still have finished and been charged.
There is no idempotency key. A call you send again is a new call, and it is charged again. Keep your timeouts generous, and retry after a timeout only when a second charge would not matter.
How Long Calls Take
We do not publish a response-time commitment. In our own tests the checking itself takes a fraction of a second, even for a text at the limit of 100,000 characters. Use a timeout of at least 10 seconds.
Rate Limit Headers
Every successful response carries two headers. X-RateLimit-Limit is the number of requests per minute your API key may make. X-RateLimit-Remaining is how many that key has left in the current minute.
These headers describe the limit of your key only. The limit of your workspace (300 requests per minute) and the limit of your IP address (120 per minute) are not counted in them, so a 429 can arrive while X-RateLimit-Remaining is above zero. A 429 always carries a Retry-After header.
Calling From a Browser
The API does not send CORS headers, so a browser cannot call it directly. Call it from your server. That also keeps your key out of the page, which is where it must stay.
Testing Without a Sandbox
There is no sandbox and there are no test keys. Every key, which starts with elk_live_, makes real calls. Your free credit of $5 covers about 50,000 words, and it is your test budget.
The playground in the console lets you try a text without writing any code. It spends credit in the same way.
Versioning
The URLs of the API carry a version, such as /v1. A change that could break your code is released under a new version prefix, so code written against /v1 is not changed by it. New fields can be added to a response at any time, so your code should ignore the fields it does not use. Every change is listed in the Changelog.
Getting Help
Email [email protected]. Include the request ID, which is the X-Request-Id header or the request_id in an error, and what you expected to happen. Please do not send the text itself unless we ask for it.