Request schemas & validation
This page documents the validation logic enforced by the API server so examples here match real behavior.
Common rules
model
is required and must be one of the allowed models. The normalized model name is used internally.messages
must be a non-empty array.tools
(if provided) must be valid per the tool spec; otherwise the request is rejected.max_tokens
/max_completion_tokens
must be between 1 and the model context window.stream
(if provided) must be a boolean.- Rate limit and size checks apply: payload too large returns 413.
OpenAI-style messages
- Allowed roles:
system
,developer
,user
,assistant
,tool
,function
. - A user message must be present somewhere in the array.
message.content
can be a string or an array of content parts. Unknown shapes are rejected.
Anthropic-style messages
- Allowed roles:
user
,assistant
,system
,tool
. - At least one text segment must be present across messages.
- Content blocks support
text
,image
,tool_use
,tool_result
as commonly used shapes.
Provider-specific parameters
The unified endpoint enforces parameter compatibility based on the model provider.
- For OpenAI models, Anthropic-only parameters (e.g.
top_k
,stop_sequences
,cache_control
) are rejected with HTTP 400. - For Anthropic models, OpenAI-only parameters (e.g.
max_completion_tokens
,logit_bias
,n
,seed
,user
,function_call
,functions
,parallel_tool_calls
,store
,response_format
) are rejected with HTTP 400.
response_format (OpenAI)
response_format
must be one of:
{ "type": "text" }
{ "type": "json_object" }
{ "type": "json_schema", "json_schema": { "name": "MySchema", "schema": {"type":"object"}, "strict": true } }
Invalid shapes (missing name
for json_schema, wrong types) cause a 400 error.
Error responses
- 400 – invalid request parameters (message describes the exact issue)
- 401 – missing or invalid API key
- 413 – payload too large
- 429 – rate limit exceeded (key or IP)
These rules are applied consistently across:
- Unified:
POST /api/v1/messages
- OpenAI:
POST /api/openai/v1/chat/completions
- Anthropic:
POST /api/anthropic/v1/messages