What's new
Added POST /v1/chat/completions - an OpenAI-compatible chat endpoint for multi-turn conversations with optional SSE streaming. Any client that already speaks OpenAI's Chat Completions API (including the Ollama-provider path in many apps) can now point at VivAgents with only a URL change.
Features
- Multi-turn chat: accepts the standard
{ messages: [{role, content}], model, stream, ... }body shape. - Streaming via SSE: set
stream: trueto gettext/event-streamchunks (data: {"choices":[{"delta":{"content":"..."}}]}plus a final[DONE]sentinel). - Non-streaming mode: standard JSON
chat.completionresponse for simple request/response flows. - Stateless by design: the server holds no conversation state; clients re-send full
messages[]every turn, matching how OpenAI's own endpoint behaves. - Vendor-name aliases:
providerfield now acceptsanthropic(→ claude),openai(→ codex), andgoogle/google-ai(→ gemini) on both/processand/v1/chat/completions. Apps that name providers after the AI vendor no longer need to know VivAgents' internal CLI-binary naming. - Abort on disconnect: if the HTTP client disconnects mid-stream, the underlying Claude CLI subprocess is terminated (SIGTERM, then SIGKILL after 5s) to avoid wasted work.
Implementation notes
- Currently Claude-only on the chat endpoint. Codex and Gemini return a clean "provider does not support chat completions" error; their session models can be wired up later.
- Claude spawning uses
--printone-shot with--output-format stream-json --verbosefor streaming,textfor non-streaming. System messages go via--append-system-promptso Claude Code's default behavior is preserved. - Prompts pipe through stdin (not argv) to avoid ARG_MAX / shell-quoting issues on large conversations.
Breaking changes
None. /process is unchanged and backwards-compatible.
Upgrading
npm install -g vivagents@1.2.0
vivagents startor if running from source:
git pull && npm install && npm run buildSee the README for the full endpoint documentation.