SaaS AI Billing for African Startups: Fikra API Payment Guide
Overview
Fikra API provides a billing model designed for developers and startups in Africa. The platform utilizes a token-credit wallet system integrated with Paystack for billing. Publicly, Fikra states that M-Pesa and card payments are accepted.
Note: If you are considering a payment method other than M-Pesa or cards, confirm its availability with Fikra before use, as specific regional payment options may vary.
Token-Credit Wallet
Fikra API operates on a token-credit wallet model. Instead of paying per request in real-time, you top up your account with credits. These credits are then deducted based on the tokens consumed by your API requests. This model allows for predictable cost management and immediate access to API services once funds are added.
Account and Top-Up Flow
- Access Dashboard: Log in to the Fikra dashboard to manage your account.
- Generate API Key: Create a new API key (format:
fk_live_...) for your application. - Top Up Wallet: Navigate to the billing section and add funds using an accepted method (M-Pesa or card) via the Paystack integration.
- Verify Balance: Ensure your token-credit balance is sufficient before making API calls.
Monitoring Balance and Handling HTTP 402
Developers should implement logic to monitor their token-credit balance to avoid service interruptions.
- HTTP 402 Payment Required: If your wallet balance is insufficient to cover the cost of a request, the API will return an HTTP 402 status code.
- Best Practice: Catch this error in your application and prompt the user or system administrator to top up the wallet. Do not retry the request immediately without adding funds, as it will continue to fail.
Security Advice
- Never expose API keys in browser code: Fikra API keys (e.g.,
fk_live_...) must be stored securely on your server or in environment variables (e.g.,FIKRA_API_KEY). Exposing them in client-side JavaScript or mobile app code can lead to unauthorized usage and depletion of your token credits. - Use Environment Variables: Load your API key from environment variables in your backend services to keep it secure.
Example: Secure API Call
import os
import requests
# Load API key from environment variable
api_key = os.environ.get("FIKRA_API_KEY")
if not api_key:
raise ValueError("FIKRA_API_KEY environment variable is not set")
url = "https://api.fikraapi.co.ke/v1/chat/completions"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
payload = {
"model": "fikra-flash",
"messages": [
{"role": "user", "content": "Hello"}
]
}
try:
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 402:
print("Payment required: Please top up your token-credit wallet.")
else:
response.raise_for_status()
print(response.json())
except requests.exceptions.HTTPError as e:
print(f"HTTP error occurred: {e}")
Conclusion
Fikra API’s token-credit wallet and Paystack integration provide a straightforward billing solution for African startups. By monitoring your balance and securing your API keys, you can ensure reliable and safe access to AI services.
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.