Overview
Fikra API is an OpenAI-compatible inference API. You send ticket text to the embeddings endpoint, get one vector per ticket, and compare vectors to surface near-duplicates before an agent picks them up. The same base URL and key also serve chat models, so you can extend the flow later.
Prerequisites
- A Fikra API key. No credit-card gate to get started; top up the token-credit wallet when you are ready.
- The key exported as
FIKRA_API_KEYin your environment. Keep it server-side, never in client code. - Python with the OpenAI SDK installed (
pip install openai). - A batch of support ticket texts to embed.
Step-by-step
- Export your key and create a client pointed at the Fikra base URL.
- Send the ticket texts to
POST https://api.fikraapi.co.ke/v1/embeddingsin one request. - Compute cosine similarity between every pair of vectors.
- Flag pairs above a threshold you tune on your own data.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.fikraapi.co.ke/v1",
api_key=os.environ["FIKRA_API_KEY"],
)
tickets = [
"I was charged twice for my subscription this month.",
"Duplicate charge on my card for the monthly plan.",
"How do I reset my password?",
]
response = client.embeddings.create(
model="fikra-auto",
input=tickets,
)
vectors = [item.embedding for item in response.data]
Model availability and per-model pricing are on the pricing page , confirm the model you pass before production use.
import math
def cosine(a, b):
dot = sum(x * y for x, y in zip(a, b))
na = math.sqrt(sum(x * x for x in a))
nb = math.sqrt(sum(y * y for y in b))
return dot / (na * nb)
THRESHOLD = 0.90 # starting point only; tune against your own tickets
for i in range(len(vectors)):
for j in range(i + 1, len(vectors)):
score = cosine(vectors[i], vectors[j])
if score >= THRESHOLD:
print(f"possible duplicate: {i} <-> {j} score={score:.3f}")
Requests and responses follow the OpenAI-style shape, so existing OpenAI SDK code works once you change base_url and the key.
Verify it works
len(response.data)equals the number of tickets you sent, and every embedding has the same length.- Each item carries its
index, so you can map vectors back to tickets. - With the sample above, the two billing tickets should be flagged and the password ticket should not.
- If a call fails, check the status code against the list below before changing your code.
Costs
Usage is billed per token against your token-credit wallet, in USD or KES. Pricing starts at $0.09 per 1M input tokens and $0.15 per 1M output tokens. Listed examples:
| 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 |
Top up by M-Pesa or card through Paystack, or with x402 USDC on Base for agents. Rate limits are 30 requests/min for unverified accounts and 100 requests/min for trusted accounts. For anything not listed here, check the pricing page.
Common errors
- 401 Unauthorized , the key is missing, wrong, or inactive. Confirm
FIKRA_API_KEYholds a current key; keys are scoped and revocable. - 400 Bad Request , unsupported or misspelled model. Use a model name from the pricing page.
- 429 Too Many Requests , you hit the rate limit (30 requests/min unverified, 100 requests/min trusted). Batch tickets into fewer embedding calls.
- 503 Service Unavailable , upstream is busy. Retry with exponential backoff.
Last updated 2026-10-18.