Skip to content

AnthropicCacheControlValidator

Namespace: Vercel.AI.Anthropic

public sealed class AnthropicCacheControlValidator

Reads cache_control and enforces Anthropic’s four-breakpoint limit.

Inheritance: object

View source

public AnthropicCacheControlValidator(string providerOptionsName = "anthropic")

Creates a validator. <code class=“paramref”>providerOptionsName</code> is read before anthropic.

Parameters

Name Type Description
providerOptionsName string

View source

public IReadOnlyList<AnthropicWarning> Warnings { get; }

Warnings collected while reading cache controls.

Value: IReadOnlyList<AnthropicWarning>

View source

public JsonObject? Get(JsonElement? providerMetadata, string contextType, bool canCache)

Returns the cache control object when this context may cache it.

Parameters

Name Type Description
providerMetadata JsonElement?
contextType string
canCache bool

Returns: JsonObject

View source

public static JsonObject? Read(JsonElement? providerMetadata)

Reads cacheControl or cache_control from Anthropic provider metadata.

Parameters

Name Type Description
providerMetadata JsonElement?

Returns: JsonObject

View source

public static JsonObject? Read(JsonElement? providerMetadata, string providerOptionsName)

Reads the cache control from <code class=“paramref”>providerOptionsName</code>, falling back to the anthropic namespace.

Parameters

Name Type Description
providerMetadata JsonElement?
providerOptionsName string

Returns: JsonObject

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product