Fikra API solutions · all how-tos

Stream Chat Responses into a Web App with SSE

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 for developers and growing AI teams. Its chat completions endpoint accepts OpenAI-style requests and responses with streaming support, so you can stream token chunks into a web app as server-sent events (SSE).

Prerequisites

Step-by-step

  1. Create an OpenAI-style client pointed at the Fikra API base URL.
  2. Call the chat completions endpoint with stream=True and a model from your account.
  3. Forward each chunk to the browser over SSE.
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["FIKRA_API_KEY"],
    base_url="https://api.fikraapi.co.ke/v1",
)

stream = client.chat.completions.create(
    model="deepseek-v4-flash-0731",
    messages=[{"role": "user", "content": "Write a short Python snippet."}],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta
    if delta.content:
        # Send each piece to the web app as an SSE event
        print(delta.content, end="", flush=True)

In production, the loop above sits in a server route that writes each delta.content value as an SSE data: event. The browser subscribes to that route and appends events to the chat UI as they arrive.

Verify it works

Run the script and confirm tokens appear progressively rather than all at once. Then connect your web app to the SSE route and confirm the UI updates incrementally with each chunk.

Costs

Pricing is per 1M tokens, billed in USD from your token-credit wallet:

Common errors

usagestatusdashboard