Codestral 22B API Pricing & Rate Card
Complete 2026 developer pricing guide for Codestral 22B. Benchmark token economics, context window limits, prompt caching discounts, and live inference latency across official provider endpoints.
| Billing Dimension | Standard Rate | Cached / Optimized Rate | Batch (50% Off) | Context Window |
|---|---|---|---|---|
| Input Prompt | $0.20 / M | $0.10 / M | 50% discount (24h SLA) | 256,000 tokens |
| Output Generation | $0.60 / M | Standard metered | 50% discount (24h SLA) | Up to max model limit |
| Tool / Function Calling | Standard input tokens | Eligible for prefix cache | Batch supported | Shared context budget |
Interactive Monthly Cost Estimator
Estimate your total bill based on prompt size, response volume, and request volume.
Mistral AI's Coding Frontier: 32k Context & Fill-in-the-Middle Economics
Codestral 22B is Mistral AI's flagship open-weights model designed specifically for code generation, bug fixing, and test creation across more than 80 programming languages. Operating with an optimized 22-billion parameter architecture, Codestral matches or exceeds the coding benchmark scores of much larger 70B models while executing at significantly higher generation speeds.
Codestral features native support for Fill-in-the-Middle (FIM) completion and a 32,768-token context window, making it the premier open engine for driving Tab-autocomplete and conversational chat in modern IDEs.
Mistral API Pricing & Self-Hosted Hardware Rates
| Provider / Deployment | Input Rate / 1M | Output Rate / 1M | Monthly Cost (50M Tokens) |
|---|---|---|---|
| Mistral La Plateforme API | $0.20 / 1M | $0.60 / 1M | $20.00 / mo |
| Together AI Serverless | $0.30 / 1M | $0.30 / 1M | $15.00 / mo |
| Dedicated Cloud GPU (RunPod A10G) | $0.29 / hr (Unlimited tokens) | $0.00 | $70.00 / mo (24/7 run) |
Frequently Asked Questions
Related Frontier Showdowns & Hubs
Mistral Codestral 22B: Fill-in-the-Middle (FIM) & Self-Hosted VRAM Sizing
Mistral's Codestral 22B is an open-weight model purpose-built for code completion, code generation, and test synthesis across 80+ programming languages. With native Fill-in-the-Middle (FIM) capabilities and a 32,768-token context window, Codestral excels at in-editor tab autocomplete and agentic refactoring. At 22 billion parameters, it fits onto a single consumer NVIDIA RTX 4090 GPU (24GB VRAM) when quantized to 4-bit (AWQ/GPTQ) or a single enterprise A10G (24GB), delivering exceptional cost-efficiency.
| Deployment Model | Input / 1M Tokens | Output / 1M Tokens | Hardware Footprint | Monthly Cost (500M Tokens) |
|---|---|---|---|---|
| Mistral La Plateforme API | $0.20 / 1M | $0.60 / 1M | Serverless Managed Cloud | $200.00 / month |
| Self-Hosted vLLM (1x RTX 4090) | $0.00 (Fixed Hardware) | $0.00 | 1x 24GB GPU (4-bit AWQ) | $245.00 / mo (Rented RunPod 24/7) |
| Self-Hosted vLLM (1x A100 80GB) | $0.00 | $0.00 | 1x 80GB GPU (BF16 Unquantized) | $1,152.00 / mo ($1.60/hr) |
Production Pipeline: Fill-in-the-Middle (FIM) Completion Client
Using Mistral's native FIM tokens (`[PREFIX]`, `[SUFFIX]`, `[MIDDLE]`) for accurate code insertions inside active IDE files:
import requests
def request_fim_completion(prompt_prefix: str, prompt_suffix: str, api_key: str):
url = "https://codestral.mistral.ai/v1/fim/completions"
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
payload = {
"model": "codestral-2501",
"prompt": prompt_prefix,
"suffix": prompt_suffix,
"temperature": 0.0,
"max_tokens": 128,
"stop": ["\n\n", "\ndef ", "\nclass "]
}
response = requests.post(url, json=payload, headers=headers)
return response.json()["choices"][0]["message"]["content"]
Production Best Practices & Latency SLAs
- FIM Stop Sequences Mandatory: Always supply language-specific stop tokens (e.g., `["\n\n", "def "]`) to prevent the model from hallucinating subsequent unrelated functions into the middle of your code file.
- API Commercial License Terms: Codestral is released under the Mistral Non-Production (MNPL) license for self-hosting in non-commercial contexts. Commercial production deployments must use the paid Mistral API.
- In-Editor Debounce Threshold: Debounce autocomplete requests by 120ms to prevent issuing API requests on every intermediate keystroke while typing.
VRAM Allocation & Self-Hosted vLLM vs Managed Mistral API
Engineering teams deciding between self-hosting Codestral 22B and routing requests to Mistral AI's managed API endpoints must evaluate physical memory constraints. In FP16 precision, the base model weights alone demand 44 GB of VRAM. Adding the KV-cache required to serve 32k context windows across 8 concurrent developer sessions pushes hardware requirements beyond a single 48 GB GPU (such as an NVIDIA RTX 6000 Ada or A40), requiring either a dual-GPU node (2x A10G or 2x L4) or 4-bit/8-bit AWQ/GPTQ quantization.
Codestral 22B Production Hardware Footprint Matrix
| Quantization / Precision | Weights VRAM | KV Cache (32k / 4 Streams) | Target GPU Hardware | Hourly Host Cost |
|---|---|---|---|---|
| FP16 Native Uncompressed | 44.2 GB | 16.4 GB | 1x H100 80GB / 2x A100 40GB | $2.49 - $3.80 / hr |
| FP8 Scaled Serving | 22.8 GB | 8.2 GB | 1x L40S 48GB / 1x A6000 Ada | $1.15 - $1.45 / hr |
| AWQ 4-bit Quantized | 12.1 GB | 6.4 GB | 1x RTX 4090 24GB / 1x L4 24GB | $0.45 - $0.75 / hr |
Fill-in-the-Middle (FIM) Production Integration
Unlike standard autoregressive completions, IDE code assistants require prompt prefix and suffix tokens formatted according to Mistral's specific FIM markers (`[PREFIX]`, `[SUFFIX]`, and `[MIDDLE]`). When calling Codestral via REST, ensure the client sets `stop: ["[MIDDLE]"]` to prevent token hallucination when the cursor context is closed.
from mistralai import Mistral
import os
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
def complete_inline_code(prefix: str, suffix: str) -> str:
response = client.fim.complete(
model="codestral-22b",
prompt=prefix,
suffix=suffix,
temperature=0.1,
max_tokens=256
)
return response.choices[0].message.content
Codestral 22B Production Concurrency & Failover Architecture
In self-hosted vLLM environments with continuous batching enabled, Codestral 22B comfortably services up to 16 concurrent IDE completion streams per NVIDIA L40S instance with an average token generation latency under 12 milliseconds per token. To avoid developer disruption when VRAM limits are approached, deploy an active-passive hot standby cluster with automated DNS health-check failover.