How do I send requests to the Fikra API?

The core of the Fikra API is the Chat Completions endpoint. This endpoint accepts an array of messages and returns a model-generated response. It is engineered to map exactly to the OpenAI specification, allowing you to use existing open-source tooling out of the box.


HTTP Request Structure

To initiate an inference task, submit an HTTP POST request to our primary v1 router. Ensure your Content-Type is set to JSON.

Endpoint POST https://api.fikraapi.co.ke/v1/chat/completions
Headers Content-Type: application/json
Authorization: Bearer fk_live_...

JSON Payload Whitelist

Fikra API strictly whitelists incoming parameters to secure the multi-provider routing layer. Submitting unlisted parameters will result in a 400 Bad Request.

Note: Client-side declaration of `thinking` or `reasoning_effort` is intentionally disabled. Enabling reasoning modes is handled implicitly by selecting a reasoning-tier model in the registry (e.g., fikra-qwen-max). This secures your cash balance by preventing runaway token bills triggered by arbitrary parameter injection.

Parameter Type Requirement Description
model string Required ID of the Fikra model (e.g., fikra-flash). View the Model Registry.
messages array Required A list of conversation objects containing a role (system, user, assistant) and content.
stream boolean Optional If true, partial deltas will be sent via Server-Sent Events (SSE).
max_tokens integer Optional The maximum number of completion tokens generated before truncation.
temperature number Optional Controls creativity. Range is 0.0 to 2.0. Default is 0.7.

Additional supported parameters: top_p, stop, presence_penalty, frequency_penalty, response_format, tools, tool_choice, seed, n, and stream_options.

SSE Streaming & Auto-Redaction

When "stream": true is set, Fikra holds the connection open, streaming the response token-by-token. This drastically reduces Time-To-First-Token (TTFT) for user interfaces. The stream automatically injects stream_options: {"include_usage": true} to the upstream provider and captures the final chunk for billing before closing the socket with [DONE].

Fikra-Auto Mode Behavior

If you route requests through fikra-auto or fikra-auto-pro, the system automatically detects missing system roles. If absent, it injects a floor language prompt: "Respond in the same language as the user's message. Default to English."

Raw SSE Stream Example
data: {"id":"chatcmpl-123","choices":[{"delta":{"role":"assistant","content":""}}]} data: {"id":"chatcmpl-123","choices":[{"delta":{"content":"Hello"}}]} data: {"id":"chatcmpl-123","choices":[{"delta":{"content":"!"}}]} data: [DONE]

← Previous Topic

Authentication

Review how to secure your API requests via HTTP Headers.

Next Topic →

Model Registry

Choose the right pipeline based on context windows and reasoning needs.