Basic Agent

Run a basic agent against a local LM Studio model and print the markdown response.

Code

from agno.agent import Agent, RunOutput  # noqa
from agno.models.lmstudio import LMStudio

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

# Get the response in a variable
# run: RunOutput = agent.run("Share a 2 sentence horror story")
# print(run.content)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story")

Usage

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Start the LM Studio API server

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/models

Set 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.

Install dependencies

uv pip install -U openai agno

Run Agent

Save the code above as basic.py, then run:

python basic.py