API reference
Chat API
Send a message from your own app and stream the reply back, with everything ChatVLM does: the router, tools, documents, artifacts, memory and council mode. Every chat you make here shows up in ChatVLM too. Or call a model on its own, for plain completions.
https://api.chatvlm.com/v1Authentication
Every call but this reference takes a personal key from Settings → API as a bearer token. The key acts as you, with your plan, your workspaces and your limits, so call the API from your server and keep the key there, never in a browser. On a ChatVLM box everyone who signs in can make one; on the cloud, members of an enterprise organization can.
Authorization: Bearer $CHATVLM_API_KEY
Streaming
A reply comes back as server-sent events in the AI SDK UI message stream format: text, reasoning, tool calls and their results, sources, and ChatVLM's own data-* parts for artifacts and routing, ending in data: [DONE]. Closing the connection does not stop the reply; it runs to the end and is saved. If your server forwards requests with your key, the AI SDK's useChat reads the stream as it is. Send it only the new message, and give it UUID message ids.
import { useChat } from '@ai-sdk/react'
import { DefaultChatTransport } from 'ai'
// /my-server forwards to ChatVLM with your key.
// Vue: new Chat({ ... }) from '@ai-sdk/vue' takes the same options.
const chat = useChat({
generateId: () => crypto.randomUUID(),
transport: new DefaultChatTransport({
api: `/my-server/chats/${chatId}/messages`,
prepareSendMessagesRequest: ({ messages }) => {
const last = messages.at(-1)
const text = last?.parts.map((part) => (part.type === 'text' ? part.text : '')).join('') ?? ''
return { body: { message: { id: last?.id, text } } }
},
prepareReconnectToStreamRequest: () => ({ api: `/my-server/chats/${chatId}/stream` })
})
})Errors
A failed call answers with its status and one envelope, the same across /v1. The message says what went wrong in words you can show; the type is stable to branch on.
{
"error": {
"message": "The chat API is part of the enterprise plan.",
"type": "forbidden"
}
}