Overview
Fikra API is an OpenAI-compatible AI inference API. The fikra-auto model is an auto model router: it picks a suitable model for each request while charging a flat rate per token. Using fikra-auto gives you a budget-friendly route when you don’t want to manage model selection yourself.
Prerequisites
- A Fikra API key stored in the
FIKRA_API_KEYenvironment variable. - Python with the OpenAI SDK installed.
- Fikra API base URL:
https://api.fikraapi.co.ke/v1.
Step-by-step
- Create an OpenAI client pointed at the Fikra API base URL.
- Use
model="fikra-auto"in your chat completion request. - Send the request to
POST /chat/completions. - Enable streaming if needed; chat completions support OpenAI-style streaming.
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.fikraapi.co.ke/v1",
api_key=os.environ["FIKRA_API_KEY"],
)
response = client.chat.completions.create(
model="fikra-auto",
messages=[
{"role": "user", "content": "Explain this idea in two sentences."}
],
)
print(response.choices[0].message.content)
Verify it works
The response uses the OpenAI chat-completions format. Check response.choices[0].message.content for the model output. A valid response means the auto router successfully handled your request.
Costs
fikra-auto is priced at:
- Input: 0.40 USD per 1M tokens
- Output: 0.40 USD per 1M tokens
Payments are handled through a token-credit wallet. Top up with M-Pesa or card via Paystack, or use x402 USDC on Base for agents. For other models and updated pricing, check the pricing page.
Common errors
- 401: Bad or inactive API key. Verify
FIKRA_API_KEYis set and the key is active. - 400: Unsupported model. Confirm the model name is exactly
fikra-auto. - 429: Rate limit reached. Unverified keys get 30 requests/min; trusted keys get 100 requests/min.
- 503: Upstream service busy. Retry with backoff.