Skip to main content
POST
Messages (Anthropic Format)

Overview

The /v1/messages endpoint provides an Anthropic-compatible Messages API that seamlessly integrates with the Anthropic SDK while delivering Stratus world model predictions.
For Anthropic SDK users: Drop-in replacement - just change the base URL and API key.

Why Use This Endpoint?

Anthropic SDK Compatible

Use official Anthropic SDK with Stratus predictions

Format Parity

Full compatibility with Anthropic’s Messages API format

Streaming Support

Server-sent events (SSE) streaming fully supported

Tools & Function Calling

Complete tool use and function calling support

How It Works

Stratus internally converts between formats to deliver predictions:
This conversion is transparent - you don’t need to handle it. Just use the Anthropic SDK normally.

Authentication

Use your Stratus API key in the x-api-key header (Anthropic SDK convention):

Request Format

Basic Request

With System Prompt

Parameters

string
required
Stratus model to use. See Models for the full list of 2,050+ combinations.Native examples: stratus-x1ac-small-gpt-4o, stratus-x1ac-base-claude-sonnet-4-20250514OpenRouter examples: stratus-x1ac-base-deepseek/deepseek-r1, stratus-x1ac-base-meta-llama/llama-3.3-70b-instruct
array
required
Array of message objects with role and content. Roles: user or assistant.
integer
required
Maximum tokens to generate (1-4096). Note: Required in Anthropic format (unlike OpenAI).
string
System prompt (state description for Stratus world model predictions).
number
default:"1.0"
Sampling temperature (0.0-2.0). Higher = more random.
number
default:"1.0"
Nucleus sampling (0.0-1.0). Alternative to temperature.
integer
Top-k sampling. Limits token selection to top k options.
boolean
default:"false"
Enable streaming responses via server-sent events (SSE).
string[]
Stop generation when any sequence is encountered.
object
Optional metadata for request tracking.
array
Tool definitions for function calling. See Tools & Function Calling.
object
Tool selection strategy: auto, any, or specific tool.

Response Format

Non-Streaming Response

Response Fields

string
Unique message identifier (format: msg_*)
string
Always "message" for complete responses
string
Always "assistant" for responses
array
Array of content blocks. Each block has type and content (e.g., text, tool_use)
string
The Stratus model that generated the response
string
Why generation stopped: end_turn, max_tokens, stop_sequence, tool_use
object
Token usage: input_tokens and output_tokens

Examples

Basic Prediction

Streaming Response

Conversation with History

Tools & Function Calling

The Messages endpoint supports full tool use and function calling.

Defining Tools

Tool Choice Strategies

Tool Use Response

Handling Tool Results

Streaming Events

When stream: true, you receive a sequence of events: Example stream:

Comparison: Messages vs Chat Completions

When to use Messages:
  • You’re already using Anthropic SDK in your codebase
  • You prefer Anthropic’s API conventions
  • You need Anthropic-specific features
When to use Chat Completions:
  • You’re using OpenAI SDK
  • You want the simpler, more common format
  • You’re familiar with OpenAI’s API

Error Handling

Errors follow Anthropic’s error format:
Common error types:
  • invalid_request_error - Malformed request
  • authentication_error - Invalid API key
  • permission_error - Insufficient permissions
  • not_found_error - Model not found
  • rate_limit_error - Rate limit exceeded
  • api_error - Server error
See Errors for full error documentation.

Best Practices

1. Always Set max_tokens

Unlike OpenAI’s API, Anthropic format requires max_tokens:

2. Use System Prompt for State

Provide current state in the system parameter:

3. Handle Streaming Properly

4. Validate Tool Inputs

When using tools, validate inputs before execution:

Migration from Anthropic API

Switching from Anthropic’s API to Stratus is simple:
That’s it! All your existing code continues to work.

Performance

Format conversion between Anthropic and OpenAI formats adds negligible overhead (<1ms).

SDK Support

Works seamlessly with the official Anthropic SDK for TypeScript and Python. No custom SDK needed.