vllm/docs/serving/integrations/langchain.md
Harry Mellor b942c094e3
Stop using title frontmatter and fix doc that can only be reached by search (#20623)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
2025-07-08 03:27:40 -07:00

788 B

LangChain

vLLM is also available via LangChain .

To install LangChain, run

pip install langchain langchain_community -q

To run inference on a single or multiple GPUs, use VLLM class from langchain.

??? code

```python
from langchain_community.llms import VLLM

llm = VLLM(model="mosaicml/mpt-7b",
        trust_remote_code=True,  # mandatory for hf models
        max_new_tokens=128,
        top_k=10,
        top_p=0.95,
        temperature=0.8,
        # tensor_parallel_size=... # for distributed inference
)

print(llm("What is the capital of France ?"))
```

Please refer to this Tutorial for more details.