Overview
Fikra API is an OpenAI-compatible inference API. You can send chat completion requests to https://api.fikraapi.co.ke/v1/chat/completions using the OpenAI SDK. Rate limits are 30 requests/min for unverified accounts and 100 requests/min for trusted accounts. To batch 1,000 requests, throttle your client to stay under your current limit.
Prerequisites
- A Fikra API account with token credits.
- An API key set as the
FIKRA_API_KEYenvironment variable. - Python with the OpenAI SDK installed.
Step-by-step
- Set your API key:
bash
export FIKRA_API_KEY=your_api_key_here
- Create a client with the Fikra API base URL:
```python from openai import OpenAI import os import time
client = OpenAI( base_url="https://api.fikraapi.co.ke/v1", api_key=os.environ["FIKRA_API_KEY"], ) ```
- Choose a model. For example:
python
MODEL = "deepseek-v4-flash-0731"
- Loop over your 1,000 payloads and send one request at a time. Sleep between requests to stay within the rate limit:
```python messages_list = [...] # your 1,000 chat message lists
responses = [] for messages in messages_list: response = client.chat.completions.create( model=MODEL, messages=messages, ) responses.append(response.choices[0].message.content) time.sleep(2) # for 30 req/min; use 0.6 if your account is trusted ```
Use time.sleep(2) to stay under 30 requests/min, or time.sleep(0.6) if your account is trusted and you can use 100 requests/min.
- Handle each response as needed. The response format is OpenAI-style.
Verify it works
- Confirm each request returns a chat completion with a
choicesfield. - Count the successful responses in
responses. - Check that your request rate never exceeds the limit for your account level.
Costs
Pricing is in USD per 1M tokens.
| Model | Input (USD/1M tokens) | Output (USD/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 |
Common errors
- 401 to Bad or inactive API key. Confirm
FIKRA_API_KEYis set and the key is active. - 400 to Unsupported model. Use a model listed above.
- 429 to Rate limit exceeded. Stay within 30 req/min (unverified) or 100 req/min (trusted).
- 503 to Upstream busy. Retry with backoff.