By Fikra DevRel • 4 min read

Paying for Fikra API: Token Credits and Billing

Paying for Fikra API: Token Credits and Billing

Understanding Fikra API Billing

Fikra API operates on a token-credit wallet system. Instead of direct per-request billing, you top up your account with credits, which are then consumed as you make API calls. This model provides predictable cost management for developers.

Payment Methods

Fikra integrates with Paystack for billing. The public documentation states that M-Pesa and cards are accepted payment methods.

Note on Virtual Credit Cards: If you are considering using a virtual credit card, please confirm its compatibility with Paystack and Fikra's billing system directly with the Fikra support team before attempting a transaction. Fikra does not publicly guarantee support for all virtual card issuers.

Account and Top-Up Flow

  1. Access Dashboard: Log in to the Fikra dashboard at fikraapi.co.ke.
  2. Generate API Key: Create a new API key (format: 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 monitor their token-credit balance to avoid service interruptions. If your balance is insufficient, the API will return an HTTP 402 Payment Required status code.

Best Practices: - Implement logic in your application to catch HTTP 402 responses. - Notify users or administrators when the balance is low. - Avoid hard-coding payment details in your application code.

Security Advice

  • Never expose Fikra API keys in browser code. API keys should be stored securely on your server or in environment variables (e.g., FIKRA_API_KEY).
  • Use environment variables to manage secrets: bash export FIKRA_API_KEY="fk_live_your_key_here"
  • Rotate keys regularly and restrict access to trusted personnel.

Example: Checking Balance (Conceptual)

While Fikra does not provide a public REST endpoint for balance checks in the base documentation, you can infer balance status by monitoring API responses. If you receive a 402 error, it indicates insufficient credits.

import os
import requests

base_url = "https://api.fikraapi.co.ke/v1"
api_key = os.getenv("FIKRA_API_KEY")

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

# Example request to check if the key is valid and has credits
# Note: A specific /balance endpoint is not documented; use 402 handling instead.
try:
    response = requests.post(
        f"{base_url}/chat/completions",
        headers=headers,
        json={
            "model": "fikra-flash",
            "messages": [{"role": "user", "content": "Hello"}]
        }
    )
    if response.status_code == 402:
        print("Insufficient credits. Please top up your wallet.")
    else:
        print(response.json())
except Exception as e:
    print(f"Error: {e}")

For the most up-to-date payment options and balance management tools, refer to the 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