LM Studio
Run local models with LM Studio in Agno agents.
LM Studio runs open-source models locally through a desktop app with an OpenAI-compatible local server.
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 offer strong performance at a small size.
Set up a model
Install LM Studio, download and load a model, then open Developer and start the API server on port 1234. Keep the server running while you run Python in a terminal.
Check the model list:
curl http://127.0.0.1:1234/v1/modelsSet LMStudio(id=...) in the example to the exact model id returned by your server. If you change the server port, set the matching base_url on LMStudio.
Example
After you have the model locally, use the LMStudio model class to access it. It uses the OpenAI client, so install the openai package:
uv pip install -U openai agnofrom agno.agent import Agent
from agno.models.lmstudio import LMStudio
agent = Agent(
model=LMStudio(id="qwen2.5-7b-instruct-1m"),
markdown=True
)
# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story.")Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | str | "qwen2.5-7b-instruct-1m" | 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] | "not-provided" | The API key for LMStudio (usually not needed for local) |
base_url | str | "http://127.0.0.1:1234/v1" | The base URL for the local LMStudio server |
LMStudio is a subclass of the OpenAILike class and has access to the same params.