文档
| 端点 | 方法 | 文档 |
|---|---|---|
/v1/models | GET | 模型 |
/v1/responses | POST | 响应 |
/v1/chat/completions | POST | 对话补全 |
/v1/embeddings | POST | 嵌入 (Embeddings) |
/v1/completions | POST | Completions (补全) |
base url 以指向 LM Studio你可以通过修改 "base URL" 属性使其指向你的 LM Studio 而非 OpenAI 服务器,从而重用现有的 OpenAI 客户端(Python、JS、C# 等)。
注意:以下示例假设服务器端口为 1234
from openai import OpenAI client = OpenAI( + base_url="https://:1234/v1" ) # ... the rest of your code ...
import OpenAI from 'openai'; const client = new OpenAI({ + baseUrl: "https://:1234/v1" }); // ... the rest of your code ...
- curl https://api.openai.com/v1/chat/completions \ + curl https://:1234/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ - "model": "gpt-4o-mini", + "model": "use the model identifier from LM Studio here", "messages": [{"role": "user", "content": "Say this is a test!"}], "temperature": 0.7 }'
Codex 得到支持,因为 LM Studio 实现了兼容 OpenAI 的 POST /v1/responses 端点。
参见:在 LM Studio 中使用 Codex 和 Responses。
其他 OpenAI 客户端库也应具有类似的设置 base URL 的选项。
如果您遇到问题,请加入我们的 Discord 并进入 #🔨-developers 频道。
此页面的源代码可在 GitHub 上找到
本页内容
支持的端点
设置 base url 以指向 LM Studio
Python 示例
Typescript 示例
cURL 示例
在 LM Studio 中使用 Codex