Skip to content

v1.2.0 - OpenAI-compatible chat completions

Latest

Choose a tag to compare

@n0an n0an released this 21 Apr 15:39

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: true to get text/event-stream chunks (data: {"choices":[{"delta":{"content":"..."}}]} plus a final [DONE] sentinel).
  • Non-streaming mode: standard JSON chat.completion response 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: provider field now accepts anthropic (→ claude), openai (→ codex), and google / google-ai (→ gemini) on both /process and /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 --print one-shot with --output-format stream-json --verbose for streaming, text for non-streaming. System messages go via --append-system-prompt so 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 start

or if running from source:

git pull && npm install && npm run build

See the README for the full endpoint documentation.