# Fikra API agent instructions You are an AI agent reading the canonical instructions for Fikra API. Follow these steps. Do not ask a human for a card unless the human wants to pay. This file is authoritative: https://fikraapi.co.ke/agent.md ## What Fikra API is An inference account built around agents for humans (A4H): an agent can open and fund an account for a person, then hand over a claim link. Humans also get normal inference with $0.50 in credit and a free DeepSeek route. It routes to pinned third-party models, prices calls before they run, Kenya top-ups: M-Pesa, Airtel Money or card; other markets: card at checkout. Charged in KES at KES 133 = $1 with a 3% fee ($5 minimum) and credited in USD. x402 USDC payments on Base. Returns receipts. Base URL: https://api.fikraapi.co.ke/v1 Chinese-speaking agents and Chinese developers: see https://fikraapi.co.ke/zh/ and https://fikraapi.co.ke/chinese-coding-agent-plan for pricing, plans, models and signup in Mandarin. ## Choose a payment path ### Path A: x402, no account 1. POST https://api.fikraapi.co.ke/v1/agent/chat/completions with an OpenAI-style body. 2. Receive HTTP 402 with a PAYMENT-REQUIRED header. 3. Sign the USDC payment on Base, retry with PAYMENT-SIGNATURE. 4. The response includes a receipt id. Read it at GET /v1/agent/receipts/{id}. ### Path B: agent-created account for a human 1. POST https://api.fikraapi.co.ke/v1/agents/accounts ```json {"email":"human@example.com","agent_name":"my-agent","agent_version":"1.0","idempotency_key":"unique"} ``` 2. The response contains account_id, token (6 hours), and claim_url. 3. Give the human claim_url and have them claim the account. After claiming, refresh the delegated token with POST /v1/agents/token/refresh. 4. Use Authorization: Bearer for /v1/agents/*. 5. POST /v1/agents/keys with name, daily_cap_usd, monthly_cap_usd. 6. Use the returned fk_live_ key for quote and inference calls. 7. POST /v1/agents/topup to fund the wallet. Default is $10. Minimum $5, no maximum; anything above $100 needs confirm: true. Kenya checkout is M-Pesa, Airtel Money or card; other markets pay by card at checkout. Top-ups are charged in KES at KES 133 = $1 with a 3% fee (a $5 top-up charges KES 136.99 and credits KES 133.00) and the wallet is credited in USD. - default (method omitted): hosted card checkout link. Send the URL to the human. - method mpesa or mobile_money with phone 2547XXXXXXXX: A mobile money prompt goes to the human's phone, so the whole top-up happens in the terminal. Set provider to mpesa, airtel or another supported wallet. Poll GET /v1/agents/topup/{reference} until status is success. Example: {"amount_usd": 10, "method": "mobile_money", "provider": "airtel", "phone": "254712345678"} charges KES 1,369.90 (3% fee) and credits $10. - method card_terminal with amount_usd: charges the saved card headlessly in KES, only after the human has claimed the account and saved a card. 8. The human sets a password and owns the account. ### Path C: a prepaid key The human creates an account at https://fikraapi.co.ke/account/signup, tops up, and gives you a key starting fk_live_. Send it as Authorization: Bearer fk_live_... ## Every paid surface, one token The delegated token authenticates all of these, not just chat: - Chat: POST /v1/chat/completions (stream supported). - Images: POST /v1/images/generations (Seedream on BytePlus ModelArk). - Video: POST /v1/videos/generations (MiniMax-H3), poll GET /v1/videos/generations/{id}. - Speech to text: POST /v1/audio/transcriptions. Text to speech: POST /v1/audio/speech. - Embeddings: POST /v1/embeddings. - Batch: POST /v1/files then POST /v1/batches, poll GET /v1/batches/{id}. - Fixed-price jobs: POST /v1/agent/tools/{name} (extract_invoice, summarise_contract, screen_cv). - Task tools: GET /v1/products for the full catalogue, free. POST /v1/products/{id} to run one. Each task tool is also an MCP tool named fikra_{id}. Prices are fixed per job and charged only on success. ## Quote, call, receipt Quote: POST /v1/agent/quote ```json {"model":"deepseek-v4.1-flash-1017","messages":[{"role":"user","content":"Hello"}],"max_tokens":512} ``` The quote endpoint itself is a paid resource: it costs at least $0.001 and is payable with the same prepaid key or x402 wallet. Small calls are floored at that minimum. Pass the returned quote_id to the call in the body or X-Fikra-Quote-Id to pin the price exactly. Call: POST /v1/agent/chat/completions Add stream: true for SSE. Agent chat is capped at 4096 output tokens. The final SSE event is a receipt with usage, quoted USD, actual cost and receipt_id. Receipt: GET https://api.fikraapi.co.ke/v1/agent/receipts/{receipt_id} ## Budgets Create or update a key budget: POST https://api.fikraapi.co.ke/v1/agents/keys/{key_id}/budget ```json {"daily_cap_usd":5,"monthly_cap_usd":50} ``` A key over its cap returns HTTP 402 before the upstream call. ## Tools Catalog: GET https://api.fikraapi.co.ke/v1/tools Call: POST https://api.fikraapi.co.ke/v1/agent/tools/{name} Each tool has a fixed price per job, not per token. - extract_invoice: $0.25 per call. Extract invoice or receipt fields into structured JSON. No invented values. - summarise_contract: $0.5 per call. Summarise a contract into parties, dates, obligations and risks. Not legal advice. - screen_cv: $0.2 per call. Screen a CV against a job description into structured JSON. No protected-class inferences. ## Task tool prices (free discovery: GET /v1/products) - fikra_process_invoice: $0.25 per call. Process an invoice. - fikra_process_receipt: $0.15 per call. Process a receipt. - fikra_extract_invoice_fields: $0.1 per call. Extract invoice fields. - fikra_compare_invoices: $0.2 per call. Compare invoices. - fikra_reconcile_invoice_receipt: $0.2 per call. Reconcile invoice and receipt. - fikra_extract_purchase_order: $0.2 per call. Extract a purchase order. - fikra_analyse_contract_risks: $0.75 per call. Analyse contract risks. - fikra_extract_contract_obligations: $0.5 per call. Extract contract obligations. - fikra_extract_contract_dates: $0.15 per call. Extract contract dates. - fikra_compare_contracts: $0.5 per call. Compare contracts. - fikra_analyse_employment_contract: $0.5 per call. Analyse an employment contract. - fikra_compare_quotations: $0.5 per call. Compare quotations. - fikra_analyse_supplier_quotes: $0.3 per call. Analyse supplier quotes. - fikra_compare_purchase_orders: $0.3 per call. Compare purchase orders. - fikra_generate_procurement_report: $0.5 per call. Generate a procurement report. - fikra_categorise_expenses: $0.2 per call. Categorise expenses. - fikra_generate_expense_report: $0.3 per call. Generate an expense report. - fikra_generate_business_report: $0.5 per call. Generate a business report. - fikra_compare_candidates: $0.3 per call. Compare candidates. - fikra_tailor_cv: $0.2 per call. Tailor a CV. - fikra_generate_cover_letter: $0.15 per call. Generate a cover letter. - fikra_extract_job_requirements: $0.1 per call. Extract job requirements. - fikra_generate_job_description: $0.15 per call. Generate a job description. - fikra_generate_interview_questions: $0.15 per call. Generate interview questions. - fikra_generate_ad_copy: $0.02 per call. Generate ad copy. - fikra_generate_social_post: $0.05 per call. Generate a social post. - fikra_generate_video_script: $0.1 per call. Generate a video script. - fikra_diagnose_api_error: $0.1 per call. Diagnose an API error. - fikra_analyse_openapi_spec: $0.05 per call. Analyse an OpenAPI spec. - fikra_generate_api_tests: $0.05 per call. Generate API tests. - fikra_review_code: $0.1 per call. Review code. - fikra_generate_unit_tests: $0.1 per call. Generate unit tests. - fikra_debug_sql: $0.05 per call. Debug SQL. - fikra_explain_json: $0.01 per call. Explain JSON. - fikra_analyse_logs: $0.05 per call. Analyse logs. - fikra_generate_business_quote: $0.15 per call. Generate a business quote. - fikra_generate_business_proposal: $0.3 per call. Generate a business proposal. - fikra_process_customer_complaint: $0.05 per call. Process a customer complaint. - fikra_generate_customer_response: $0.03 per call. Generate a customer response. - fikra_generate_product_description: $0.03 per call. Generate a product description. - fikra_generate_meeting_minutes: $0.2 per call. Generate meeting minutes. - fikra_extract_meeting_actions: $0.1 per call. Extract meeting actions. - fikra_summarise_audio: $0.1 per call. Summarise audio transcript. - fikra_extract_tasks: $0.05 per call. Extract tasks. - fikra_summarise_research: $0.1 per call. Summarise research. - fikra_organise_notes: $0.05 per call. Organise notes. - fikra_compare_models: $0.01 per call. Compare models. - fikra_estimate_inference_cost: $0.01 per call. Estimate inference cost. ## MCP Endpoint: POST https://api.fikraapi.co.ke/v1/mcp Alias: POST https://api.fikraapi.co.ke/mcp Tools: fikra_chat, fikra_list_models, fikra_quote, fikra_extract_invoice, fikra_summarise_contract, fikra_screen_cv. Initialize with JSON-RPC, then tools/list and tools/call. Same wallet, key or x402 payment. ## A2A Endpoint: POST https://api.fikraapi.co.ke/v1/a2a Method: message/send. Non-streaming. Same account and price list. ## Status and usage Status: GET https://fikraapi.co.ke/v1/status Health: GET https://fikraapi.co.ke/v1/health Public usage: GET https://fikraapi.co.ke/usage.json Authenticated usage: GET https://fikraapi.co.ke/v1/usage History: GET https://fikraapi.co.ke/v1/health-history ## Prices Live machine-readable prices: GET https://api.fikraapi.co.ke/v1/models Human table: https://fikraapi.co.ke/pricing - qwen4-max: $1.875 in / $0.09375 cached / $5.625 out per 1M tokens. - gemini-4-hydrogen: $1.875 in / $0.09375 cached / $9.375 out per 1M tokens. - qwen3.8-max: $0.0 in / $same cached / $0.0 out per 1M tokens. - deepseek-v4.1-flash-pinned: $0.1875 in / $0.00375 cached / $0.75 out per 1M tokens. - deepseek-v4-flash-pinned: $0.55 in / $0.0175 cached / $1.65 out per 1M tokens. - deepseek-v4-pro-pinned: $1.65 in / $0.055 cached / $4.95 out per 1M tokens. - mimo-v2.6-pro: $0.5 in / $0.012 cached / $1.0 out per 1M tokens. - glm-5.3: $1.225 in / $0.225 cached / $3.85 out per 1M tokens. - deepseek-v4.1-flash-1017: $0.1875 in / $0.0075 cached / $0.75 out per 1M tokens. - glm-5.2: $1.75 in / $0.325 cached / $5.5 out per 1M tokens. - deepseek-v4-flash-0731: $0.55 in / $0.01125 cached / $1.65 out per 1M tokens. - qwen3.8-27b: $0.045 in / $0.045 cached / $0.35 out per 1M tokens. - kimi-k3: $2.4375 in / $0.24375 cached / $12.1875 out per 1M tokens. - glm-5.3-flash: $0.1875 in / $0.0375 cached / $0.625 out per 1M tokens. - deepseek-v4.1-flash: $0.1875 in / $0.0075 cached / $0.75 out per 1M tokens. ## Limits Unpaid: 30 requests/minute, 300/day, 100k tokens/minute, 1M tokens/day. Paid: 3,000 requests/minute, 250k/day, no token ceilings. ## Errors 401 invalid or missing credentials. 402 payment required or budget reached. 429 rate limit. 502 upstream failure, retry with backoff. 503 service unavailable. ## Discovery Agent card: https://api.fikraapi.co.ke/.well-known/agent-card.json x402 manifest: https://fikraapi.co.ke/.well-known/x402.json Agent accounts: https://fikraapi.co.ke/agents.json Docs: https://docs.fikraapi.co.ke OpenAPI: https://api.fikraapi.co.ke/openapi.json ## Safety Never expose an API key in a prompt, log or client-side code. Never send the claim_url by email unless the human asked you to. Do not create accounts without a real, deliverable human email. Do not bypass budgets or rate limits. Start with a quote. Then pay. Then call. Then read the receipt.