lm studio 部署

无界面部署

# 安装 lms
curl -fsSL https://lmstudio.ai/install.sh | bash

# 下载模型 https://lmstudio.ai/models/qwen3.6
lms get qwen/qwen3.6-35b-a3b

# 列出模型
lms ls   

# 加载模型 : 设置别名, 上下文大小
lms load qwen/qwen3.6-35b-a3b --gpu=max --identifier="qwen36" --context-length 8192

# 启动服务
lms server start --bind 0.0.0.0 --port 1234 --cors

# 停止服务
lms server stop

然后就可以在 http://*:1234 调用接口了

测试代码

from anthropic import Anthropic

# LM Studio: SDK 会自动追加 /v1/messages
client = Anthropic(
    base_url="http://localhost:1234",
    api_key="lmstudio",
)

try:
    message = client.messages.create(
        max_tokens=1024,
        messages=[
            {"role": "user", "content": "Hello from LM Studio"}
        ],
        model="qwen36" # "qwen36", // qwen/qwen3.6-35b-a3b
    )
    # 解析响应内容
    for block in message.content:
        if block.type == "text":
            print(block.text)
except Exception as e:
    print(f"Error: {type(e).__name__}: {e}")
Logo

免费领 150 小时云算力,进群参与显卡、AI PC 幸运抽奖

更多推荐