How-to

Build a Self‑Funding Customer Support Bot with Fikra API

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

Overview

Create a customer‑support chatbot using Fikra API’s OpenAI‑compatible chat endpoint. The bot runs on a pay‑per‑token model (USD or KES) and can be monetised through support subscriptions, helping it cover its own cost.

Prerequisites

  • Python 3.8+
  • openai Python package (pip install openai)
  • Fikra API key stored in environment variable FIKRA_API_KEY
  • Internet connectivity

Step-by-step

  1. Install the SDK bash pip install openai
  2. Configure the client ```python import os, openai

openai.api_key = os.getenv('FIKRA_API_KEY') openai.base_url = 'https://api.fikraapi.co.ke/v1' 3. **Send a chat request**python from openai import OpenAI

client = OpenAI(base_url="https://api.fikraapi.co.ke/v1", api_key="fk_...")

response = client.chat.completions.create( model="deepseek-v4-1-flash-economy-free", messages=[{"role": "user", "content": "Hello"}], ) print(response.choices[0].message.content) ``` 4. Hook the response into your support channel (e.g., webhook, chat widget). 5. Monitor usage via the Fikra dashboard to ensure revenue exceeds token cost.

Verify it works

Running the script above should return a concise answer like “To reset your password, click ‘Forgot password’ on the login page…”. A successful HTTP 200 response confirms the endpoint is reachable and the API key is valid.

Costs

  • Model: deepseek-v4.1-flash-1017
  • Input: $0.05625 USD per 1 M tokens
  • Output: $0.05625 USD per 1 M tokens
  • Rate limits: 30 requests/min for unverified keys, 100 requests/min for trusted keys. Track token usage to compare against any subscription revenue.

Common errors

  • 401 Unauthorized to API key missing, inactive, or scoped incorrectly.
  • 400 Bad Request to Invalid payload or unsupported model name.
  • 429 Too Many Requests to Exceeded the request‑rate limit; back‑off and retry.
  • 503 Service Unavailable to Upstream busy; retry with exponential back‑off.

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