Devstral is an agentic LLM for software engineering tasks built under a collaboration between Mistral AI and All Hands AI 🙌. Devstral excels at using tools to explore codebases, editing multiple files and power software engineering agents. The model achieves remarkable performance on SWE-bench which positionates it as the #1 open source model on this benchmark.
It is finetuned from Mistral-Small-3.1, therefore it has a long context window of up to 128k tokens. As a coding agent, Devstral is text-only and before fine-tuning from Mistral-Small-3.1 the vision encoder was removed.
For enterprises requiring specialized capabilities (increased context, domain-specific knowledge, etc.), we will release commercial models beyond what Mistral AI contributes to the community.
Agentic coding: Devstral is designed to excel at agentic coding tasks, making it a great choice for software engineering agents.
lightweight: with its compact size of just 24 billion parameters, Devstral is light enough to run on a single RTX 4090 or a Mac with 32GB RAM, making it an appropriate model for local deployment and on-device use.
Apache 2.0 License: Open license allowing usage and modification for both commercial and non-commercial purposes.
Context Window: A 128k context window.
Tokenizer: Utilizes a Tekken tokenizer with a 131k vocabulary size.
Benchmark Results
SWE-Bench
Devstral achieves a score of 46.8% on SWE-Bench Verified, outperforming prior open-source SoTA by 6%.
Model
Scaffold
SWE-Bench Verified (%)
Devstral
OpenHands Scaffold
46.8
GPT-4.1-mini
OpenAI Scaffold
23.6
Claude 3.5 Haiku
Anthropic Scaffold
40.6
SWE-smith-LM 32B
SWE-agent Scaffold
40.2
When evaluated under the same test scaffold (OpenHands, provided by All Hands AI 🙌), Devstral exceeds far larger models such as Deepseek-V3-0324 and Qwen3 232B-A22B.
SWE Benchmark
Usage
We recommend to use Devstral with the OpenHands scaffold.
You can use it either through our API or by running locally.
API
Follow these instructions to create a Mistral account and get an API key.
Then run these commands to start the OpenHands docker container.
The server will start at http://0.0.0.0:3000. Open it in your browser and you will see a tab AI Provider Configuration.
Now you can start a new conversation with the agent by clicking on the plus sign on the left bar.
The model can also be deployed with the following libraries:
Make sure you launched an OpenAI-compatible server such as vLLM or Ollama as described above. Then, you can use OpenHands to interact with Devstral-Small-2505.
In the case of the tutorial we spineed up a vLLM server running the command:
Then, you can access the OpenHands UI at http://localhost:3000.
Connect to the server
When accessing the OpenHands UI, you will be prompted to connect to a server. You can use the advanced mode to connect to the server you launched earlier.
API Key: token (or any other token you used to launch the server if any)
Use OpenHands powered by Devstral
Now you're good to use Devstral Small inside OpenHands by starting a new conversation. Let's build a To-Do list app.
To-Do list app
Let's ask Devstral to generate the app with the following prompt:
txt
1Build a To-Do list app with the following requirements:
2- Built using FastAPI and React.
3- Make it a one page app that:
4 - Allows to add a task.
5 - Allows to delete a task.
6 - Allows to mark a task as done.
7 - Displays the list of tasks.
8- Store the tasks in a SQLite database.
Agent prompting
Let's see the result
You should see the agent construct the app and be able to explore the code it generated.
If it doesn't do it automatically, ask Devstral to deploy the app or do it manually, and then go the front URL deployment to see the app.
Agent working
App UI
Iterate
Now that you have a first result you can iterate on it by asking your agent to improve it. For example, in the app generated we could click on a task to mark it checked but having a checkbox would improve UX. You could also ask it to add a feature to edit a task, or to add a feature to filter the tasks by status.
In a bash terminal, run lms import devstralQ4_K_M.ggu in the directory where you've downloaded the model checkpoint (e.g. mistralai/Devstral-Small-2505_gguf)
Open the LMStudio application, click the terminal icon to get into the developer tab. Click select a model to load and select Devstral Q4 K M. Toggle the status button to start the model, in setting oggle Serve on Local Network to be on.
On the right tab, you will see an API identifier which should be devstralq4_k_m and an api address under API Usage. Keep note of this address, we will use it in the next step.
Launch Openhands
You can now interact with the model served from LM Studio with openhands. Start the openhands server with the docker
Click “see advanced setting” on the second line.
In the new tab, toggle advanced to on. Set the custom model to be mistral/devstralq4_k_m and Base URL the api address we get from the last step in LM Studio. Set API Key to dummy. Click save changes.
vLLM (recommended)
We recommend using this model with the vLLM library
to implement production-ready inference pipelines.
To ping the client you can use a simple Python snippet.
py
1import requests
2import json
3from huggingface_hub import hf_hub_download
456url ="http://<your-server-url>:8000/v1/chat/completions"7headers ={"Content-Type":"application/json","Authorization":"Bearer token"}89model ="mistralai/Devstral-Small-2505"1011defload_system_prompt(repo_id:str, filename:str)->str:12 file_path = hf_hub_download(repo_id=repo_id, filename=filename)13withopen(file_path,"r")asfile:14 system_prompt =file.read()15return system_prompt
1617SYSTEM_PROMPT = load_system_prompt(model,"SYSTEM_PROMPT.txt")1819messages =[20{"role":"system","content": SYSTEM_PROMPT},21{22"role":"user",23"content":[24{25"type":"text",26"text":"Write a function that computes fibonacci in Python.",27},28],29},30]3132data ={"model": model,"messages": messages,"temperature":0.15}3334response = requests.post(url, headers=headers, data=json.dumps(data))35print(response.json()["choices"][0]["message"]["content"])
Output
Certainly! The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. Here's a simple Python function to compute the Fibonacci sequence:
Iterative Approach
This approach uses a loop to compute the Fibonacci number iteratively.
python
1deffibonacci(n):2if n <=0:3return"Input should be a positive integer."4elif n ==1:5return06elif n ==2:7return189 a, b =0,110for _ inrange(2, n):11 a, b = b, a + b
12return b
1314# Example usage:15print(fibonacci(10))# Output: 34
Recursive Approach
This approach uses recursion to compute the Fibonacci number. Note that this is less efficient for large n due to repeated calculations.
python
1deffibonacci_recursive(n):2if n <=0:3return"Input should be a positive integer."4elif n ==1:5return06elif n ==2:7return18else:9return fibonacci_recursive(n -1)+ fibonacci_recursive(n -2)1011# Example usage:12print(fibonacci_recursive(10))# Output: 34
### Memoization Approach
This approach uses memoization to store previously computed Fibonacci numbers, making it more efficient than the simple recursive approach.
python
1deffibonacci_memo(n, memo={}):2if n <=0:3return"Input should be a positive integer."4elif n ==1:5return06elif n ==2:7return18elif n in memo:9return memo[n]1011 memo[n]= fibonacci_memo(n -1, memo)+ fibonacci_memo(n -2, memo)12return memo[n]1314# Example usage:15print(fibonacci_memo(10))# Output: 34
### Dynamic Programming Approach
This approach uses an array to store the Fibonacci numbers up to n.
python
1deffibonacci_dp(n):2if n <=0:3return"Input should be a positive integer."4elif n ==1:5return06elif n ==2:7return189 fib =[0,1]+[0]*(n -2)10for i inrange(2, n):11 fib[i]= fib[i -1]+ fib[i -2]12return fib[n -1]1314# Example usage:15print(fibonacci_dp(10))# Output: 34
You can choose any of these approaches based on your needs. The iterative and dynamic programming approaches are generally more efficient for larger values of n.
Mistral-inference
We recommend using mistral-inference to quickly try out / "vibe-check" Devstral.
Install
Make sure to have mistral_inference >= 1.6.0 installed.
If you prompt it with "Write me a unique and efficient function that computes fibonacci in Python", the model should generate something along the following lines:
Output
Certainly! A common and efficient way to compute Fibonacci numbers is by using memoization to store previously computed values. This avoids redundant calculations and significantly improves performance. Below is a Python function that uses memoization to compute Fibonacci numbers efficiently:
python
1deffibonacci(n, memo=None):2if memo isNone:3 memo ={}45if n in memo:6return memo[n]78if n <=1:9return n
1011 memo[n]= fibonacci(n -1, memo)+ fibonacci(n -2, memo)12return memo[n]1314# Example usage:15n =1016print(f"Fibonacci number at position {n} is {fibonacci(n)}")
Explanation:
Base Case: If n is 0 or 1, the function returns n because the Fibonacci sequence starts with 0 and 1.
Memoization: The function uses a dictionary memo to store the results of previously computed Fibonacci numbers.
Recursive Case: For other values of n, the function recursively computes the Fibonacci number by summing the results of fibonacci(n - 1) and fibonacci(n)