Agent Skills › ddalcu/mlx-serve › mlx-serve

mlx-serve

GitHub

集成mlx-serve本地LLM服务,支持聊天、图像、音视频及3D生成。提供连接配置、模型管理及内存控制指南,适用于Mac端本地AI应用开发。

skills/mlx-serve/SKILL.md ddalcu/mlx-serve

触发场景

需要调用本地MLX服务进行文本或媒体生成 查询mlx-serve的API接口与模型状态

安装

npx skills add ddalcu/mlx-serve --skill mlx-serve -g -y
更多选项

不安装直接使用

npx skills use ddalcu/mlx-serve@mlx-serve

指定 Agent (Claude Code)

npx skills add ddalcu/mlx-serve --skill mlx-serve -a claude-code -g -y

安装 repo 全部 skill

npx skills add ddalcu/mlx-serve --all -g -y

预览 repo 内 skill

npx skills add ddalcu/mlx-serve --list

SKILL.md

Frontmatter
{
    "name": "mlx-serve",
    "description": "Hook an app, game or script up to the local mlx-serve server for LLM chat, embeddings, image, speech, music, sound effect, video and 3D generation, and Laya\/Kev\/Clef typed decisions, or make a whole film or music video on this Mac. Use when code should call mlx-serve or the user wants a video, song, pictures or game assets made locally."
}

mlx-serve

mlx-serve runs MLX models on this Mac behind one HTTP port: OpenAI, Anthropic and Ollama compatible chat, plus native endpoints for images, speech, music, sound effects, video, 3D and decisions. Everything below is plain HTTP + JSON, so any language works.

Connect

  • Base URL: $MLX_SERVE_URL when set, else http://127.0.0.1:11234. Make it a config value or env var in the code you write, never a hardcoded LAN IP.
  • Auth: none from this Mac. A server started with --api-key wants Authorization: Bearer <key> from other machines; a 401 means that.
  • CORS is open (Access-Control-Allow-Origin: *): a browser game can call it directly.
  • Up? curl -s "$MLX_SERVE_URL/health"

Pick models from /v1/models, never guess ids

curl -s "${MLX_SERVE_URL:-http://127.0.0.1:11234}/v1/models" \
  | jq -r '.data[] | "\(.id)\t\(.capabilities | join(","))\t\(.state)"'

Each row has id (like org/name), capabilities, state (ready, unloaded, remote) and context_length. Choose by capability:

capability endpoint details
chat POST /v1/chat/completions (also /v1/messages, /v1/responses) chat.md
embeddings POST /v1/embeddings chat.md
image POST /v1/images/generations, POST /v1/images/edits media.md
audio without music or sound POST /v1/audio/speech (TTS) media.md
music POST /v1/audio/music-generations media.md
sound POST /v1/audio/sound-generations (sound effects) media.md
transcription POST /v1/audio/transcriptions (speech to text, word times, subtitles) media.md
video POST /v1/video/generations media.md
3d POST /v1/3d/generations media.md
decisions POST /v1/decisions, POST /v1/systemone decisions.md

Read the linked file (next to this one) before writing client code for that endpoint. If no model has the capability the user needs, say so and tell them to download one in the MLX Core app (Models). Do not invent an id.

Loading and memory

  • Any request names its model with "model": "<id>". An unloaded model loads on the first request, which can take seconds to minutes. POST /v1/load-model {"model": "<id>"} pre-warms one; POST /v1/unload-model {"model": "<id>"} frees it. While a load runs, GET /v1/load-progress lists each loading model's phase, done/total and eta_s.
  • All models share one GPU memory budget. A 503 out_of_memory means unload something first (typically the media model when you are done with it).
  • Generation runs on one inference thread: a 3-minute video render stalls chat replies for 3 minutes. Decisions and embeddings are milliseconds.

Films and music videos

Making a video (music video, trailer, release or story film)? Read film.md first: a YuE2 song is the spine, gen.mjs makes the pictures, clips and sound effects, and film.mjs (Node 18+) times every cut to the sung words and renders it.

Rules for apps and games

  • Building a 3D game or scene? Read games.md first: movement, foliage and lighting rules, and gen.mjs (next to this file, Node 18+), which generates and post-processes every asset from one assets.json (node gen.mjs help).
  • Generate media AHEAD of time or in the background, never on the frame or input path. Cache results on disk keyed by model + prompt + seed + size, and ship the cache (or regenerate lazily) instead of calling on every run.
  • Rough cost on Apple Silicon: image 5-60 s, speech about real time or faster, sound effects about a second, music 30 s to minutes, 3D 1-5 min, video minutes. Set client timeouts to match (10+ minutes for video), and keep the game playable while waiting.
  • Send "seed" for reproducible assets.
  • Long jobs: send "stream": true and read the SSE progress events to drive a progress bar. See media.md.
  • Errors are JSON: {"error": {"message": "..."}} with a 4xx/5xx status. The message names the bad field. Show it; never retry a 400 unchanged.
  • Keep the server's own URL and model ids in one config module so the user can swap models without touching game code.

Smoke test

BASE="${MLX_SERVE_URL:-http://127.0.0.1:11234}"
IMG=$(curl -s "$BASE/v1/models" | jq -r '[.data[] | select(.capabilities | index("image"))][0].id')
curl -s "$BASE/v1/images/generations" -H 'content-type: application/json' \
  -d "{\"model\":\"$IMG\",\"prompt\":\"pixel art treasure chest on a plain white background\",\"size\":\"512x512\",\"seed\":7}" \
  | jq -r '.data[0].b64_json' | base64 -d > chest.png

版本历史

  • 64b6e53 当前 2026-10-18 17:43

    新增Neural Engine引擎支持及模型加载进度监控功能

  • d500d42 2026-09-27 11:57

同 Skill 集合

.claude/skills/bench/SKILL.md
.claude/skills/pr-charts/SKILL.md
.claude/skills/release/SKILL.md

元信息

文件数
0
版本
64b6e53
Hash
4401559a
收录时间
2026-09-27 11:57

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-18 18:13
浙ICP备14020137号-1