How-to

Generate SEO content with structured outputs

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

Overview

Fikra API gives you an OpenAI-compatible chat completions endpoint, so you can generate SEO content and receive it as structured JSON from a single model call. The API base URL is https://api.fikraapi.co.ke/v1, and you authenticate with your Fikra API key using Authorization: Bearer <Fikra API key>. Responses follow the OpenAI-style chat completions shape, which makes them easy to parse with the OpenAI Python SDK.

Prerequisites

  • A Fikra API key. Store it in an environment variable named FIKRA_API_KEY.
  • Python 3.8 or later.
  • The OpenAI Python SDK installed: pip install openai
  • A model from the Fikra API model list, for example deepseek-v4-flash-0731.

Step-by-step

  1. Set your API key in your environment:
export FIKRA_API_KEY="your_fikra_api_key"
  1. Create a Python script that calls the chat completions endpoint with a prompt that asks for JSON output:
import json
import os
from openai import OpenAI

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

prompt = """
Generate SEO content for a page targeting the keyword "affordable cloud storage".
Return JSON only with this exact structure:
{
  "title": "string",
  "meta_description": "string",
  "headings": ["string"],
  "body": "string"
}
"""

response = client.chat.completions.create(
    model="deepseek-v4-flash-0731",
    messages=[
        {"role": "system", "content": "You are an SEO content writer. Always respond with valid JSON."},
        {"role": "user", "content": prompt},
    ],
)

content = response.choices[0].message.content
data = json.loads(content)
print(json.dumps(data, indent=2))
  1. Use the parsed JSON in your content pipeline instead of scraping raw text.

Verify it works

Run the script. A successful response contains a choices[0].message.content string that can be parsed into JSON. The printed output should show the requested fields, for example:

{
  "title": "Affordable Cloud Storage: Plans, Pricing, and Features",
  "meta_description": "Compare affordable cloud storage plans with transparent pricing and reliable performance.",
  "headings": [
    "What Is Affordable Cloud Storage?",
    "How to Choose a Cloud Storage Plan",
    "Affordable Cloud Storage Pricing"
  ],
  "body": "Affordable cloud storage lets you scale..."
}

If you see that output, the endpoint is working correctly and the structured SEO content is ready to use.

Costs

Fikra API charges per 1 million tokens, with different rates by model. The available models and their input/output prices are:

Model Input (USD / 1M tokens) Output (USD / 1M tokens)
deepseek-v4-flash-0731 0.09 0.15
deepseek-v4.1-flash 0.25 0.80
deepseek-v4.1-flash-1017 0.30 0.85
deepseek-v4.1-flash-1017 0.40 0.40
deepseek-v4.1-flash-1017 6.00 12.00
deepseek-v4.1-flash-1017 1.00 1.00

For the exact current price list, check the pricing page.

Common errors

  • 401 Unauthorized to The API key is missing, invalid, or inactive. Confirm that FIKRA_API_KEY is set and that you are sending Authorization: Bearer <Fikra API key>.
  • 400 Bad Request to The requested model is not supported, or the request body is malformed. Check that the model name is exactly one from the model list.
  • 429 Too Many Requests to You hit the rate limit. Unverified keys are limited to 30 requests per minute, and trusted keys to 100 requests per minute. Wait before retrying.
  • 503 Service Unavailable to The upstream service is busy. Retry the request with exponential backoff.

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