> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/fr/notions-de-base/inference-and-deployment/llama-server-and-openai-endpoint.md).

# Guide de déploiement de llama-server et du point de terminaison OpenAI

Nous allons déployer Devstral-2 - voir [Devstral 2](/docs/fr/modeles/tutorials/devstral-2.md) pour plus de détails sur le modèle.&#x20;

Obtenez le dernier `llama.cpp` par défaut. Seule votre machine peut atteindre le serveur. [GitHub ici](https://github.com/ggml-org/llama.cpp). Vous pouvez également suivre les instructions de compilation ci-dessous. Modifiez `-DGGML_CUDA=ON` à `-DGGML_CUDA=OFF` si vous n’avez pas de GPU ou si vous voulez simplement une inférence CPU. **Pour les appareils Apple Mac / Metal**, définissez `-DGGML_CUDA=OFF` puis continuez comme d’habitude - la prise en charge Metal est activée par défaut.

{% code overflow="wrap" %}

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-mtmd-cli llama-server llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

{% endcode %}

{% hint style="info" %}
Lors de l’utilisation de `--jinja` llama-server ajoute le message système suivant si les outils sont pris en charge : `Répondez au format JSON, soit avec tool_call (une demande d’appel d’outils), soit avec une réponse à la demande de l’utilisateur` . Cela cause parfois des problèmes avec les fine-tunes ! Voir le [dépôt llama.cpp](https://github.com/ggml-org/llama.cpp/blob/12ee1763a6f6130ce820a366d220bbadff54b818/common/chat.cpp#L849) pour plus de détails.
{% endhint %}

Commencez par télécharger Devstral 2 :

{% code overflow="wrap" %}

```python
# !pip install huggingface_hub hf_transfer
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id = "unsloth/Devstral-2-123B-Instruct-2512-GGUF",
    local_dir = "Devstral-2-123B-Instruct-2512-GGUF",
    allow_patterns = ["*UD-Q2_K_XL*", "*mmproj-F16*"],
)
```

{% endcode %}

Pour déployer Devstral 2 en production, nous utilisons `llama-server` Dans un nouveau terminal, par exemple via tmux, déployez le modèle via :

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-server \
    --model Devstral-Small-2-24B-Instruct-2512-GGUF/Devstral-Small-2-24B-Instruct-2512-UD-Q4_K_XL.gguf \
    --mmproj Devstral-Small-2-24B-Instruct-2512-GGUF/mmproj-F16.gguf \
    --alias "unsloth/Devstral-Small-2-24B-Instruct-2512" \
    --threads -1 \\
    --n-gpu-layers 999 \
    --prio 3 \
    --min-p 0.01 \\
    --ctx-size 16384 \
    --port 8001 \
    --jinja
```

{% endcode %}

Lorsque vous exécutez la commande ci-dessus, vous obtiendrez :

<figure><img src="/files/c00594641705f106a55423340c78b87cddaf654d" alt=""><figcaption></figcaption></figure>

Puis dans un nouveau terminal, après avoir fait `pip install openai`, faites :

{% code overflow="wrap" %}

```python
from openai import OpenAI
import json
openai_client = OpenAI(
    base_url = "http://127.0.0.1:8001/v1",
    api_key = "sk-no-key-required",
)
completion = openai_client.chat.completions.create(
    model = "unsloth/Devstral-Small-2-24B-Instruct-2512",
    messages = [{"role": "user", "content": "What is 2+2?"},],
)
print(completion.choices[0].message.content)
```

{% endcode %}

Ce qui affichera simplement 4.\
\
Vous pouvez revenir à l’écran de llama-server et vous pourriez voir quelques statistiques qui pourraient être intéressantes :

<figure><img src="/files/dde5fe516edf5811b4d9e6c645bd6824a3d0b4ac" alt=""><figcaption></figcaption></figure>

Pour des arguments comme l’utilisation du décodage spéculatif, voir <https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md>

## :grey\_question:Particularités de Llama-server

* Lors de l’utilisation de `--jinja` llama-server ajoute le message système suivant si les outils sont pris en charge : `Répondez au format JSON, soit avec tool_call (une demande d’appel d’outils), soit avec une réponse à la demande de l’utilisateur` . Cela cause parfois des problèmes avec les fine-tunes ! Voir le [dépôt llama.cpp](https://github.com/ggml-org/llama.cpp/blob/12ee1763a6f6130ce820a366d220bbadff54b818/common/chat.cpp#L849) pour plus de détails.\
  \
  Vous pouvez arrêter cela en utilisant `--no-jinja` mais alors `/ Anthropic` devient non pris en charge.\
  \
  Par exemple, FunctionGemma utilise par défaut :

  <pre class="language-notebook-python" data-overflow="wrap"><code class="lang-notebook-python">Vous êtes un modèle capable d’effectuer des appels de fonctions avec les fonctions suivantes
  </code></pre>

  Mais à cause du message supplémentaire ajouté par llama-server, nous obtenons :

  <pre class="language-notebook-python" data-overflow="wrap"><code class="lang-notebook-python">Vous êtes un modèle capable d’effectuer des appels de fonctions avec les fonctions suivantes\n\nRépondez au format JSON, soit avec `tool_call` (une demande d’appel d’outils), soit avec `response`, une réponse à la demande de l’utilisateur
  </code></pre>

  Nous avons signalé le problème à <https://github.com/ggml-org/llama.cpp/issues/18323> et les développeurs de llama.cpp travaillent sur un correctif !\
  \
  En attendant, pour tous les fine-tunes, veuillez ajouter spécifiquement le prompt pour l’appel d’outils !

## :toolbox:Appel d’outils avec llama-server

Voir [Tool Calling Guide](/docs/fr/notions-de-base/tool-calling-guide-for-local-llms.md) sur la manière de faire des appels d’outils !


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://unsloth.ai/docs/fr/notions-de-base/inference-and-deployment/llama-server-and-openai-endpoint.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
