Skip to main content
LM Studio provides a desktop app for running models locally with a simple interface. Great for development and testing.
from agno.agent import Agent
from agno.models.lmstudio import LMStudio

agent = Agent(
    model=LMStudio(id="qwen2.5-7b-instruct-1m"),
    markdown=True,
)

agent.print_response("Explain machine learning", stream=True)

Tool Use

from agno.agent import Agent
from agno.models.lmstudio import LMStudio
from agno.tools.websearch import WebSearchTools

agent = Agent(
    model=LMStudio(id="qwen2.5-7b-instruct-1m"),
    tools=[WebSearchTools()],
    markdown=True,
)

agent.print_response("What's happening in France?", stream=True)

Vision

import httpx
from agno.agent import Agent
from agno.media import Image
from agno.models.lmstudio import LMStudio

agent = Agent(
    model=LMStudio(id="llama3.2-vision"),
    markdown=True,
)

response = httpx.get("https://example.com/image.jpg")
agent.print_response(
    "Tell me about this image",
    images=[Image(content=response.content)],
    stream=True,
)

Structured Output

from pydantic import BaseModel, Field
from agno.agent import Agent
from agno.models.lmstudio import LMStudio

class Analysis(BaseModel):
    summary: str = Field(..., description="Brief summary")
    findings: list[str] = Field(..., description="Key findings")

agent = Agent(
    model=LMStudio(id="qwen2.5-7b-instruct-1m"),
    output_schema=Analysis,
)

agent.print_response("Analyze the impact of remote work")

Run Examples

# Start LM Studio and load a model through the UI
# The server runs on localhost:1234 by default

git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/92_models/lmstudio

python basic.py
python tool_use.py