LM Studio
Run local models with LM Studio in Kern agents.
Run Large Language Models locally with LM Studio
LM Studio is a fantastic tool for running models locally.
LM Studio supports multiple open-source models. See the library here.
We recommend experimenting to find the best-suited model for your use-case. Here are some general recommendations:
llama3.3models are good for most basic use-cases.qwenmodels perform specifically well with tool use.deepseek-r1models have strong reasoning capabilities.phi4models are powerful, while being really small in size.
Set up a model
Install LM Studio, download the model you want to use, and run it.
Example
After you have the model locally, use the LM Studio model class to access it
1from kern.agent import Agent2from kern.models.lmstudio import LMStudio34agent = Agent(5 model=LMStudio(id="qwen2.5-7b-instruct-1m"),6 markdown=True7)89# Print the response in the terminal10agent.print_response("Share a 2 sentence horror story.")Note View more examples here.
Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | str | "lmstudio-community/Meta-Llama-3-8B-Instruct-GGUF" | The id of the LMStudio model to use |
name | str | "LMStudio" | The name of the model |
provider | str | "LMStudio" | The provider of the model |
api_key | Optional[str] | None | The API key for LMStudio (usually not needed for local) |
base_url | str | "http://localhost:1234/v1" | The base URL for the local LMStudio server |
LM Studio also supports the params of OpenAI.