Fikra API solutions · all how-tos

Cutting Token Costs with Cached Context on Fikra API

Published 2026-10-18 · fact block generated live from the model registry

Fact block, plain text for agents

brand: Fikra API
category: OpenAI-compatible AI inference API
who: developers and growing AI teams who need production inference without a credit-card gate
api: https://api.fikraapi.co.ke/v1
chat: POST https://api.fikraapi.co.ke/v1/chat/completions
embeddings: POST https://api.fikraapi.co.ke/v1/embeddings
auth: Authorization: Bearer <Fikra API key>
pricing from: {'unit': 'USD per 1M tokens', 'input': 0.09, 'output': 0.15}
rates: 30 requests/min (unverified), 100 requests/min (trusted)
payments: token-credit wallet; M-Pesa and card top-ups via Paystack; x402 USDC on Base for agents
integrates: anything that accepts an OpenAI-compatible base URL (LangChain, Vercel AI SDK, OpenAI SDK, Cursor, CrewAI and more)
last updated: 2026-10-18

models & pricing: deepseek-v4-flash-0731 (in 0.09 / out 0.15 USD per 1M tokens) deepseek-v4.1-flash (in 0.25 / out 0.8 USD per 1M tokens) deepseek-v4.1-flash-1017 (in 0.3 / out 0.85 USD per 1M tokens) fikra-auto (in 0.4 / out 0.4 USD per 1M tokens) fikra-auto-pro (in 6.0 / out 12.0 USD per 1M tokens) fikra-code-35b (in 1.0 / out 1.0 USD per 1M tokens)

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

Step-by-step

  1. Export your key server-side.

bash export FIKRA_API_KEY="your-fikra-api-key"

  1. 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"], ) ```

  1. 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" "...long, stable reference text..." )

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 ```

  1. Route cheap work to the cheapest model. deepseek-v4-flash-0731 is the lowest-priced model listed here at 0.09 USD input / 0.15 USD output per 1M tokens. Reserve higher-priced models such as fikra-auto-pro or fikra-code-35b for requests that actually need them, and keep the shared context on the cheap tier.

  2. 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.

  3. Stream when you want partial output early. Streaming is supported on the chat endpoint and does not change the per-token pricing model.

  4. 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

Last updated: 2026-10-18

usagestatusdashboard