Paying for OpenAI Inference with M-Pesa via Fikra API
Bridging the Gap: OpenAI Inference with M-Pesa Payments
For African developers, accessing top-tier AI models like GPT-4 or GPT-3.5 Turbo has historically been hindered by payment infrastructure. While OpenAI is the gold standard for LLMs, their billing systems often require international credit cards that are not universally accessible or practical for local businesses.
Fikra API solves this by acting as a seamless bridge. We provide OpenAI-compatible endpoints that accept M-Pesa as a native payment method. This means you can leverage the power of OpenAI models without changing a single line of your existing code.
Why Fikra API?
- Zero Code Rewrites: Our API endpoints are drop-in replacements for the standard OpenAI API. If your code works with
openai.chat.completions.create, it works with Fikra. - Native M-Pesa Support: Pay for tokens directly via M-Pesa STK Push or manual payment. No international cards, no forex fees, no friction.
- Local Infrastructure: Reduced latency for developers in East and Southern Africa.
Getting Started
1. Create Your Fikra Account
Sign up at fikra.ai and verify your M-Pesa number. This ensures your payment method is linked to your developer profile.
2. Generate Your API Key
Navigate to the Dashboard > API Keys section. Generate a new key. This key will be used in place of your OpenAI API key.
3. Update Your Base URL
The only change you need to make in your code is the base_url.
Before (OpenAI):
import openai
openai.api_key = "sk-your-openai-key"
# Default base_url is https://api.openai.com/v1
After (Fikra API):
import openai
openai.api_key = "fikra-your-fikra-key"
openai.base_url = "https://api.fikra.ai/v1" # Point to Fikra
4. Make Your First Request
Your existing code remains identical. Here is an example using the Python SDK:
response = openai.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in simple terms."}
]
)
print(response.choices[0].message.content)
Payment Workflow
- Usage Tracking: Fikra tracks your token usage in real-time.
- Threshold Alert: When your balance approaches zero, you will receive an SMS and email notification.
- M-Pesa Top-Up:
- Click the "Top Up" button in your Fikra dashboard.
- Enter the amount you wish to add (e.g., 500 KES).
- You will receive an STK Push prompt on your phone.
- Enter your M-Pesa PIN to confirm.
- Instant Activation: Your balance is updated immediately, and your API requests resume without interruption.
Supported Models
Fikra currently supports the following OpenAI models:
- gpt-3.5-turbo
- gpt-4
- gpt-4-turbo
- text-embedding-ada-002
Note: Model availability may vary based on current partnerships. Check the Fikra Dashboard for the latest list.
Troubleshooting
- 401 Unauthorized: Ensure you are using your Fikra API key, not your OpenAI key.
- 404 Not Found: Verify that
openai.base_urlis set tohttps://api.fikra.ai/v1. - Payment Failed: Check your M-Pesa balance and ensure your phone number is correctly registered in your Fikra profile.
Conclusion
By using Fikra API, you gain access to world-class AI models with the convenience of local mobile money. Start building today with the power of OpenAI, paid for with M-Pesa.
Fikra API is not affiliated with OpenAI. OpenAI is a trademark of OpenAI Technologies, Inc.
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.