Messages API (Anthropic wire dialect)
/api/client/v1/messages speaks Anthropic's Messages API request/response shape natively, alongside the OpenAI-shaped Chat Completions endpoint. Both run through the same model routing, guardrails, and provider gateway — pick whichever wire format your client already speaks.
New in September 2026
This endpoint shipped alongside the guardrail hook plane rewrite. If your integration currently targets Anthropic's API directly, pointing it at this endpoint instead gets you Cognipeer's model routing, guardrails, and tracing without a rewrite.
Endpoint
POST /api/client/v1/messages
Authorization: Bearer <token>
Content-Type: application/json2
3
Request
{
"model": "claude-sonnet",
"system": "You are a helpful assistant.",
"messages": [
{ "role": "user", "content": "What is the capital of France?" }
],
"max_tokens": 1000,
"temperature": 0.7,
"stream": false
}2
3
4
5
6
7
8
9
10
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model key configured in the dashboard |
messages | array | Yes | Array of { role: "user" | "assistant", content } turns |
system | string | No | System prompt, kept separate from messages as Anthropic's shape expects |
max_tokens | number | Yes | Maximum tokens to generate |
temperature | number | No | Sampling temperature (0-1) |
stream | boolean | No | Enable SSE streaming (default: false) |
tools | array | No | Tool definitions, in Anthropic's tool-use shape |
thinking | object | No | { "type": "enabled", "budget_tokens": 4096 }, { "type": "adaptive" } or { "type": "disabled" }. Used only when the model has no Model Hub reasoning default |
output_config | object | No | With thinking.type: "adaptive", { "effort": "low" | "medium" | "high" | "xhigh" | "max" } sets the level |
include_reasoning | boolean | No | false hides the thinking blocks of this response |
content accepts either a plain string or an array of content blocks ({ type: "text", text: "..." }, plus tool-use/tool-result blocks when tools is set).
Thinking
Available from the next Cognipeer release
Thinking on /messages follows the Model Hub reasoning rules from the next Cognipeer release on.
The request's thinking is translated into the model's reasoning setting, and the Model Hub default of the model still wins. A response carries thinking content blocks (and thinking_delta events while streaming) only when the request turned thinking on (enabled or adaptive), the model returned reasoning, and neither the model nor include_reasoning: false hides it. A caller that never asked for thinking gets none. The blocks have an empty signature: do not echo them back as signed thinking. Thinking tokens are counted in the usage of the call. See Reasoning.
Response (Non-Streaming)
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"model": "claude-sonnet",
"content": [
{ "type": "text", "text": "The capital of France is Paris." }
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 25,
"output_tokens": 8
}
}2
3
4
5
6
7
8
9
10
11
12
13
14
Response (Streaming)
When stream: true, the response is a Server-Sent Events stream using Anthropic's event types (message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop) rather than Chat Completions' chat.completion.chunk shape.
Guardrails
Guardrails attached to the target model apply the same way they do on Chat Completions — the input.pre / output.pre hooks run regardless of which wire dialect the request arrived through. A blocked request returns the same guardrail_block error shape.
Errors
| Status | Description |
|---|---|
| 400 | Missing model, messages, or max_tokens; guardrail block |
| 401 | Invalid API token |
| 422 | output_token_limit_exceeded: the model hit its output token limit before it could answer |
| 500 | Model not found or not configured for chat completions |
| 429 | Rate limit or quota exceeded |
Examples
cURL
curl -X POST https://gateway.example.com/api/client/v1/messages \
-H "Authorization: Bearer cpeer_your_token" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet",
"max_tokens": 1000,
"messages": [{"role": "user", "content": "Hello"}]
}'2
3
4
5
6
7
8
Python (Anthropic SDK)
Point Anthropic's own SDK at the gateway by overriding its base URL:
from anthropic import Anthropic
client = Anthropic(
api_key="cpeer_your_token",
base_url="https://gateway.example.com/api/client/v1",
)
response = client.messages.create(
model="claude-sonnet",
max_tokens=1000,
messages=[{"role": "user", "content": "Hello"}],
)2
3
4
5
6
7
8
9
10
11
Listing models
GET /api/client/v1/models returns the project's models and, for tokens that may read agents, its active agents as agent:<key> entries (owned_by: "cognipeer-agent"). Agent ids are for /chat/completions and /responses; pass a model key here.

