Paying for Fikra API: M-Pesa and Token Credits
Overview
Fikra API operates on a token-credit wallet system. Developers purchase credits to use Fikra's models, such as fikra-flash or fikra-pro-20b. The platform integrates with Paystack for billing, and public documentation states that M-Pesa and card payments are accepted.
Note: If you are specifically looking for a "DeepSeek API" payment flow, note that DeepSeek is an external provider. Fikra does not serve DeepSeek models. This guide applies to paying for Fikra's own API services via M-Pesa or card.
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. Each API call consumes tokens from this balance. When the balance reaches zero, API requests will fail until you add more credits.
Account and Top-Up Flow
- Create an Account: Sign up for a Fikra account at fikraapi.co.ke.
- Generate API Key: Access your dashboard to generate a Fikra API key (format:
fk_live_...). - Top Up Wallet: Navigate to the billing section in the dashboard. Select M-Pesa or card as your payment method. Follow the Paystack prompts to complete the transaction.
- Verify Balance: Confirm that your token-credit balance has updated in the dashboard.
Monitoring Balance and Handling HTTP 402
Developers should monitor their token-credit balance to avoid service interruptions. If your balance is insufficient, the Fikra API will return an HTTP 402 Payment Required status code.
Handling 402 Errors
When you receive a 402 response, it indicates that your wallet balance is too low to process the request. You should:
- Log the error for debugging.
- Notify the user or system administrator that a top-up is required.
- Pause further API calls until the balance is replenished.
Example: Checking for 402 in Python
import os
import requests
base_url = "https://api.fikraapi.co.ke/v1"
api_key = os.environ.get("FIKRA_API_KEY")
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("Error: Insufficient token credits. Please top up your Fikra wallet.")
elif response.status_code == 200:
print(response.json())
else:
print(f"Unexpected error: {response.status_code}")
Security Advice
- Never expose your Fikra API key in browser code. Client-side JavaScript or HTML should not contain your
fk_live_...key, as it can be easily extracted by users. - Use server-side proxies. Route API requests from your backend server, which securely stores the API key in environment variables (e.g.,
FIKRA_API_KEY). - Rotate keys if compromised. If you suspect your key has been exposed, revoke it in the Fikra dashboard and generate a new one.
Important Notes
- Payment Methods: M-Pesa and card payments are publicly stated as accepted methods. Always confirm current availability and specific payment instructions in the Fikra dashboard.
- No Direct Payment APIs: Fikra does not offer a public API for processing payments. All top-ups must be done through the dashboard.
- External Providers: If you are integrating with DeepSeek or other external providers, their payment and billing systems are separate from Fikra. This guide does not apply to those 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.