Fikra API solutions · all how-tos

Generate Code with DeepSeek v4 Through 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 designed for developers and growing AI teams. You can run chat models behind one OpenAI-style endpoint and pay in USD or KES. This page shows how to use the DeepSeek v4 model (deepseek-v4-flash-0731) to generate code as part of a script using the chat completions endpoint.

The API base URL is https://api.fikraapi.co.ke/v1, and the chat endpoint is POST https://api.fikraapi.co.ke/v1/chat/completions. Requests and responses follow the OpenAI chat-completions format, and streaming is supported.

Prerequisites

Step-by-step

  1. Create an OpenAI client with the Fikra API base URL and your API key:

```python from openai import OpenAI import os

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

  1. Send a chat completion request to a DeepSeek v4 model with a code-generation prompt:

```python response = client.chat.completions.create( model="deepseek-v4-flash-0731", messages=[ { "role": "user", "content": "Write a Python script that reads a CSV file and prints the sum of a column.", } ], )

print(response.choices[0].message.content) ```

  1. The response body contains the generated script as the message.content value. You can save it to a .py file and run it, or use it directly in your own automation.

Other DeepSeek v4 models are also available: deepseek-v4.1-flash and deepseek-v4.1-flash-1017. Set model to one of those names if you prefer a different version.

Verify it works

Check that response.choices[0].message.content is a non-empty string containing Python code. For example, print the value and confirm it includes import csv or a similar code block. Unauthorized or malformed requests will return an error status instead of a valid completion.

You can also use stream=True in the request to receive tokens as they are generated.

Costs

Pricing is based on tokens processed. For deepseek-v4-flash-0731:

Other available models have different rates, including deepseek-v4.1-flash (input $0.25 / output $0.80 per 1M tokens), deepseek-v4.1-flash-1017 (input $0.30 / output $0.85 per 1M tokens), and fikra-auto (input $0.40 / output $0.40 per 1M tokens). For models not listed here, check the pricing page.

Payments are handled through a token-credit wallet. You can top up with M-Pesa or card via Paystack, and agents can use x402 USDC on Base.

Common errors

usagestatusdashboard