gen_ai_hub.orchestration_v2.models.cache_control module¶
Cache control for prompt caching on supported models.
- class gen_ai_hub.orchestration_v2.models.cache_control.CacheControl(*, type: Literal['ephemeral'], ttl: Literal['5m', '1h'] | None = None)¶
Bases:
ABCBaseModelMarks a message content block or tool definition for prompt caching.
When attached to a content block, the model stores intermediate computation results for that content and reuses them on subsequent requests within the TTL window, reducing both latency and token costs.
Attach
CacheControldirectly to a content block (TextPart,ImagePart) or to aChatCompletionTool.- Parameters:
type –
"ephemeral"ttl – Cache duration.
"5m"(default) or"1h".
- type: Literal['ephemeral']¶
- ttl: Literal['5m', '1h'] | None¶
- serialize_wire_format(handler: Any) Dict[str, Any]¶
Serialize to the wire format, omitting
ttlwhen not set.- Returns:
{"type": "ephemeral"}or{"type": "ephemeral", "ttl": "<value>"}- Return type:
dict
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].