Use MLX in Strands Agents
Project description
strands-mlx
Run and train AI agents locally on Apple Silicon
MLX model provider for Strands Agents - inference, tool calling, and LoRA fine-tuning.
Installation
Requirements: Python ≤3.13, macOS/Linux
Quick install with uv (recommended):
uv venv --python 3.13 && source .venv/bin/activate && uv pip install strands-agents strands-agents-tools strands-mlx
Or with pip:
pip install strands-mlx
Quick Start
from strands import Agent
from strands_mlx import MLXModel
from strands_tools import calculator # pip install strands-agents-tools
model = MLXModel(model_id="mlx-community/Qwen3-1.7B-4bit")
agent = Agent(model=model, tools=[calculator])
agent("What is 29 * 42?")
Dynamic Model Invocation
mlx_invoke - Call MLX models as tools with custom configs:
from strands import Agent
from strands_mlx import mlx_invoke
agent = Agent(tools=[mlx_invoke])
# Agent can invoke different MLX models dynamically
agent("Use mlx_invoke to ask Qwen3-1.7B to calculate 29 * 42 with calculator")
# Direct tool call with custom parameters
agent.tool.mlx_invoke(
prompt="Explain quantum computing",
system_prompt="You are a physics expert.",
model_id="mlx-community/Qwen3-1.7B-4bit",
params={"temperature": 0.7, "max_tokens": 2000},
tools=["calculator"]
)
Training Workflow
1. Collect → 2. Train → 3. Deploy
from strands import Agent
from strands_mlx import MLXModel, MLXSessionManager, mlx_trainer
# 1. Collect training data (auto-exports to JSONL)
model = MLXModel(model_id="mlx-community/Qwen3-1.7B-4bit")
session = MLXSessionManager(session_id="my_training_data")
agent = Agent(model=model, session_manager=session)
agent("teach me about neural networks")
agent("how does backpropagation work?")
# Saved to: ~/.strands/mlx_training_data/my_training_data.jsonl
# 2. Train with LoRA
mlx_trainer(
action="train",
model="mlx-community/Qwen3-1.7B-4bit",
data="~/.strands/mlx_training_data/my_training_data.jsonl",
adapter_path="./trained_adapter",
iters=1000
)
# 3. Deploy trained model
trained = MLXModel(model_id="mlx-community/Qwen3-1.7B-4bit", adapter_path="./trained_adapter")
agent = Agent(model=trained)
Features
- Local inference - Run on Apple Silicon with unified memory
- Tool calling - Native Strands tools support
- Streaming - Token-by-token generation
- Dynamic invocation - mlx_invoke tool for runtime model switching
- Training pipeline - Conversation → JSONL → LoRA → Deploy
- 1000+ models - mlx-community quantized models (4-bit, 8-bit)
Configuration
Model:
model = MLXModel(model_id="mlx-community/Qwen3-1.7B-4bit", adapter_path="./adapters")
model.update_config(params={"temperature": 0.7, "max_tokens": 2000})
Training:
mlx_trainer(
action="train",
model="...",
data="path.jsonl",
adapter_path="./adapters",
batch_size=4,
iters=1000,
learning_rate=1e-5,
lora_rank=8
)
Development
git clone https://github.com/cagataycali/strands-mlx.git
cd strands-mlx
pip install -e ".[dev]"
python3 test.py
Resources
- Strands Agents
- MLX by Apple ML Research
- mlx-community models
Citation
@software{strands_mlx2025,
author = {Cagatay Cali},
title = {strands-mlx: MLX Model Provider for Strands Agents},
year = {2025},
url = {https://github.com/cagataycali/strands-mlx}
}
Apache 2 License | Built with MLX, MLX-LM, and Strands Agents
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file strands_mlx-0.1.1.tar.gz.
File metadata
- Download URL: strands_mlx-0.1.1.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e38177bf732333c6db3cb34769b85e7482215960de21a3557bc15c4cd6b08ab6
|
|
| MD5 |
9a1e07bdfc9009575876a361688c0de7
|
|
| BLAKE2b-256 |
16f42f5ff1f60f9e9b96e5a4b0660e1002b1551ec89ca6a94b19b7ad107ef432
|
File details
Details for the file strands_mlx-0.1.1-py3-none-any.whl.
File metadata
- Download URL: strands_mlx-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a210ca941810f66fe272b6624a8452e82e8ddcdbd874a81abaf7383ca6bce5ef
|
|
| MD5 |
6be9a3127f600e6e21bf5abac071760f
|
|
| BLAKE2b-256 |
6efe6f2ee1a520fc2d60bf30cd438ee325b10aa11bf995144a7188d69f737223
|