By Fikra DevRel • 4 min read

Managing Fikra API Credits: Wallet and Payment Methods

Managing Fikra API Credits: Wallet and Payment Methods

Fikra API operates on a token-credit wallet system. This means you purchase credits in advance, and your API usage deducts from this balance based on the tokens consumed by your requests. This model provides predictable costs and immediate access to the service once funds are added.

Payment Methods

Fikra integrates with Paystack for billing. According to public information, M-Pesa and card payments are accepted.

Note: If you are looking for a specific payment method not listed here (such as direct bank transfer or other regional mobile money providers), please confirm its availability with Fikra support before attempting to use it. Do not assume support for unlisted methods.

Account and Top-Up Flow

  1. Access Dashboard: Log in to your Fikra dashboard at fikraapi.co.ke.
  2. Generate API Key: Create a new API key (starting with fk_live_...) for your application.
  3. Top Up Wallet: Navigate to the billing section to add credits using an accepted method (M-Pesa or Card via Paystack).
  4. Verify Balance: Ensure your token-credit balance is sufficient before making API calls.

Monitoring Balance and Handling Errors

Developers should implement logic to monitor their remaining credit balance. If your balance is insufficient to process a request, the API will return an HTTP 402 Payment Required status code.

Best Practices: - Pre-check: Query your account balance via the dashboard or relevant API endpoints (if available) before high-volume batches. - Error Handling: Catch 402 responses in your application. Do not retry immediately; instead, alert the user or administrator to top up the wallet. - Logging: Log the request ID and timestamp when a 402 occurs to help with reconciliation.

Security Advice

  • Never expose API keys in client-side code: Do not include your FIKRA_API_KEY in JavaScript, HTML, or any code that runs in the user's browser. This key grants access to your wallet and usage limits.
  • Use Environment Variables: Store your API key in a secure environment variable (e.g., FIKRA_API_KEY) on your server.
  • Server-Side Proxies: If you are building a web application, route API calls through your backend server. The server holds the key and forwards requests to https://api.fikraapi.co.ke/v1/chat/completions.

Example: Secure Server-Side Request (Python)

import os
import requests

# Load key from environment variable, never hardcode
api_key = os.environ.get("FIKRA_API_KEY")
if not api_key:
    raise ValueError("FIKRA_API_KEY environment variable is not set")

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}

payload = {
    "model": "fikra-flash",
    "messages": [
        {"role": "user", "content": "Hello"}
    ]
}

try:
    response = requests.post(
        "https://api.fikraapi.co.ke/v1/chat/completions",
        headers=headers,
        json=payload
    )

    if response.status_code == 402:
        print("Error: Insufficient credits. Please top up your wallet.")
    elif response.status_code == 200:
        print(response.json())
    else:
        print(f"Error: {response.status_code} - {response.text}")

except Exception as e:
    print(f"Request failed: {e}")

For the most current list of supported payment methods and regional availability, always refer to the official Fikra dashboard or contact support.


JM
// The Founder

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.

usagestatusdashboard