App öffnen
Moonborn — API · chat

Append a user turn and produce an assistant reply

When `stream=true`, the response is `text/event-stream` with token deltas; the final SSE event carries the persisted message ids. On rejection by moderation, the assistant reply is replaced with a safe fallback and a 200 is still returned (verdict in body).

POST/v1/chat/sessions/{id}/messagesscope · Bearer (API key or session JWT)
Path parameters
FieldTypeDescription
idreqstringChat session id (e.g. `chs_*`).
Request body
FieldTypeDescription
userTextreqstring
modelIdstring
historyLimitnumber
temperaturenumber
maxOutputTokensnumber
toolNamesstring[]
memoryDigeststring
extraGuardrailsstring[]
streamboolean

Responses

200OK
Body
FieldTypeDescription
userMessagereqobject
userMessage.messageIdreqstring
userMessage.sessionIdreqstring
userMessage.rolereqstring · "user" | "assistant" | "system" | "tool"
userMessage.contentreqstring
userMessage.inputTokensreqnumber
userMessage.outputTokensreqnumber
userMessage.modelreqstring
userMessage.latencyMsreqnumber
userMessage.costUsdMicrosreqnumber
userMessage.moderationVerdictreqstring
userMessage.driftScorereqnumber
userMessage.createdAtreqstring
assistantMessagereqobject
assistantMessage.messageIdreqstring
assistantMessage.sessionIdreqstring
assistantMessage.rolereqstring · "user" | "assistant" | "system" | "tool"
assistantMessage.contentreqstring
assistantMessage.inputTokensreqnumber
assistantMessage.outputTokensreqnumber
assistantMessage.modelreqstring
assistantMessage.latencyMsreqnumber
assistantMessage.costUsdMicrosreqnumber
assistantMessage.moderationVerdictreqstring
assistantMessage.driftScorereqnumber
assistantMessage.createdAtreqstring
sessionreqobject
session.sessionIdreqstring
session.orgIdreqstring
session.workspaceIdreqstring
session.personaIdreqstring
session.userIdreqstring
session.titlereqstring
session.statusreqstring · "active" | "ended" | "archived"
session.messageCountreqnumber
session.inputTokensreqnumber
session.outputTokensreqnumber
session.costUsdMicrosreqnumber
session.startedAtreqstring
session.lastActiveAtreqstring
session.endedAtreqstring
401Unauthenticated
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
404Session not found
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
409Session is not active
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
422Validation error
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
429Rate limit / quota exceeded
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring

Examples

cURL
curl -X POST https://api.moonborn.co/v1/chat/sessions/<id>/messages \
  -H "Authorization: Bearer $MOONBORN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "userText": "<string>"
    }'
TypeScript
import Moonborn from '@moonborn/sdk';

const client = new Moonborn({ apiKey: process.env.MOONBORN_API_KEY });

const result = await client.chat.sendChatMessage({
  id: '<id>',
  userText: "<string>",
});
Python
import os
from moonborn import Moonborn

client = Moonborn(api_key=os.environ["MOONBORN_API_KEY"])

result = client.chat.send_chat_message(
    id="<id>",
    user_text="<string>",
)