Managing Fikra API Billing and Token Credits
Understanding Fikra API Billing
Fikra API operates on a token-credit wallet system. Instead of direct per-request billing, developers purchase credits that are deducted as tokens are processed. This model provides predictable cost management and immediate access to API services once funds are available.
Payment Methods
Fikra integrates with Paystack for billing. The public documentation states that M-Pesa and card payments are accepted.
Note on External Providers: If you are searching for "Anthropic billing issues Africa," please note that Anthropic is an external provider. Fikra API does not serve Anthropic models. For Fikra API, you should use the supported payment methods listed above (M-Pesa and cards via Paystack). If you require a specific payment method not listed here, confirm its availability with Fikra support before attempting a transaction.
Account and Top-Up Flow
- Access Dashboard: Log in to the Fikra dashboard at https://fikraapi.co.ke.
- Generate API Key: Create a new API key (format:
fk_live_...) for your application. - Top Up Wallet: Navigate to the billing section to add credits using M-Pesa or a supported card.
- Verify Balance: Ensure your token-credit balance is sufficient before making API calls.
Monitoring Balance and Handling Errors
Developers should monitor their token-credit balance to avoid service interruptions. If your balance is insufficient to process a request, the API will return an HTTP 402 (Payment Required) status code.
Best Practices: - Implement logic in your application to catch HTTP 402 responses. - When a 402 is received, pause API calls and prompt the user or administrator to top up the wallet. - Do not retry the request immediately without verifying the balance has been updated.
Security Advice
- Never expose API keys in browser code. Fikra API keys (starting with
fk_live_...) should be stored securely on your backend server. - Use environment variables (e.g.,
FIKRA_API_KEY) to manage credentials in your development and production environments. - Rotate keys if you suspect they have been compromised.
Code Example: Handling 402 Errors
import os
import requests
FIKRA_API_KEY = os.getenv("FIKRA_API_KEY")
BASE_URL = "https://api.fikraapi.co.ke/v1"
def make_chat_request():
headers = {
"Authorization": f"Bearer {FIKRA_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": "fikra-flash",
"messages": [{"role": "user", "content": "Hello"}]
}
response = requests.post(f"{BASE_URL}/chat/completions", headers=headers, json=payload)
if response.status_code == 402:
print("Error: Insufficient token credits. Please top up your wallet.")
return None
elif response.status_code == 200:
return response.json()
else:
print(f"Error: {response.status_code} - {response.text}")
return None
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.