ドキュメント
インテグレーション
Model Context Protocol (MCP)
モデル (model.yaml)
インテグレーション
Model Context Protocol (MCP)
モデル (model.yaml)
API
OpenAI互換API
Chat Completions (テキストおよび画像)、Completions、Embeddings エンドポイントへのリクエストを送信
Chat Completions (テキストおよび画像)、Completions、Embeddings エンドポイントへのリクエストを送信。
LM Studio は、いくつかの OpenAI エンドポイントでリクエストを受け付け、OpenAI ライクなレスポンスオブジェクトを返します。
GET /v1/models POST /v1/chat/completions POST /v1/embeddings POST /v1/completions
既存の OpenAI クライアント (Python, JS, C# など) の "base URL" プロパティを LM Studio にポイントするように変更することで、再利用できます。
base url を変更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 }'
/v1/modelsGET リクエストcurl https://:1234/v1/models
/v1/chat/completionsPOST リクエストlms log stream を開いたターミナルウィンドウを置いておいてください。# Example: reuse your existing OpenAI setup from openai import OpenAI # Point to the local server client = OpenAI(base_url="https://:1234/v1", api_key="lm-studio") completion = client.chat.completions.create( model="model-identifier", messages=[ {"role": "system", "content": "Always answer in rhymes."}, {"role": "user", "content": "Introduce yourself."} ], temperature=0.7, ) print(completion.choices[0].message)
/v1/embeddingsPOST リクエスト# Make sure to `pip install openai` first from openai import OpenAI client = OpenAI(base_url="https://:1234/v1", api_key="lm-studio") def get_embedding(text, model="model-identifier"): text = text.replace("\n", " ") return client.embeddings.create(input = [text], model=model).data[0].embedding print(get_embedding("Once upon a time, there was a cat."))
/v1/completionsこの OpenAI ライクなエンドポイントは、OpenAI によってサポートされなくなりました。LM Studio は引き続きサポートしています。
チャットチューニングされたモデルでこのエンドポイントを使用すると、モデルによって余分なロール トークンが出力されるなど、予期しない動作が発生する可能性があります。
最良の結果を得るために、ベースモデルを使用してください。
POST リクエストlms log stream を開いたターミナルウィンドウを置いておいてください。各パラメータの説明については、https://platform.openai.com/docs/api-reference/chat/create を参照してください。
model top_p top_k messages temperature max_tokens stream stop presence_penalty frequency_penalty logit_bias repeat_penalty seed
LM Studio Discord サーバーで、他の LM Studio 開発者とチャットしたり、LLM、ハードウェアなどについて話し合ったりしましょう。LM Studio Discord サーバー。
このページのソースは GitHub で入手できます。
このページについて
OpenAIライクなAPIエンドポイント
- サポートされているエンドポイント
既存の OpenAI クライアントの再利用
- LM Studio を指すように base url を変更
エンドポイントの概要
- /v1/models
- /v1/chat/completions
- /v1/embeddings
- /v1/completions
サポートされているペイロードパラメータ
コミュニティ