AI

Getting started with Mistral Codestral-22B

Learn how to implement Mistral Codestral-22B, which achieves an 81.1% pass rate on HumanEval for Python. This guide covers installation via Hugging Face, integration with VS Code, and various API pricing models.

Getting started with Mistral Codestral-22B

Codestral-22B-v0.1 achieves an 81.1% pass rate on HumanEval for Python tasks. This result exceeds the 76.2% pass rate for Llama 3 70B and the 67.1% pass rate for CodeLlama 70B. On the MBPP benchmark, Codestral scores 78.2%, while DeepSeek Coder 33B achieves 80.2%. The model also maintains a 51.3% pass rate on CruxEval-O for Python output prediction, which beats the 47.3% score of CodeLlama 70B and the 49.5% scores of both DeepSeek Coder 33B and Llama 3 70B. For long-range repository-level tasks, Codestral-22B-v0.1 hits a 34.0% completion rate on the RepoBench benchmark. This figure is higher than the 11.4% rate for CodeLlama 70B, the 18.4% rate for Llama 3 70B, and the 28.4% rate for DeepSeek Coder 33B. I find the model performs well on SQL tasks using the Spider benchmark.

Programming language support and FIM capability

Mistral trained Codestral-22B-v0.1 on a diverse dataset of more than 80 programming languages. Popular languages like Python, Java, C, C++, JavaScript, and Bash appear frequently in the training set. The model also handles more specialized languages like Swift and Fortran. Codestral uses a fill-in-the-middle mechanism to predict tokens between a prefix and a suffix. This capability helps software development add-ons like those in VS Code. I find the 32k token context window provides more room for large files than the 4k or 8k windows found in some competitors. The model can also complete coding functions, write tests, and complete partial code. This broad language base ensures Codestral assists developers in various coding environments and projects.

Implementation through CLI and Python libraries

Users can install Codestral-22B-v0.1 through Hugging Face or LM Studio. If you install the mistral_inference package, the mistral-chat command becomes available in your environment. You should run pip install --upgrade mistral_common to ensure you have version 1.2 or higher. The transformers library also works with this model. You must run pip install -U transformers before you start. Developers using the API through la Plateforme must manage their own rate limits and concurrency constraints because Mistral does not provide automatic retries for all client libraries when they encounter 429 errors during high volume tasks. You can use the mistral_inference package for inference.

Integration with professional coding environments

Continue.dev and Tabnine provide integration for Codestral in VSCode and JetBrains environments. Continue.dev users use the plugin for code generation, interactive conversation, and inline editing. Tabnine users use the plugin to chat with the model. You can also use Codestral within application frameworks like LlamaIndex and LangChain. These integrations allow developers to build agentic applications. Nate Sesti, the CTO and co-founder of Continue.dev, says Codestral is a public autocomplete model with a combination of speed and quality that did not exist before. Vladislav Tankov, the Head of JetBrains AI, notes that Mistral focuses on code and development assistance. Mikhail Evtikhiev, a researcher at JetBrains, tested Codestral on a Kotlin-HumanEval benchmark. He found that Codestral achieved a score of 73.75, which surpassed the 72.05 score of GPT-4-Turbo and the 54.66 score of GPT-3.5-Turbo. Meital Zilberstein, the R&D Lead at Tabnine, says the model delivers results on par with much larger models. Quinn Slack, the CEO and co-founder of Sourcegraph, notes that Codestral reduces the latency of Cody autocomplete while maintaining code quality.

API access and Le Chat pricing models

Mistral maintains two distinct billing systems for its users. The API via la Plateforme uses token-based pricing. This API provides access to Codestral at a rate of $0.30 per million input tokens and $0.90 per million output tokens. The Le Chat consumer interface uses a monthly subscription model. The Pro plan costs $14.99 per month and includes Codestral. The Free plan costs $0 and provides roughly 25 messages per day. The Pro plan includes Mistral Vibe for in-chat coding. The Team plan costs $24.99 per user per month and includes shared workspaces and admin features.

Plan Type Pricing Usage Details
Le Chat Free $0 25 messages per day
Le Chat Pro $14.99/month Includes Codestral
Le Chat Team $24.99/user/month Shared workspaces
API (la Plateforme) $0.30/$0.90 per MTok Billed per token

Developers can also use the dedicated endpoint at codestral.mistral.ai. This endpoint serves as a preference for developers using Instruct or Fill-In-the-Middle routes in an IDE. Mistral offered this endpoint for free during an 8 week beta period. The API key for this endpoint stays at the personal level. It does not bind to organization rate limits. What happens when the beta period for the dedicated endpoint ends?

Deployment through self-hosting and local hardware

The MacBook Pro with Apple Silicon handles local AI execution well because the unified memory architecture allows the CPU and GPU to share the same high-bandwidth RAM pool. A 32GB model runs large language models locally that would require expensive cloud GPU instances on other laptops. You should install Python 3 and Node.js to manage AI development libraries. You can download VS Code from code.visualstudio.com. After installation, you can add the code command to your terminal. I suggest installing the Cline extension by saoudrizwan for agentic coding and the Continue extension for inline suggestions. You can use both together.

You can run Mistral models locally using Ollama. To pull the Mistral Small 22B model, you run ollama pull mistral-small. This model requires approximately 14GB of RAM. You can also use Codestral for coding tasks through Ollama. You should check your local VRAM before pulling the model weights. For organizations that want to keep code completely on-prem, self-deployment makes sense. Mistral publishes open-weight models under Apache 2.0 or Modified MIT licenses.

Comparisons with competitive models

Codestral-22B-v0.1 shows different performance trends depending on the benchmark. On HumanEval, it beats Llama 3 70B by 5.9%. On the MBPP benchmark, it remains slightly behind DeepSeek Coder 33B, which scores 80.2%. On CruxEval-O, it leads both DeepSeek Coder 33B and Llama 3 70B with a 51.3% pass rate. I find the model’s 32k context window smaller than frontier models like Claude. For autonomous multi-file refactoring, Claude Code remains the standard because Codestral scores in the low single digits on the SWE-Bench Pro benchmark.

Model HumanEval Pass Rate MBPP Success Rate Context Window
Codestral-22B 81.1% 78.2% 32k
CodeLlama 70B 67.1% 70.8% 4k
DeepSeek Coder 33B 77.4% 80.2% 16k
Llama 3 70B 76.2% 76.7% 8k

Complexity in Mistral’s billing streams

Mistral creates a tracking problem for finance teams because it uses three separate billing streams. The first stream involves self-hosting models like Mistral Small 4 on GPU instances, which results in a cloud compute line item on an AWS or GCP invoice. The second stream involves the la Plateforme API, which bills per token on a Mistral account. The third stream involves Le Chat Pro subscriptions, which arrive as a monthly SaaS charge. The word "Mistral" does not appear on all those invoices in a way that connects them. This makes attribution at the model level a necessity for teams managing multiple providers. FinOps teams face visibility challenges because AI costs are scattered across different dashboards. One report from the FinOps Foundation found that 78% of organizations cannot distinguish AI costs from general cloud spend. You should track your spend daily using the Mistral dashboard to avoid unexpected bills.