> 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/jp/tong-he/connections/vllm.md).

# ローカルチャット推論のためにvLLMをUnslothに接続する

接続方法を学ぶ **vLLM に** [**Unsloth**](https://github.com/unslothai/unsloth) vLLM の **OpenAI互換API** オープンソースのUIチャットインターフェース内で、モデルを提供し、ローカルでそれらとチャットできるようにします。このガイドでは、vLLMのインストール、ローカルvLLMサーバーの起動、APIベースURLの設定、利用可能なモデルIDの読み込み、そしてホストしたvLLMモデルの選択までを順に説明します。

最終的に、vLLMで提供しているモデルがローカルモデルと並んで表示され、UIチャットインターフェースから外部LLM推論を高速かつ柔軟に実行できるようになります。

### セットアップ

{% stepper %}
{% step %}

#### vLLMをインストール

まず vLLM をインストールして、 `vllm serve` コマンドを実行できるようにします。公式の [vLLMインストールガイド](https://docs.vllm.ai/en/stable/getting_started/installation/) を、使用しているプラットフォームとハードウェアに合わせて確認してください。

インストール後、ターミナルで vLLM が動作することを確認します: `vllm --help`
{% endstep %}

{% step %}

#### モデルを選択

vLLM は Hugging Face のモデルを提供します。

たとえば、Unslothモデルを使って vLLM サーバーを起動します:

```bash
vllm serve unsloth/gemma-4-26B-A4B-it 
\ --dtype auto
```

これにより、次の API エンドポイントが公開されます：

`http://localhost:8000/v1`

APIキーを必須にするには、次を追加します：

```bash
--api-key token-abc123
```

{% endstep %}

{% step %}

#### vLLM を Unsloth に接続

開く **設定 → 接続**、次に **接続を追加**.

を選択 **vLLM**、その後サーバーの詳細を入力します。

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FN80ObNBvpN7hDypheYkt%2Fimage.png?alt=media&amp;token=481f4c1f-afb6-438d-ae35-85566f15e414" alt=""><figcaption></figcaption></figure>

vLLM サーバーの詳細を入力してください:

* **APIキー:** --api-key 付きで vLLM を起動しない限り空欄のままにしてください
* **ベースURL:** 例: <http://localhost:8000/v1>
* **推論モデル:** 提供中のモデルが思考をサポートしている場合はこれを有効にしてください
* **モデルID:** クリック **モデルを読み込む**、またはカスタムIDを手動で入力します

をクリックすると、 **接続を追加**有効にしたモデルが **接続** モデルのドロップダウンに表示されます。
{% endstep %}

{% step %}

#### チャット準備完了

接続を保存すると、vLLM モデルが **接続済み** モデルのドロップダウンに表示されます。選択すると、vLLM サーバー経由でチャットを開始できます。

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FpoXSmL3PcpprEy8CIT7S%2Fexport-1779046578662.gif?alt=media&amp;token=acf1de86-6fa4-466f-97f7-2d91662a124e" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
vLLM サーバーの応答が遅い場合（特にモデルの読み込み中）は、タイムアウトを調整できます:

```bash
AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST=30
```

{% endhint %}
{% endstep %}
{% endstepper %}

### 一般的な vLLM 引数

上の例では、基本的なサービング設定を使用しています。モデルやハードウェアに応じて、さらに vllm serve 引数を追加できます。

一般的なオプションには次があります：

```bash
vllm serve unsloth/gemma-4-26B-A4B-it \
  --dtype auto \
  --host 0.0.0.0 \\
  --port 8000 \
  --api-key token-abc123 \
  --max-model-len 8192 \
  --gpu-memory-utilization 0.9
```

vLLM サーバー引数の全一覧については、公式の vLLM [OpenAI互換サーバー](https://docs.vllm.ai/en/stable/serving/openai_compatible_server/) ドキュメントを参照してください。


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://unsloth.ai/docs/jp/tong-he/connections/vllm.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
