Overview
Fikra API exposes an OpenAI-compatible inference endpoint, so you can move from another OpenAI-style gateway by changing the base URL and model names. Existing chat-completions requests and responses keep the same format, and streaming is supported. Point any OpenAI-compatible client at https://api.fikraapi.co.ke/v1, authenticate with a Fikra API key, and use Fikra models.
Prerequisites
- A Fikra API key stored in the environment variable
FIKRA_API_KEY. - Python 3.7 or newer with the
openaiSDK installed. - Existing code that calls an OpenAI-compatible chat-completions endpoint.
Step-by-step
- Get an API key
Generate a scoped, revocable Fikra API key and export it:
bash
export FIKRA_API_KEY="your-key"
- Install or upgrade the OpenAI SDK
bash
pip install --upgrade openai
- Point the client at Fikra API
Replace the old gateway base URL withhttps://api.fikraapi.co.ke/v1and use your Fikra API key:
```python import os from openai import OpenAI
client = OpenAI( base_url="https://api.fikraapi.co.ke/v1", api_key=os.environ["FIKRA_API_KEY"], ) ```
-
Swap the model name
Change any model identifiers to one of the available Fikra models, for exampledeepseek-v4-flash-0731orfikra-auto. If your old gateway used a custom model name, map it to a Fikra model from the list below. -
Run a migration test
Send a minimal chat request to confirm the endpoint, authentication, and model are working before switching production traffic.
Verify it works
Run this script and confirm you get a text response:
response = client.chat.completions.create(
model="deepseek-v4-flash-0731",
messages=[{"role": "user", "content": "ping"}],
)
print(response.choices[0].message.content)
If the request succeeds, your OpenAI-compatible integration is ready for the new gateway. Streamed responses work the same way as before.
Costs
Fikra API bills per token in USD, with different rates per model:
| Model | Input (USD per 1M tokens) | Output (USD per 1M tokens) |
|---|---|---|
| deepseek-v4-flash-0731 | 0.09 | 0.15 |
| deepseek-v4.1-flash | 0.25 | 0.80 |
| deepseek-v4.1-flash-1017 | 0.30 | 0.85 |
| fikra-auto | 0.40 | 0.40 |
| fikra-auto-pro | 6.00 | 12.00 |
| fikra-code-35b | 1.00 | 1.00 |
Payments are made through a token-credit wallet. You can top up with M-Pesa or card via Paystack, or use x402 USDC on Base for agent workloads. Fikra API bills in USD or KES; check the pricing page for current details.
Common errors
- 401 Unauthorized to API key is missing, invalid, or inactive. Confirm
FIKRA_API_KEYis set and the key is scoped and enabled. - 400 Bad Request to The model name is not supported. Use an available model from the list above.
- 429 Too Many Requests to You hit the rate limit: 30 requests/min for unverified keys, 100 requests/min for trusted keys. Slow down or request trusted access.
- 503 Service Unavailable to Upstream is busy. Retry the request with exponential backoff.