Skip to main content
Valar’s 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

Point the SDK at Valar. Use auth_token (sends Authorization: Bearer) — or api_key (sends x-api-key); Valar accepts both.
The full Anthropic surface is supported — 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 thinking or output_config.effort (low / medium / high / xhigh / max). 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.
Accepted values are "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 has no background parameter, so a synchronous flex call blocks for up to 5 minutes and may 504 at the gateway’s wait ceiling. For flex work, use the Responses API with background=true, which returns a queued response you poll for later.

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 the X-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

Set ENABLE_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.