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, you purchase credits that are deducted as you consume tokens through the API. This model provides predictable cost management for developers.
Payment Methods
Fikra integrates with Paystack for billing. The public documentation states that M-Pesa and card payments are accepted.
Note: If you are looking for specific payment methods not listed here (such as direct bank transfers or other regional wallets), please confirm availability with Fikra support before attempting to use them. Do not assume support for unlisted methods.
Account and Top-Up Flow
- Access Dashboard: Log in to the Fikra dashboard at https://fikraapi.co.ke.
- Top Up Wallet: Navigate to the billing section to add credits to your token-credit wallet using an accepted payment method (M-Pesa or Card via Paystack).
- Generate API Key: Ensure you have a valid API key (format:
fk_live_...) from your dashboard. - Make Requests: Use your API key to make requests to the API. Credits are deducted based on token usage.
Monitoring Balance and Handling Errors
Developers should monitor their token-credit balance regularly 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: Implement logic in your application to catch HTTP 402 responses. When this occurs, prompt the user or administrator to top up their wallet via the Fikra dashboard. Do not retry the request immediately without topping up, as it will continue to fail.
Security Advice
- Never expose API keys in client-side code: Do not include your
FIKRA_API_KEYin browser JavaScript, mobile app code, or any publicly accessible frontend. This can lead to unauthorized usage and depletion of your credits. - Use Environment Variables: Store your API key in environment variables (e.g.,
FIKRA_API_KEY) on your server or backend service. - Server-Side Proxies: If you need to call the Fikra API from a frontend, route requests through your own backend server that holds the API key securely.
Example: Handling 402 in Python
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 credits. Please top up your Fikra wallet.")
return None
elif response.status_code == 200:
return response.json()
else:
print(f"Error: {response.status_code} - {response.text}")
return None
# Example usage
result = make_chat_request()
if result:
print(result["choices"][0]["message"]["content"])
For the most current payment options and balance details, always refer to your Fikra dashboard.
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.