bendytree
04/24/2025, 1:30 PMmodel-output// Client-side
const vapi = new Vapi("...");
vapi.start({
  ...
  clientMessages: ['model-output'],
  model: { provider: 'custom-llm', ... },
);
vapi.on("message", (message) => {
  if (message.type === 'model-output') {
    console.log(message); // ?
  }
});// Server-side (Custom LLM)
app.post('/agent/vapi-custom-llm/chat/completions', async (req, res, next) => { 
  res.write(`data: {"id":"1","object":"chat.completion.chunk","choices":[{"delta":{"role":"assistant","content":""},"index":0}]}\n\n`);
  res.write(`data: {"id":"1","object":"chat.completion.chunk","choices":[{"delta":{"content":"Here is the link."},"index":0}]}\n\n`);
  // additional url param added here
  res.write(`data: {"url":"https://example.com/abc","id":"1","object":"chat.completion.chunk","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}\n\n`);
  res.end(`data: [DONE]\n\n`);
});Vapi Support Bot
04/24/2025, 1:32 PMclientMessagesjavascript
// Client-side
const vapi = new Vapi("...");
vapi.start({
  clientMessages: ['model-output', 'tool-calls'],
  model: { provider: 'custom-llm', ... },
});
vapi.on("message", (message) => {
  if (message.type === 'tool-calls') {
    console.log(message.data.url); // Access your extra data
  }
});Vapi Support Bot
04/24/2025, 3:20 PMbendytree
04/24/2025, 3:57 PMres.write(`data: {"id":"1","object":"chat.completion.chunk","choices":[{"delta":{"role":"assistant","content":""},"index":0}]}\n\n`);
    res.write(`data: {"id":"1","object":"chat.completion.chunk","choices":[{"delta":{"content":"Here is the link."},"index":0}]}\n\n`);
    res.write(`data: {"id":"1","object":"chat.completion.chunk","choices":[{"delta":{"tool_calls":[{"id":"2134","type":"function","index":0,"function":{"name":"parse_data","arguments":${JSON.stringify(JSON.stringify({url: "foobar"}))}}}]},"index":0}]}\n\n`);
    res.write(`data: {"id":"1","object":"chat.completion.chunk","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}\n\n`);
    res.end(`data: [DONE]\n\n`);tool-callmodel-outputmodel-output {"type":"model-output","output":"Here is the link."}
model-output {"type":"model-output","output":[{"id":"2134","type":"function","function":{"name":"parse_data","arguments":"{\"url\":\"foobar\"}"},"isPrecededByText":true}]}Kyle
04/28/2025, 12:52 AMbendytree
04/28/2025, 6:29 PMKyle
04/30/2025, 9:03 AM