Overview
Fikra API is an OpenAI-compatible AI inference API. You send OpenAI-style chat-completions requests to one endpoint , POST https://api.fikraapi.co.ke/v1/chat/completions , and get OpenAI-style responses back, with streaming supported. Billing is per token, in USD, with M-Pesa and card top-ups available.
This page shows how to keep repeated-context workloads cheap: reuse the same context instead of rebuilding it, and run that context on the lowest-cost model in the catalogue. Fikra API does not share keys between users, and keys are scoped and revocable.
Note: prompt-caching behaviour and any cache-specific pricing are not documented in this fact set. Check the pricing page before you rely on a cache discount.
Prerequisites
- A Fikra API key, kept in the environment variable
FIKRA_API_KEY. Never hardcode it in source or client code. - Python with the
openaiSDK installed. - Your API base URL set to
https://api.fikraapi.co.ke/v1. - A model name from the pricing list , for example
deepseek-v4-flash-0731. - Awareness of your rate tier: 30 requests/min unverified, 100 requests/min trusted.
Step-by-step
- Export your key server-side.
bash
export FIKRA_API_KEY="your-fikra-api-key"
- Create a client pointed at Fikra API. Authenticate with
Authorization: Bearer <Fikra API key>; the SDK sends this for you.
```python import os from openai import OpenAI
client = OpenAI( base_url="https://api.fikraapi.co.ke/v1", api_key=os.environ["FIKRA_API_KEY"], ) ```
- Build the reused context once, then send it as-is. Put the long, stable material , system instructions, reference documents, style rules , into a variable and reuse that exact string across requests instead of re-assembling it per call.
```python
SHARED_CONTEXT = (
"You are a support assistant for an online store. "
"Use this policy document when answering:\n"
"
def ask(question: str, model: str = "deepseek-v4-flash-0731") -> str: response = client.chat.completions.create( model=model, messages=[ {"role": "system", "content": SHARED_CONTEXT}, {"role": "user", "content": question}, ], ) return response.choices[0].message.content ```
-
Route cheap work to the cheapest model.
deepseek-v4-flash-0731is the lowest-priced model listed here at 0.09 USD input / 0.15 USD output per 1M tokens. Reserve higher-priced models such asfikra-auto-proorfikra-code-35bfor requests that actually need them, and keep the shared context on the cheap tier. -
Keep the context tight. Trim the shared block to what the task needs. Every token you leave in the context is billed on every request that carries it.
-
Stream when you want partial output early. Streaming is supported on the chat endpoint and does not change the per-token pricing model.
-
Respect your rate tier and back off on errors. At 30 requests/min (unverified) or 100 requests/min (trusted), batch and retry responsibly.
Verify it works
Run one call and confirm you get a completion back:
print(ask("What is the return window?"))
Then confirm the token accounting in the response so you can see what each request costs:
response = client.chat.completions.create(
model="deepseek-v4-flash-0731",
messages=[
{"role": "system", "content": SHARED_CONTEXT},
{"role": "user", "content": "What is the return window?"},
],
)
print(response.choices[0].message.content)
print(response.usage)
Use the reported token counts to compare a request that carries the full shared context against one that carries a trimmed version.
Costs
Pricing below is USD per 1M tokens.
| Model | Input | Output |
|---|---|---|
| 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 |
Entry pricing starts at 0.09 USD input / 0.15 USD output per 1M tokens.
Two levers control your bill on a repeated-context workload: which model carries the context, and how many tokens the context contains. A long stable context on deepseek-v4-flash-0731 costs a fraction of the same context on fikra-auto-pro.
Payment runs through a token-credit wallet, with M-Pesa and card top-ups via Paystack, and x402 USDC on Base for agents.
Whether repeated context is billed at a reduced cached rate is not stated here , check the pricing page.
Common errors
- 401 Unauthorized , the key is missing, malformed, or inactive. Confirm
FIKRA_API_KEYis set in the server environment and that the key is still active in your account. - 400 Bad Request , often an unsupported model name. Use a model from the pricing table above, spelled exactly.
- 429 Too Many Requests , you have exceeded your rate tier (30 requests/min unverified, 100 requests/min trusted). Slow down, queue work, or reduce concurrency.
- 503 Service Unavailable , upstream is busy. Retry with exponential backoff rather than retrying immediately.
Last updated: 2026-10-18