Use Cadreen as a Model Provider
Cadreen exposes a standard OpenAI-compatible /api/v1/cadreen/chat/completions endpoint. Point any OpenAI client at it and you get governance, memory, and intelligence.
Quick start
/api/v1/cadreen/chat/completionsfrom openai import OpenAI
client = OpenAI(
base_url="https://api.cadreen.com/api/v1/cadreen",
api_key="sk_cadreen_..."
)
response = client.chat.completions.create(
model="cadreen",
messages=[{"role": "user", "content": "What connectors do I have?"}]
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.cadreen.com/api/v1/cadreen",
apiKey: "sk_cadreen_...",
});
const response = await client.chat.completions.create({
model: "cadreen",
messages: [{ role: "user", content: "What connectors do I have?" }],
});
console.log(response.choices[0].message.content);curl -X POST https://api.cadreen.com/api/v1/cadreen/chat/completions \
-H "Authorization: Bearer sk_cadreen_..." \
-H "Content-Type: application/json" \
-d '{
"model": "cadreen",
"messages": [{"role": "user", "content": "What connectors do I have?"}],
"stream": true
}'Request fields
| Field | Type | Required | Notes |
|---|---|---|---|
| model | string | No | Accepted for compatibility, ignored internally |
| messages | array | Yes | OpenAI message format |
| stream | bool | No | Enable streaming SSE |
| tools | array | No | Tool/function definitions |
| conversation_id | string | No | Track conversations across requests |
| context | object | No | Cadreen-specific context |
Streaming
Set stream: true to get SSE chunks. Cadreen sends keepalive comments every 15 seconds during long operations.
stream = client.chat.completions.create(
model="cadreen",
messages=[{"role": "user", "content": "Hello!"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")Tool calling
Send your tools and Cadreen answers as a tool-calling model: your tools only, tool_choice and parallel_tool_calls honoured, and governance on every call before it is returned to you. Your system messages are the policy it follows.
response = client.chat.completions.create(
model="cadreen",
messages=[{"role": "user", "content": "Read main.py and summarize it"}],
tools=[{
"type": "function",
"function": {
"name": "read",
"description": "Read a file",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string", "description": "File path"}
},
"required": ["path"]
}
}
}]
)Response metadata
A successful answer that is not streamed includes Cadreen-specific metadata alongside the OpenAI-compatible fields. A stream the model generates token by token sends the intelligence object in its last event; a stream that ends in one chunk (a call your rules blocked, a question back, a mission, a fallback answer), or one where the server ran all the tool calls itself and asked the model again, sends none.
{
"choices": [{
"message": {
"role": "assistant",
"content": "You have 3 active connectors.",
"metadata": {
"confidence": 0.92,
"cadreen_type": "direct",
"classification": { "intent": "question", "complexity": "simple" },
"assessment": { "can_do": 0.85, "assessment_quality": "complete" },
"governance": { "decision": "auto", "approved": true }
}
}
}],
"intelligence": {
"reasoning": {
"confidence": 0.92
},
"governance": { "active": false, "policies_checked": 1 },
"humility": { "honest_assessment": "Assessment: complete, CanDo: 0.85" },
"version": "1.0",
"timestamp": "2026-06-21T10:30:00Z"
}
}