Overview
Fikra API is an OpenAI-compatible AI inference API for developers and growing AI teams who need production inference without a credit-card gate. You can estimate the cost of a chat request before sending it by using the published per-token rates for each model. This guide walks through that calculation.
Prerequisites
- A Fikra API key. Keys are scoped and revocable.
- The API key set in your environment as
FIKRA_API_KEY. - A model name from the pricing table in the Costs section.
- Python 3.x with the
openaipackage if you plan to make a live call after estimating.
Step-by-step
- Choose a model. For example,
deepseek-v4-flash-0731. - Estimate input and output tokens. Count the tokens in your prompt and estimate the tokens in the model's completion. Token counts vary by model, so use a rough estimate when you do not have exact counts.
- Apply the rates. Multiply the input token count by the model's input rate per 1M tokens, and the output token count by its output rate per 1M tokens. Add the two results to get the estimated cost in USD.
- Use the optional estimator. The Python function below uses the published rates and does the multiplication for you.
```python import os
FIKRA_API_KEY = os.environ.get("FIKRA_API_KEY")
RATES = { "deepseek-v4-flash-