Source URL: https://simonwillison.net/2025/May/29/llm-mistral-014/#atom-everything
Source: Simon Willison’s Weblog
Title: llm-mistral 0.14
Feedly Summary: llm-mistral 0.14
I added tool-support to my plugin for accessing the Mistral API from LLM today, plus support for Mistral’s new Codestral Embed embedding model.
An interesting challenge here is that I’m not using an official client library for llm-mistral – I rolled my own client on top of their streaming HTTP API using Florimond Manca’s httpx-sse library. It’s a very pleasant way to interact with streaming APIs – here’s my code that does most of the work.
The problem I faced is that Mistral’s API documentation for function calling has examples in Python and TypeScript but doesn’t include curl or direct documentation of their HTTP endpoints!
I needed documentation at the HTTP level. Could I maybe extract that directly from Mistral’s official Python library?
It turns out I could. I started by cloning the repo:
git clone https://github.com/mistralai/client-python
cd client-python/src/mistralai
files-to-prompt . | ttok
My ttok tool gave me a token count of 212,410 (counted using OpenAI’s tokenizer, but that’s normally a close enough estimate) – Mistral’s models tap out at 128,000 so I switched to Gemini 2.5 Flash which can easily handle that many.
I ran this:
files-to-prompt -c . > /tmp/mistral.txt
llm -f /tmp/mistral.txt \
-m gemini-2.5-flash-preview-05-20 \
-s ‘Generate comprehensive HTTP API documentation showing
how function calling works, include example curl commands for each step’
The results were pretty spectacular! Gemini 2.5 Flash produced a detailed description of the exact set of HTTP APIs I needed to interact with, and the JSON formats I should pass to them.
There are a bunch of steps needed to get tools working in a new model, as described in the LLM plugin authors documentation. I started working through them by hand… and then got lazy and decided to see if I could get a model to do the work for me.
This time I tried the new Claude Opus 4. I fed it three files: my existing, incomplete llm_mistral.py, a full copy of llm_gemini.py with its working tools implementation and a copy of the API docs Gemini had written for me earlier. I promped:
I need to update this Mistral code to add tool support. I’ve included examples of that code for Gemini, and a detailed README explaining the Mistral format.
Claude churned away and wrote me code that was most of what I needed. I tested it in a bunch of different scenarios, pasted problems back into Claude to see what would happen, and eventually took over and finished the rest of the code myself. Here’s the full transcript.
I’m a little sad I didn’t use Mistral to write the code to support Mistral, but I’m pleased to add yet another model family to the list that’s supported for tool usage in LLM.
Tags: gemini, llm, plugins, llm-tool-use, ai, llms, mistral, generative-ai, projects, ai-assisted-programming, claude, claude-4, httpx, python
AI Summary and Description: Yes
Summary: The text discusses developing a plugin for the Mistral API, highlighting the challenges of lacking comprehensive API documentation and the use of various AI models to generate necessary code and documentation. It exemplifies the integration of different AI technologies, which is relevant for those in the fields of AI and software security.
Detailed Description: The provided text showcases the author’s journey in enhancing a plugin for the Mistral API, reflecting several key themes pertinent to professionals in AI, cloud, and infrastructure security:
– **Tool Development and Integration**:
– The author created a plugin that interfaces with the Mistral API using a custom client built on top of their streaming HTTP API.
– Emphasizes the importance of robust client handling for effective API interactions.
– **Documentation Challenges**:
– The lack of adequate HTTP-level documentation from Mistral prompted the author to utilize other resources (like Mistral’s official Python library) to extract the necessary API details.
– Highlighting documentation issues reflects a common concern in API security and compliance, as inadequate documentation can lead to misuse and vulnerabilities.
– **Leveraging AI for Code Generation**:
– The author utilized AI models like Gemini 2.5 Flash and Claude Opus 4 to assist in generating API documentation and writing code.
– This interaction underscores the emerging role of generative AI in software development processes, enhancing the speed and efficiency of coding tasks.
– **Challenges in Model Utilization**:
– The author faced limitations with the token count in Mistral’s models, leading to a strategic switch to a more capable model.
– **Iterative Development Process**:
– The narrative showcases an iterative approach to development, where the author continually validates and tests generated code using AI, highlighting a trend towards more collaborative workflows between humans and AI.
Overall, this text illustrates the practical implications of generative AI in streamlining the development process, while also raising concerns about documentation and security in API interactions. Security professionals might note the impact of such processes on compliance and governance, as well as the ongoing dependency on AI tools for efficient software development.