POST /v1/messages endpoint speaks the Anthropic Messages API, so the official Anthropic Python SDK and the Claude Agent SDK work against Valar with a base URL and key change. The same models and completion windows work as on the Responses and Chat Completions surfaces; see the API support matrix for the full feature list.
Anthropic Python SDK
auth_token (sends Authorization: Bearer) — or api_key (sends x-api-key); Valar accepts both.
system prompts, tools, thinking, stop_sequences, top_k, stream: true, and structured outputs via output_config.format. System prompts go in the top-level system field, not as a role: "system" message. Reasoning-capable models emit thinking blocks by default; control the depth with output_config.effort (low / medium / high / xhigh / max). thinking: {"type": "enabled"} is accepted and reasons at medium effort whatever its budget_tokens, and thinking: {"type": "disabled"} turns reasoning off. Use max_tokens generously (thinking counts toward the output budget) and iterate content for the text block rather than indexing content[0].
Streaming
Choose a completion window
Set the window either in the request body or through a header. The body field takes precedence when both are set."asap" (Now), "priority", "standard", and "flex". See Inference modes.
"flex" targets a ~5-minute turn time and is designed for background use. The Messages API accepts flex only without streaming: send it as a background request and poll for the result. A streaming flex request (stream=True, including messages.stream()) is rejected with a 400.Background requests
For long or bulk work on an async window, setbackground: true — a Valar extension to the Messages API, so pass it through extra_body. The call returns 202 right away with a response object (not a message) whose id is your handle; use the SDK’s raw-response mode to read it, since the SDK expects a message body.
GET /v1/responses/{id} returns the response object with its status. Once the run succeeds it returns the finished Anthropic message, the same body a synchronous call would have returned; a failed run keeps the response object with its error. You can also skip polling and receive a webhook when the run finishes.
A request on an async window without background waits for the result on the open connection, for up to five minutes. If the result isn’t ready by then, the call returns the same 202 with the in-progress response object instead of a timeout error, so check the status code and poll its id rather than resending the request. background can’t be combined with stream: true: that request is rejected with a 400.
Claude Agent SDK
The Claude Agent SDK runs the Claude Code agent loop as a library. Because the SDK owns the request body, set the completion window through theX-Valar-Completion-Window header via ANTHROPIC_CUSTOM_HEADERS rather than body metadata.
ANTHROPIC_API_KEY sends x-api-key, which Valar accepts. allowed_tools enables the SDK’s built-in tools (Read, Grep, Bash, …) or your own MCP servers — leave it empty for a plain completion.
Keep MCP tool definitions out of the prompt
SetENABLE_TOOL_SEARCH to true whenever you connect MCP servers.
The SDK withholds tool definitions by default and loads only the ones a turn needs, but it turns that off when ANTHROPIC_BASE_URL points anywhere other than Anthropic. Pointing the SDK at Valar therefore sends every tool definition on every request. With a few hundred MCP tools connected, those definitions can account for more than half of every prompt.
The cost compounds. Tool definitions are rendered ahead of your system prompt and messages, so any change to the tool list invalidates the prompt cache for the whole request. MCP servers connect asynchronously, which means the first turns of a session often carry a partial tool list that grows as servers finish connecting, and each change re-prefills everything behind it.
With ENABLE_TOOL_SEARCH set, the agent receives a short summary of the available tools and loads full definitions on demand, at the cost of one extra round-trip per search.
Next steps
Inference modes
Realtime, async, and completion windows.
API support matrix
What /v1/messages accepts and returns.