MLX
mlx-lm 是 Apple 的陣列運算框架指向語言模型的形態。在 M 系列 Mac 上它是最快的本機路徑,因為它用統一記憶體,不必和獨立顯卡搶資源。
mlx-lm 是 Apple 的陣列運算框架指向語言模型的形態。在 M 系列 Mac 上它是最快的本機路徑,因為它用統一記憶體,不必和獨立顯卡搶資源。
僅限 Apple Silicon。`mlx_lm.server --model mlx-community/Qwen3-8B-4bit` 會在 localhost:8080/v1 上提供 OpenAI 相容服務。上下文有多大,取決於你的統一記憶體。
- 最大上下文
- Whatever your unified memory allows
- 免費額度
- 無限且私密
- 註冊要求
- 什麼都不用 —— 無帳號
端點
基底網址
http://localhost:8080/v1速率限制
None — it is your machine- OpenAI 相容
- 官方 SDK:mlx-lm
- 文字
- 視覺
程式碼範例
npm install openaiimport OpenAI from 'openai'
const client = new OpenAI({
baseURL: 'http://localhost:8080/v1',
apiKey: 'not-needed'
})
const response = await client.chat.completions.create({
model: 'mlx-community/Qwen3-8B-4bit',
messages: [{ role: 'user', content: 'Explain closures in one paragraph.' }]
})
console.log(response.choices[0].message.content)pip install openaifrom openai import OpenAI
client = OpenAI(
base_url="http://localhost:8080/v1",
api_key="not-needed",
)
response = client.chat.completions.create(
model="mlx-community/Qwen3-8B-4bit",
messages=[{"role": "user", "content": "Explain closures in one paragraph."}],
)
print(response.choices[0].message.content)curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "mlx-community/Qwen3-8B-4bit",
"messages": [{"role": "user", "content": "Explain closures in one paragraph."}]
}'pip install mlx-lmfrom mlx_lm import load, generate
model, tokenizer = load("mlx-community/Qwen3-8B-4bit")
prompt = tokenizer.apply_chat_template(
[{"role": "user", "content": "Explain closures in one paragraph."}],
add_generation_prompt=True,
)
print(generate(model, tokenizer, prompt=prompt, max_tokens=512))值得注意
- 僅限 Apple Silicon。
- 先起伺服器:`mlx_lm.server --model mlx-community/Qwen3-8B-4bit`。
你能免費使用的模型3
- Qwen 3
qwen3 - Qwen Coder
Qwen2.5-Coder-7B - GPT-OSS 120B
gpt-oss-120b