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
from openai import OpenAI
client = OpenAI(base_url="https://api.fikraapi.co.ke/v1", api_key="fk_...")
response = client.chat.completions.create(
model="deepseek-v4-1-flash-economy-free",
messages=[{"role": "user", "content": "Hello"}],
)
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.05625 USD per 1M input tokens and $0.1 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 to API key missing, malformed, or inactive.
- 400 Bad Request to Model name not supported or request format invalid.
- 429 Too Many Requests to Exceeded rate limit (30 req/min unverified, 100 req/min trusted).
- 503 Service Unavailable to Upstream busy; retry with exponential backoff.