Alternative to Stripe billing for AI: Fikra API Payment Guide
Overview
Fikra API provides an alternative to traditional global payment processors like Stripe for AI API billing. Fikra utilizes a token-credit wallet system integrated with Paystack.
The public Fikra website states that M-Pesa and cards are accepted payment methods. If you are looking for a specific payment method not listed here (such as direct bank transfer or other regional wallets), please confirm availability with Fikra support before attempting to use it.
What is a Token-Credit Wallet?
A token-credit wallet is a prepaid balance system. Instead of paying per request in real-time, you top up your account with credits. When you make API calls, the cost of the tokens used is deducted from this balance. This model simplifies billing for developers by decoupling payment processing from API request handling.
Account and Top-Up Flow
- Create an Account: Sign up for a Fikra account via the Fikra dashboard.
- Generate API Key: Create an API key (format:
fk_live_...) in the dashboard. - Top Up Wallet: Navigate to the billing section in the dashboard. Select a payment method (M-Pesa or Card) to add credits to your token-credit wallet.
- Verify Balance: Ensure your wallet balance is sufficient before making API calls.
Monitoring Balance and Handling HTTP 402
Developers should monitor their wallet balance to avoid service interruptions. If your balance is insufficient to cover the cost of a request, the Fikra API will return an HTTP 402 Payment Required status code.
Best Practices for Handling 402 Errors
- Check Balance: Implement logic to check your current wallet balance via the Fikra dashboard or available account endpoints.
- Graceful Degradation: If a 402 error is received, pause API calls and notify the user or administrator that a top-up is required.
- Retry Logic: Do not automatically retry 402 errors without first topping up the wallet, as this will result in repeated failures.
Security Advice
- Never expose Fikra API keys in browser code. API keys should only be used in server-side environments.
- Store your
FIKRA_API_KEYin environment variables or a secure secrets manager. - Use the following base URL for all API requests:
https://api.fikraapi.co.ke/v1
Example: Secure API Usage
import os
import requests
# Load API key from environment variable
api_key = os.environ.get("FIKRA_API_KEY")
base_url = "https://api.fikraapi.co.ke/v1"
headers = {
"Authorization": f"Bearer {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("Payment Required: Please top up your Fikra wallet.")
elif response.status_code == 200:
print(response.json())
else:
print(f"Error: {response.status_code}")
Note on Payment Methods
Fikra currently supports M-Pesa and cards via Paystack. If you require a different payment method, please contact Fikra support to confirm availability. Do not assume support for unlisted payment methods.
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.