Troubleshooting LLM Uptime and Error Handling
Understanding Uptime and Reliability
Fikra API does not publish a specific uptime SLA or guarantee dedicated capacity. Reliability depends on the underlying infrastructure and the specific model alias requested. To ensure robustness in your application, implement client-side retry logic and error handling for transient failures.
Common HTTP Error Codes
| Code | Meaning | Action |
|---|---|---|
| 400 | Malformed request or unsupported model alias. | Verify your request body structure and ensure the model field matches a current Fikra alias (e.g., fikra-flash, fikra-pro-20b). |
| 401 | Missing, invalid, or inactive API key. | Check your Authorization: Bearer fk_live_... header. Ensure the key is active in the Fikra dashboard. |
| 402 | Insufficient wallet balance. | Top up your token-credit wallet via the Fikra dashboard. |
| 429 | Rate limit exceeded. | Unverified accounts are limited to 30 RPM; trusted accounts to 100 RPM. Implement backoff. |
| 503 | Upstream/provider temporarily unavailable. | The model backend is temporarily unreachable. Implement backoff and retry. |
Handling 429 and 503 with Exponential Backoff
For 429 (rate limit) and 503 (service unavailable) errors, use exponential backoff to avoid overwhelming the API. Below is a compact Python example using the requests library.
import time
import requests
FIKRA_API_KEY = "your_api_key_here" # Load from environment variable in production
BASE_URL = "https://api.fikraapi.co.ke/v1"
def call_fikra_with_retry(model="fikra-flash", max_retries=5):
url = f"{BASE_URL}/chat/completions"
headers = {
"Authorization": f"Bearer {FIKRA_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": model,
"messages": [{"role": "user", "content": "Hello"}]
}
for attempt in range(max_retries):
try:
response = requests.post(url, headers=headers, json=payload)
if response.status_code in [429, 503]:
# Exponential backoff: 1s, 2s, 4s, 8s, 16s
wait_time = 2 ** attempt
print(f"Received {response.status_code}. Retrying in {wait_time}s...")
time.sleep(wait_time)
continue
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
if attempt == max_retries - 1:
raise e
time.sleep(2 ** attempt)
raise Exception("Max retries exceeded")
# Example usage
# result = call_fikra_with_retry()
Best Practices
- Monitor Wallet Balance: A
402error indicates insufficient credits. Monitor your balance in the Fikra dashboard to prevent service interruptions. - Respect Rate Limits: Adhere to the 30 RPM (unverified) or 100 RPM (trusted) limits to avoid
429errors. - Validate Model Aliases: Use only current Fikra aliases (
fikra-flash,fikra-fast-8b,fikra-pro-20b,fikra-pro-120b). Unsupported models will return a400error. - No Automatic Failover: Fikra does not automatically fail over to other models or providers. Your application must handle retries and error states explicitly.
James Miano
CTO & ML Engineer at Lacesse Ventures. James specializes in low-overhead LLM quantization processes, custom ternary weights architectures, and localized server optimization.
Stop paying for overpriced round-trip latency
Why route queries over Western servers when you can use low-overhead hardware located in Nairobi? Save 87% on your monthly inference spend. No minimum credit limits. M-Pesa ready.