By Fikra DevRel • 4 min read

Integrating Fikra API with Cursor IDE

Integrating Fikra API with Cursor IDE

Prerequisites

  • A Fikra API account with an active API key (fk_live_...).
  • Cursor IDE installed.
  • Access to the Fikra dashboard to verify your API key and token-credit wallet balance.

Configuration in Cursor IDE

Cursor IDE supports custom OpenAI-compatible endpoints. To route requests to Fikra API:

  1. Open Cursor Settings (gear icon or Cmd/Ctrl + ,).
  2. Navigate to Models or AI Provider settings.
  3. Select Custom OpenAI-compatible endpoint (or similar option depending on your Cursor version).
  4. Enter the following:
  5. Base URL: https://api.fikraapi.co.ke/v1
  6. API Key: Your Fikra API key (fk_live_...)
  7. Model: fikra-flash (or another listed alias like fikra-pro-20b)

Note: Cursor must support OpenAI-style chat-completions requests. If your version of Cursor does not expose a custom base URL option, use the generic HTTP integration below.

Environment Variable Setup

For programmatic or CLI-based integrations, set the Fikra API key as an environment variable:

export FIKRA_API_KEY="fk_live_your_key_here"

Python Example

import os
from openai import OpenAI

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

response = client.chat.completions.create(
    model="fikra-flash",
    messages=[
        {"role": "user", "content": "Explain how to configure a custom OpenAI base URL."}
    ]
)

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

Streaming Guidance

Fikra API supports streaming via stream: true and Server-Sent Events (SSE).

stream = client.chat.completions.create(
    model="fikra-flash",
    messages=[
        {"role": "user", "content": "Stream a short poem."}
    ],
    stream=True
)

for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

In Cursor IDE, streaming is typically handled automatically if the endpoint supports SSE. Ensure your network configuration allows long-lived HTTP connections.

Common Errors

HTTP Status Meaning Action
400 Bad Request Check request payload structure, model alias, and message format.
401 Unauthorized Verify your Authorization: Bearer fk_live_... header and API key validity.
402 Payment Required Insufficient token credits. Top up your wallet via the Fikra dashboard.
429 Rate Limit Exceeded Unverified accounts are limited to 30 RPM; trusted accounts to 100 RPM. Implement exponential backoff.
503 Service Unavailable Temporary server issue. Retry with backoff.

Production Checklist

  • [ ] Use https://api.fikraapi.co.ke/v1 as the base URL.
  • [ ] Store API keys in environment variables or a secrets manager, not in code.
  • [ ] Implement retry logic with exponential backoff for 429 and 503 errors.
  • [ ] Monitor token-credit wallet balance to avoid 402 errors.
  • [ ] Test with fikra-flash for low-latency tasks; use fikra-pro-20b or fikra-pro-120b for complex reasoning.
  • [ ] Verify streaming behavior in your target environment (Cursor IDE or custom client).
  • [ ] Check the Fikra model registry for current alias availability and capabilities.

JM
// The Founder

James Miano

CTO & ML Engineer at Lacesse Ventures. James specializes in low-overhead LLM quantization processes, custom ternary weights architectures, and localized server optimization.

Stop paying for overpriced round-trip latency

Why route queries over Western servers when you can use low-overhead hardware located in Nairobi? Save 87% on your monthly inference spend. No minimum credit limits. M-Pesa ready.

usagestatusdashboard