Overview
Fikra API is an OpenAI‑compatible inference service hosted in Kenya. It lets developers run chat (and embeddings) behind the same OpenAI‑style endpoints without a credit‑card gate.
Prerequisites
- Python 3.8+
openaipackage (pip install openai)- Environment variable
FIKRA_API_KEYcontaining your Fikra API key - Internet access to
https://api.fikraapi.co.ke/v1
Step‑by‑step
import os
import openai
openai.api_key = os.getenv("FIKRA_API_KEY")
openai.base_url = "https://api.fikraapi.co.ke/v1"
response = openai.ChatCompletion.create(
model="deepseek-v4-flash-0731",
messages=[{"role": "user", "content": "Hello, world!"}],
stream=False
)
print(response.choices[0].message.content)
Verify it works
Run the script; you should receive a JSON response with the assistant’s reply. If the call succeeds, the endpoint replacement is complete.
Costs
Default pricing is $0.09 USD per 1M input tokens and $0.15 USD per 1M output tokens. Model‑specific rates (e.g., deepseek-v4-flash-0731) follow the same tier; see the pricing page for other models.
Common errors
- 401 Unauthorized – API key missing, malformed, or inactive.
- 400 Bad Request – Model name not supported or request format invalid.
- 429 Too Many Requests – Exceeded rate limit (30 req/min unverified, 100 req/min trusted).
- 503 Service Unavailable – Upstream busy; retry with exponential backoff.