Reasoning & Prompt Caching
Unlock frontier multi-step reasoning (gpt-5, o3, Claude Extended Thinking, Gemini 2.5 Thinking, DeepSeek-R1) while keeping long-context agent bills predictable with prompt caching.
Controlling Reasoning Depth
bash
curl https://api.vanix.io/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VANIX_API_KEY" \
-d '{
"model": "o3-mini",
"reasoning_effort": "medium",
"max_completion_tokens": 2048,
"messages": [{"role": "user", "content": "Design a lock-free token bucket rate limiter in Go."}]
}'bash
curl https://api.vanix.io/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: $VANIX_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 8000,
"thinking": {"type": "enabled", "budget_tokens": 4096},
"messages": [{"role": "user", "content": "Audit this SQL migration for zero-downtime lock hazards."}]
}'Prompt Caching
Repeated static prefixes—such as long system instructions, tool schemas, repository context, or RAG policy documents—can be cached upstream for 50%–90% lower input token costs and dramatically faster TTFT.
| Provider | Caching Mode | Minimum Prefix | Telemetry Field |
|---|---|---|---|
| OpenAI | Automatic on identical prefixes | 1,024 tokens | usage.prompt_tokens_details.cached_tokens |
| Anthropic | Explicit cache_control: {"type": "ephemeral"} | 1,024–2,048 tokens | usage.cache_creation_input_tokens & cache_read_input_tokens |
| Google Gemini | Implicit / Context Caching | Model-dependent | usageMetadata.cachedContentTokenCount |
Anthropic Explicit Cache Breakpoint Example
json
{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"system": [
{
"type": "text",
"text": "<large static codebase rules and API specification exceeding 1,024 tokens>",
"cache_control": { "type": "ephemeral" }
}
],
"messages": [
{ "role": "user", "content": "Review middleware/rate-limit.go for race conditions." }
]
}Three Rules for High Cache Hit Rates
- Keep prefixes byte-identical: Place timestamps, user IDs, and dynamic RAG snippets at the end of the prompt—never inside the static
systemblock. - Stabilize tool definitions: Sort
tools[]deterministically so schema order never churns between turns. - Preserve channel affinity: Follow our Channel Affinity Guide so consecutive agent turns route to the same upstream provider cache.