Messages (Anthropic)
POST /v1/messages is the Anthropic-compatible endpoint for Claude-native apps and agent flows. Perfect for use with the official Anthropic SDK, Claude Code, Cline, and other tools that speak the Anthropic protocol directly.
Use it when
- Your code already targets the Anthropic Messages API
- You need Anthropic-style request and response objects
- You want Claude-native tooling and streaming behavior
Code examples
1curl -X POST https://api.navy/v1/messages \
2 -H "x-api-key: sk-navy-YOUR_KEY" \
3 -H "Content-Type: application/json" \
4 -H "anthropic-version: 2023-06-01" \
5 -d '{
6 "model": "claude-sonnet-4-20250514",
7 "max_tokens": 1024,
8 "messages": [
9 {"role": "user", "content": "Draft a deployment checklist."}
10 ]
11 }'Parameters
model(string, required) — Anthropic model ID such asclaude-sonnet-4,claude-opus-4.6,claude-haiku-4.5messages(array, required) — Array withrole("user"or"assistant") andcontentmax_tokens(integer, required) — Maximum tokens to generate (required by Anthropic format)system(string or array, optional) — System prompt as a string or array of text blocksstream(boolean, optional) — Enable streaming via Anthropic SSE formattemperature(number, optional) — Sampling temperature (0.0–1.0)top_p(number, optional) — Nucleus sampling thresholdtop_k(integer, optional) — Top-K sampling parameterstop_sequences(array, optional) — Array of stop sequencestools(array, optional) — Anthropic-format tool definitionstool_choice(object, optional) —{ type: "auto" },{ type: "any" }, or{ type: "tool", name: "..." }
Authentication
This endpoint accepts your NavyAI API key via either header:
x-api-key: sk-navy-YOUR_KEY(Anthropic style)Authorization: Bearer sk-navy-YOUR_KEY(OpenAI style)
Streaming
Set "stream": true to receive Anthropic-style SSE events such as message_start, content_block_start, content_block_delta, content_block_stop, message_delta, and message_stop.
1import anthropic
2
3client = anthropic.Anthropic(
4 api_key="sk-navy-YOUR_KEY",
5 base_url="https://api.navy"
6)
7
8with client.messages.stream(
9 model="claude-sonnet-4-20250514",
10 max_tokens=1024,
11 messages=[{"role": "user", "content": "Stream a haiku about the sea."}]
12) as stream:
13 for text in stream.text_stream:
14 print(text, end="", flush=True)Tool use
Provide tools and the model can emit tool_use content blocks. Reply with a tool_result block keyed by the tool's id on the next turn.
1tools = [{
2 "name": "get_weather",
3 "description": "Get the current weather for a city",
4 "input_schema": {
5 "type": "object",
6 "properties": {"city": {"type": "string"}},
7 "required": ["city"]
8 }
9}]
10
11message = client.messages.create(
12 model="claude-sonnet-4-20250514",
13 max_tokens=1024,
14 tools=tools,
15 messages=[{"role": "user", "content": "What's the weather in Tokyo?"}]
16)
17print(message.content)Vision
Send images using Anthropic's native image content block (URL or base64) inside a user message. Use Anthropic's documented shape — NavyAI does not transform it.
Notes
- This endpoint is designed for Anthropic-native clients
- Streaming uses Anthropic SSE formatting
- Vision and tools are supported in the native shape
- If you call this endpoint with a non-Anthropic model (e.g.
gpt-5), NavyAI adapts the request and translates the response back into Anthropic shape so the same SDK works across providers