Tool Calling with /completions
Send your tools and Cadreen answers as a tool-calling model: it honours tool_choice and parallel_tool_calls, returns OpenAI-shaped tool_calls, and checks every call with governance before you get it. Your system messages are its policy. A named model with server_tools on is hybrid: Cadreen's own tools also run server-side.
How tools work
You send tool definitions in the request. The model proposes tool calls to them. Cadreen evaluates governance on every call, and the calls it approves are returned to you for local execution. With model cadreen nothing runs server-side: Cadreen's own tools are not added to your list, and its clarifying questions and direct answers are not used.
The hybrid execution flow
This flow is for a named model with server_tools on. When you ask "read main.py and email a summary to john@example.com", Cadreen splits the work:
Tool chaining
When the model proposes tool calls, you execute them and send results back:
# First request — model proposes tools
response = client.chat.completions.create(
model="cadreen",
messages=[{"role": "user", "content": "List my connectors and summarize them"}],
tools=[...]
)
# Get tool calls
tool_calls = response.choices[0].message.tool_calls
# Execute tools locally, then send results back
messages = [
{"role": "user", "content": "List my connectors and summarize them"},
response.choices[0].message,
{
"role": "tool",
"tool_call_id": tool_calls[0].id,
"content": '{"connectors": ["acme", "salesforce", "github"]}'
}
]
# Second request — model sees tool results
response2 = client.chat.completions.create(
model="cadreen",
messages=messages,
tools=[...]
)conversation_id to track conversations across requests. Tool call confirmations (when governance blocks a call) are matched to the correct conversation via this ID.GET /conversations/{id}/messages (and GET /conversations/{id}) leave those results out. To get your own results back, add ?include=tool_results to the request. Use the same include on every page of one read: pages are by offset over the messages that are returned, so a changed value shifts them. GET /conversations/{id}/view-state counts the messages a person reads only, never tool results.Self-healing
When a tool call fails, Cadreen diagnoses the failure and retries:
Governance on tool calls
When governance holds a tool call, the response says so instead of returning the call, and lists it in pending_actions:
{
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "This action needs a person's approval before it can run:\n- process_refund (decision governance_task:7c1e2a40-...)\n\nA person in this workspace has to approve or decline it, signed in. Replying here does not approve it."
},
"finish_reason": "stop"
}],
"operation_id": null,
"pending_actions": [{
"tool": "process_refund",
"tool_call_id": "call_abc123",
"operation_id": "5b0d9e3a-...",
"decision_id": "governance_task:7c1e2a40-...",
"kind": "governance_task",
"source_id": "7c1e2a40-...",
"resolve_path": "/api/v1/cadreen/decisions/governance_task:7c1e2a40-.../resolve",
"runs_in": "cadreen"
}]
}Discovering available tools
Use GET /api/v1/cadreen/tools to list the tools your workspace can use: Cadreen's built-in tools and the services you connected.
/api/v1/cadreen/toolscurl https://api.cadreen.com/api/v1/cadreen/tools \
-H "Authorization: Bearer sk_cadreen_..."Each is an OpenAI function definition whose parameters are what the tool takes, with its id: the tool_id a routing job's service names.