Praus Developers Get API access

Guides

Conversations

Each request stands alone. To continue a conversation, send the earlier turns with the new message.

#How context works

The Praus API doesn’t remember earlier requests. A request answers the message you send, using only the history included in that same request. To hold a conversation, your application keeps the turns and sends them back each time in conversationHistory.

#Send earlier turns

List earlier messages oldest first. Each item has a role of user or assistant, and its content as a string. Put the new question in message, not in the history.

{
  "message": "What is the project codename?",
  "queryProfile": "ask",
  "searchEnabled": false,
  "stream": false,
  "sessionOnly": true,
  "conversationHistory": [
    { "role": "user", "content": "The project codename is Cedar." },
    { "role": "assistant", "content": "Noted." }
  ],
  "userMemory": {
    "memories": [],
    "customInstructions": ""
  }
}
curl https://praus.ai/api/chat/compound-pipeline-sync \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: $PRAUS_API_KEY" \
  -d '{
  "message": "What is the project codename?",
  "queryProfile": "ask",
  "searchEnabled": false,
  "stream": false,
  "sessionOnly": true,
  "conversationHistory": [
    { "role": "user", "content": "The project codename is Cedar." },
    { "role": "assistant", "content": "Noted." }
  ],
  "userMemory": {
    "memories": [],
    "customInstructions": ""
  }
}'

Praus answers with the codename from the history: Cedar.

#Keep the history in your app

import os
import requests

URL = "https://praus.ai/api/chat/compound-pipeline-sync"
HEADERS = {"Content-Type": "application/json", "X-Api-Key": os.environ["PRAUS_API_KEY"]}
history = []  # earlier turns, oldest first


def ask(message):
    response = requests.post(URL, headers=HEADERS, timeout=120, json={
        "message": message,
        "queryProfile": "ask",
        "searchEnabled": False,
        "stream": False,
        "sessionOnly": True,
        "conversationHistory": history,
        "userMemory": {"memories": [], "customInstructions": ""},
    })
    data = response.json()
    if not response.ok:
        raise RuntimeError(f"{response.status_code} {data.get('code')}: {data.get('message')}")
    answer = data["result"]["content"]
    history.append({"role": "user", "content": message})
    history.append({"role": "assistant", "content": answer})
    return answer


print(ask("The project codename is Cedar."))
print(ask("What is the project codename?"))
const URL = "https://praus.ai/api/chat/compound-pipeline-sync";
const history = []; // earlier turns, oldest first

async function ask(message) {
  const response = await fetch(URL, {
    method: "POST",
    headers: { "Content-Type": "application/json", "X-Api-Key": process.env.PRAUS_API_KEY },
    body: JSON.stringify({
      message,
      queryProfile: "ask",
      searchEnabled: false,
      stream: false,
      sessionOnly: true,
      conversationHistory: history,
      userMemory: { memories: [], customInstructions: "" },
    }),
  });
  const data = await response.json();
  if (!response.ok) throw new Error(`${response.status} ${data.code}: ${data.message}`);
  const answer = data.result.content;
  history.push({ role: "user", content: message }, { role: "assistant", content: answer });
  return answer;
}

console.log(await ask("The project codename is Cedar."));
console.log(await ask("What is the project codename?"));

Only add a turn to the history after the request succeeds, so a failed request isn’t remembered as part of the conversation.

#History limits

  • Praus keeps at most the latest 60 history messages from a request. Older ones are dropped.
  • History counts toward your input allowance of 16,000 bytes (UTF-8) per request on Plus and Pro, together with the message and any other text you send. A request over the allowance returns 413 CONSUMER_API_INPUT_LIMIT.
  • For long conversations, keep the most recent turns, or replace older turns with a short summary that your app writes.