chat() method sends a chat completion request to a running model server and returns a ChatMessage payload. It is a simple API for quick prompts when you do not need to call the HTTP endpoint directly.
Basic Chat
Multiturn conversations
For multiturn conversations thechat() method accepts an additional history argument which can also be used to set system prompts.
Model instantiation
The model exposes a variety of customization parameters includingbase_image, which allows you to customize the model container runtime. This is especially useful if you need to run inference on custom hardware which requires a specifically compiled version of llama.cpp, vLLM, and more.
Async models
The async model API is identical to the sync examples above.Before you call chat()
The server must be running. If you are not using a context manager, manage the model lifecycle yourself:Method signature
Parameters
Returns
AChatMessage typed dict with the assistant response.
Raises
RuntimeErrorif the server is not running.
When to use chat() vs direct HTTP
For direct HTTP calls, see the quick start example that uses
requests.
