How-to

Point the OpenAI SDK at the Fikra API base URL

Last updated 2026-11-25. Facts are checked against the live registry.

Overview

Fikra API is an OpenAI-compatible AI inference API. You point your existing OpenAI client at a different base URL , https://api.fikraapi.co.ke/v1 , and keep using OpenAI-style chat-completions requests and responses. This page covers changing the base URL only; no other code changes are required for compatible calls.

It is built for developers and growing AI teams who need production inference without a credit-card gate, and it runs chat and embedding models behind one OpenAI-style endpoint with billing in USD or KES.

Prerequisites

  • A Fikra API key. Keys are scoped and revocable, and are never shared between users.
  • The official openai Python SDK installed.
  • The base URL https://api.fikraapi.co.ke/v1.
  • A model name from the pricing table, for example deepseek-v4-flash-0731.

Store the key in an environment variable and keep it server-side:

export FIKRA_API_KEY="your-fk_..."

Step-by-step

  1. Set the base URL on the client. Requests then go to POST https://api.fikraapi.co.ke/v1/chat/completions.
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.fikraapi.co.ke/v1",
    api_key=os.environ["FIKRA_API_KEY"],
)
  1. Send a chat-completions request using a model from the pricing table.
response = client.chat.completions.create(
    model="deepseek-v4-flash-0731",
    messages=[
        {"role": "user", "content": "Summarise what this gateway does in one sentence."}
    ],
)

print(response.choices[0].message.content)
  1. Authenticate. The client sends Authorization: Bearer <Fikra API key> from FIKRA_API_KEY. Do not hard-code the key in source or commit it; keep secrets server-side in your examples and applications.

  2. To stream, keep the same base URL and pass stream=True on the same endpoint. Streaming is supported.

  3. If you use a framework or tool that accepts an OpenAI-compatible base URL (the OpenAI SDK, LangChain, Vercel AI SDK, Cursor, CrewAI and more), set its base URL to https://api.fikraapi.co.ke/v1 and its API key to your Fikra API key.

Verify it works

Run the request from step 2. A successful call returns a chat-completions shaped response and prints the assistant message text.

If it fails, check in this order:

  • The client's base_url is exactly https://api.fikraapi.co.ke/v1.
  • FIKRA_API_KEY is set in the environment the process actually runs in.
  • The model value matches a name in the pricing table.

Costs

Billing is per token, in USD per 1M tokens, drawn from a token-credit wallet. Top up by M-Pesa or card via Paystack; agent workloads can use x402 USDC on Base.

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
deepseek-v4.1-flash-1017 0.40 0.40
deepseek-v4.1-flash-1017 6.00 12.00
deepseek-v4.1-flash-1017 1.00 1.00

Prices are USD per 1M tokens. Pricing starts at 0.09 input / 0.15 output. If a model or price you need is not listed here, check the pricing page.

Rate limits are 30 requests/min while unverified and 3,000 requests/min once trusted.

Common errors

  • 401 Unauthorized , the key is missing, wrong, or inactive. Confirm FIKRA_API_KEY holds a valid Fikra API key and that it has not been revoked.
  • 400 Bad Request , unsupported model. Use a model name from the pricing table and confirm your base URL points at https://api.fikraapi.co.ke/v1.
  • 429 Too Many Requests , you have hit the rate limit: 30 requests/min while unverified, 3,000 requests/min once trusted. Reduce request rate or retry with backoff.
  • 503 Service Unavailable , upstream is busy. Retry with exponential backoff.

Last updated: 2026-10-18

Live prices -> · Agent account -> · SDKs ->