CowAgent serves a chat endpoint compatible with the OpenAI Chat Completions protocol, on the same port as the Web Console. Any app, SDK or workflow that speaks the OpenAI protocol can connect to it directly.Unlike calling a model, the endpoint runs the full Agent: it uses its tools, skills, memory and knowledge base to finish the task, and returns its reasoning, tool calls and token usage along with the answer.
Turn on the API
The API is off by default. Once it is on, every request must carry the API key.From the console
Open “Config → General → Chat API” and turn on the switch. After you confirm, an API key is generated, along with the base URL and ready-to-copy examples (cURL / Python / Node.js).- Regenerate: issues a new API key; the old one stops working at once
- Turn off: the API stops serving requests. The key is kept and works again once the API is back on
From the config file
Set these two keys inconfig.json, then restart the service:
The API shares the Web Console’s address and port. By default it listens on
127.0.0.1, so only this machine can reach it. To call it from other machines, set web_host to 0.0.0.0 as described in Web Console and open the port. The API key is independent from the console password web_password.Quick start
The examples assume the service runs on port9899 of this machine. They name neither a model nor an Agent, so the default Agent answers on its own model.
- cURL
- Python
- Node.js
Endpoints
Authentication
Every request carries the API key in its headers:Chat
POST /v1/chat/completions
The Agent uses its own tools and system prompt, so parameters such as
temperature, max_tokens and tools are ignored.
Choose an Agent
With multiple Agents configured,agent_id chooses which one answers. An Agent’s ID is shown under its name on the Agents page, with a button next to it to copy it. default always means the default Agent. An Agent that does not exist or is archived returns 404.
model applies to that request only; it does not change the model set for the Agent or the conversation.
List models
GET /v1/models
Returns the available models: the chat models of every provider configured under “Config → Models”, with the provider in owned_by. A request naming a model that is not listed returns 404.
Conversations
The API supports two ways of keeping a conversation:- Stateless (default): without
conversation_id, send the wholemessageslist every time, as with any model. The lastusermessage is this turn’s input, and theuser/assistantmessages before it are the context. Nothing is written to CowAgent’s conversation history. - Stateful: with
conversation_id, CowAgent keeps the history, so each request only sends the new message and earlier entries inmessagesare ignored. Requests in the same conversation are handled one at a time, in order.
system messages in the request are ignored: the Agent always keeps its own persona, skills and memory. Either way, the Agent can read and write its workspace and memory files through its tools.Responses
Non-streaming
Besides the standard OpenAI response,message carries the reasoning and a record of the tool calls:
Streaming
With"stream": true the response is a stream of standard chat.completion.chunk events over SSE:
- The answer is in
choices[0].delta.content - The reasoning is in
choices[0].delta.reasoning_content - Process events such as tool calls are in the top-level
cow_eventfield, with an emptydelta - The last chunk has
finish_reasonset tostop. Withstream_options.include_usage, one more chunk follows with emptychoicesand theusage - The stream ends with
data: [DONE]
Process events
cow_event.type takes these values:
Errors
Errors follow the OpenAI format:
A streaming request waits up to 30 seconds for the Agent to produce the first event. A failure or a timeout before the first event returns one of the JSON errors above, and a timeout cancels that request. Once the stream has started its HTTP status can no longer change, so a later failure arrives as a
cow_event.type=error chunk, followed by a terminal chunk with finish_reason=error and then data: [DONE].
Use it from other apps
Any client or platform that accepts a custom OpenAI endpoint can connect. Choose the “OpenAI” or “OpenAI compatible” provider and fill in:- Base URL:
http://<server address>:9899/v1(some apps only want the address and port, and add/v1themselves) - API key: the key generated in the console
- Model: pick one from the model list
Only text input is supported for now; images and other multimodal content are not. Caller-supplied
tools for function calling are not supported either: the Agent finishes the task with its own tools.