Chat Completions
The chat completion endpoint is OpenAI-compatible, making it easy to build applications on top of it or migrate existing ones with minimal effort.
Use the chat completion endpoint to extract information from a given project and build integrations on top of it.
Endpoint
First grab the base URL by copying and pasting the following command to your terminal:
slp status
This will return a table listing model size, context, project, etc. for the device:
| Property | Value |
|---|---|
| Server | http://127.0.0.1:38540 |
| GPU | Apple Silicon (MPS) |
| Active project | general_chat (id=533338cf-5980-4f6a-aeea-02fe9fa92999) |
You can explore the interactive API documentation at http://127.0.0.1:38540/docs.
If the agent is not already running, start it with:
slp agent start
The API follows the OpenAI Chat Completions specification, so any client or SDK that supports OpenAI will work out of the box.
Retrieve Project ID
Before querying against a project, retrieve the list of available projects to get the project_id:
curl http://127.0.0.1:38540/v1/projects
This returns a list of projects, for example:
{
"projects": [
{
"id": "c91626ed-cded-4bb4-9627-5cb9c257a13e",
"name": "vanguard",
"model_name": "slp-orchestra-mini",
"current": true
}
]
}
Use the id field as the project_id in your chat completion requests.
Using Python SDK
Install the OpenAI Python SDK:
pip install openai
Query a project by passing project_id as an extra body parameter:
from openai import OpenAI
client = OpenAI(
base_url="http://127.0.0.1:38540/v1",
api_key="not-needed",
)
response = client.chat.completions.create(
model="slp-orchestra-mini",
messages=[
{"role": "user", "content": "What are the fund names and their tickers?"}
],
stream=False,
extra_body={"project_id": "c91626ed-cded-4bb4-9627-5cb9c257a13e"},
)
print(response.choices[0].message.content)
Using JavaScript SDK
Install the OpenAI Node.js SDK:
npm install openai
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "http://127.0.0.1:38540/v1",
apiKey: "not-needed",
});
const response = await client.chat.completions.create({
model: "slp-orchestra-mini",
messages: [
{ role: "user", content: "What are the fund names and their tickers?" },
],
stream: false,
// @ts-ignore — extended field
project_id: "c91626ed-cded-4bb4-9627-5cb9c257a13e",
});
console.log(response.choices[0].message.content);
Using CURL
curl http://127.0.0.1:38540/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "slp-orchestra-mini",
"project_id": "c91626ed-cded-4bb4-9627-5cb9c257a13e",
"stream": false,
"messages": [
{"role": "user", "content": "What are the fund names and their tickers?"}
]
}'
Message Roles
| Role | Description |
|---|---|
system | Sets the behavior and context for the assistant |
user | The end user's message |
assistant | Previous assistant responses (for multi-turn conversations) |
Response Format
{
"message_id": "msg-71d45ab2",
"choices": [
{
"message": {
"role": "assistant",
"content": "Vanguard Ohio Long-Term Tax-Exempt Fund (VOHIX), Vanguard International Value Fund (VTRIX), Vanguard Virtual Value Fund (VTXR)"
}
}
],
"citations": [
{ "document_id": "5c41051fd68e9d76b74e0eca3b0ae73e", "document_name": "sp97.pdf" },
{ "document_id": "51886ebb65216aae83fad416f8001459", "document_name": "sp934.pdf" },
{ "document_id": "a613f5035cd7b349e9229fbd4723c9e2", "document_name": "sp46.pdf" }
]
}
The response extends the standard OpenAI format with two additional fields:
message_id— unique identifier for the assistant message, useful for feedback and tracking.citations— list of source documents from the project that were used to generate the answer.
Access the response content and citations:
print(response.choices[0].message.content)
# Access citations (returned in the raw response)
import json
raw = json.loads(response.model_dump_json())
for cite in raw.get("citations", []):
print(cite["document_name"])
Multi-turn Conversations
To maintain context across messages, pass the full conversation history in the messages array along with the project_id:
response = client.chat.completions.create(
model="slp-orchestra-mini",
messages=[
{"role": "user", "content": "What are the fund names and their tickers?"},
{"role": "assistant", "content": "Vanguard Ohio Long-Term Tax-Exempt Fund (VOHIX), Vanguard International Value Fund (VTRIX), Vanguard Virtual Value Fund (VTXR)"},
{"role": "user", "content": "Which one has the highest expense ratio?"},
],
stream=False,
extra_body={"project_id": "c91626ed-cded-4bb4-9627-5cb9c257a13e"},
)
print(response.choices[0].message.content)
# Vanguard International Value Fund (VTRIX) has the highest expense ratio at 0.35%.
The response follows the same format, with citations referencing the source documents used to answer the follow-up:
{
"message_id": "msg-3ec5c892",
"choices": [
{
"message": {
"role": "assistant",
"content": "Vanguard International Value Fund (VTRIX) has the highest expense ratio at 0.35%."
}
}
],
"citations": [
{ "document_id": "a613f5035cd7b349e9229fbd4723c9e2", "document_name": "sp46.pdf" },
{ "document_id": "1c1d5deeb7ea216fec1eed84e1268e30", "document_name": "sp923.pdf" },
{ "document_id": "5c41051fd68e9d76b74e0eca3b0ae73e", "document_name": "sp97.pdf" }
]
}