diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CacheControl.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CacheControl.java new file mode 100644 index 000000000..5473e5a98 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CacheControl.java @@ -0,0 +1,345 @@ +/* + * Orchestration v2 + * Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Cache control directive for Anthropic prompt caching. Only applicable to Anthropic Claude models. + * When set, marks the content block as a cache breakpoint. + */ +// CHECKSTYLE:OFF +public class CacheControl +// CHECKSTYLE:ON +{ + /** Gets or Sets type */ + public enum TypeEnum { + /** The EPHEMERAL option of this CacheControl */ + EPHEMERAL("ephemeral"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this CacheControl */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type CacheControl + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty("type") + private TypeEnum type; + + /** + * Time-to-live for the cache entry. Default is \"5m\" (5 minutes). \"1h\" (1 + * hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, Sonnet 4.5). + */ + public enum TtlEnum { + /** The _5M option of this CacheControl */ + _5M("5m"), + + /** The _1H option of this CacheControl */ + _1H("1h"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this CacheControl */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TtlEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type CacheControl + */ + @JsonCreator + @Nonnull + public static TtlEnum fromValue(@Nonnull final String value) { + for (TtlEnum b : TtlEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty("ttl") + private TtlEnum ttl; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for CacheControl. */ + protected CacheControl() {} + + /** + * Set the type of this {@link CacheControl} instance and return the same instance. + * + * @param type The type of this {@link CacheControl} + * @return The same instance of this {@link CacheControl} class + */ + @Nonnull + public CacheControl type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type The type of this {@link CacheControl} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link CacheControl} instance. + * + * @param type The type of this {@link CacheControl} + */ + public void setType(@Nonnull final TypeEnum type) { + this.type = type; + } + + /** + * Set the ttl of this {@link CacheControl} instance and return the same instance. + * + * @param ttl Time-to-live for the cache entry. Default is \"5m\" (5 minutes). + * \"1h\" (1 hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, + * Sonnet 4.5). + * @return The same instance of this {@link CacheControl} class + */ + @Nonnull + public CacheControl ttl(@Nullable final TtlEnum ttl) { + this.ttl = ttl; + return this; + } + + /** + * Time-to-live for the cache entry. Default is \"5m\" (5 minutes). \"1h\" (1 + * hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, Sonnet 4.5). + * + * @return ttl The ttl of this {@link CacheControl} instance. + */ + @Nonnull + public TtlEnum getTtl() { + return ttl; + } + + /** + * Set the ttl of this {@link CacheControl} instance. + * + * @param ttl Time-to-live for the cache entry. Default is \"5m\" (5 minutes). + * \"1h\" (1 hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, + * Sonnet 4.5). + */ + public void setTtl(@Nullable final TtlEnum ttl) { + this.ttl = ttl; + } + + /** + * Get the names of the unrecognizable properties of the {@link CacheControl}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link CacheControl} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("CacheControl has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link CacheControl} instance including unrecognized + * properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (type != null) declaredFields.put("type", type); + if (ttl != null) declaredFields.put("ttl", ttl); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link CacheControl} instance. If the map previously + * contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CacheControl cacheControl = (CacheControl) o; + return Objects.equals(this.cloudSdkCustomFields, cacheControl.cloudSdkCustomFields) + && Objects.equals(this.type, cacheControl.type) + && Objects.equals(this.ttl, cacheControl.ttl); + } + + @Override + public int hashCode() { + return Objects.hash(type, ttl, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CacheControl {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" ttl: ").append(toIndentedString(ttl)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link CacheControl} instance + * with all required arguments. + */ + public static Builder create() { + return (type) -> new CacheControl().type(type); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the type of this {@link CacheControl} instance. + * + * @param type The type of this {@link CacheControl} + * @return The CacheControl instance. + */ + CacheControl type(@Nonnull final TypeEnum type); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CacheCreationTokenDetails.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CacheCreationTokenDetails.java new file mode 100644 index 000000000..a6bd62e6a --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CacheCreationTokenDetails.java @@ -0,0 +1,222 @@ +/* + * Orchestration v2 + * Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Breakdown of cache creation tokens by TTL (Anthropic only). */ +// CHECKSTYLE:OFF +public class CacheCreationTokenDetails +// CHECKSTYLE:ON +{ + @JsonProperty("ephemeral_5m_input_tokens") + private Integer ephemeral5mInputTokens; + + @JsonProperty("ephemeral_1h_input_tokens") + private Integer ephemeral1hInputTokens; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for CacheCreationTokenDetails. */ + protected CacheCreationTokenDetails() {} + + /** + * Set the ephemeral5mInputTokens of this {@link CacheCreationTokenDetails} instance and return + * the same instance. + * + * @param ephemeral5mInputTokens Tokens cached with 5-minute TTL. + * @return The same instance of this {@link CacheCreationTokenDetails} class + */ + @Nonnull + public CacheCreationTokenDetails ephemeral5mInputTokens( + @Nullable final Integer ephemeral5mInputTokens) { + this.ephemeral5mInputTokens = ephemeral5mInputTokens; + return this; + } + + /** + * Tokens cached with 5-minute TTL. + * + * @return ephemeral5mInputTokens The ephemeral5mInputTokens of this {@link + * CacheCreationTokenDetails} instance. + */ + @Nonnull + public Integer getEphemeral5mInputTokens() { + return ephemeral5mInputTokens; + } + + /** + * Set the ephemeral5mInputTokens of this {@link CacheCreationTokenDetails} instance. + * + * @param ephemeral5mInputTokens Tokens cached with 5-minute TTL. + */ + public void setEphemeral5mInputTokens(@Nullable final Integer ephemeral5mInputTokens) { + this.ephemeral5mInputTokens = ephemeral5mInputTokens; + } + + /** + * Set the ephemeral1hInputTokens of this {@link CacheCreationTokenDetails} instance and return + * the same instance. + * + * @param ephemeral1hInputTokens Tokens cached with 1-hour TTL. + * @return The same instance of this {@link CacheCreationTokenDetails} class + */ + @Nonnull + public CacheCreationTokenDetails ephemeral1hInputTokens( + @Nullable final Integer ephemeral1hInputTokens) { + this.ephemeral1hInputTokens = ephemeral1hInputTokens; + return this; + } + + /** + * Tokens cached with 1-hour TTL. + * + * @return ephemeral1hInputTokens The ephemeral1hInputTokens of this {@link + * CacheCreationTokenDetails} instance. + */ + @Nonnull + public Integer getEphemeral1hInputTokens() { + return ephemeral1hInputTokens; + } + + /** + * Set the ephemeral1hInputTokens of this {@link CacheCreationTokenDetails} instance. + * + * @param ephemeral1hInputTokens Tokens cached with 1-hour TTL. + */ + public void setEphemeral1hInputTokens(@Nullable final Integer ephemeral1hInputTokens) { + this.ephemeral1hInputTokens = ephemeral1hInputTokens; + } + + /** + * Get the names of the unrecognizable properties of the {@link CacheCreationTokenDetails}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link CacheCreationTokenDetails} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "CacheCreationTokenDetails has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link CacheCreationTokenDetails} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (ephemeral5mInputTokens != null) + declaredFields.put("ephemeral5mInputTokens", ephemeral5mInputTokens); + if (ephemeral1hInputTokens != null) + declaredFields.put("ephemeral1hInputTokens", ephemeral1hInputTokens); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link CacheCreationTokenDetails} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CacheCreationTokenDetails cacheCreationTokenDetails = (CacheCreationTokenDetails) o; + return Objects.equals(this.cloudSdkCustomFields, cacheCreationTokenDetails.cloudSdkCustomFields) + && Objects.equals( + this.ephemeral5mInputTokens, cacheCreationTokenDetails.ephemeral5mInputTokens) + && Objects.equals( + this.ephemeral1hInputTokens, cacheCreationTokenDetails.ephemeral1hInputTokens); + } + + @Override + public int hashCode() { + return Objects.hash(ephemeral5mInputTokens, ephemeral1hInputTokens, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CacheCreationTokenDetails {\n"); + sb.append(" ephemeral5mInputTokens: ") + .append(toIndentedString(ephemeral5mInputTokens)) + .append("\n"); + sb.append(" ephemeral1hInputTokens: ") + .append(toIndentedString(ephemeral1hInputTokens)) + .append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Create a new {@link CacheCreationTokenDetails} instance. No arguments are required. */ + public static CacheCreationTokenDetails create() { + return new CacheCreationTokenDetails(); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTool.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTool.java index e5c505f09..06c98f84a 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTool.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTool.java @@ -90,6 +90,9 @@ public static TypeEnum fromValue(@Nonnull final String value) { @JsonProperty("function") private FunctionObject function; + @JsonProperty("cache_control") + private CacheControl cacheControl; + @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -158,6 +161,37 @@ public void setFunction(@Nonnull final FunctionObject function) { this.function = function; } + /** + * Set the cacheControl of this {@link ChatCompletionTool} instance and return the same instance. + * + * @param cacheControl The cacheControl of this {@link ChatCompletionTool} + * @return The same instance of this {@link ChatCompletionTool} class + */ + @Nonnull + public ChatCompletionTool cacheControl(@Nullable final CacheControl cacheControl) { + this.cacheControl = cacheControl; + return this; + } + + /** + * Get cacheControl + * + * @return cacheControl The cacheControl of this {@link ChatCompletionTool} instance. + */ + @Nonnull + public CacheControl getCacheControl() { + return cacheControl; + } + + /** + * Set the cacheControl of this {@link ChatCompletionTool} instance. + * + * @param cacheControl The cacheControl of this {@link ChatCompletionTool} + */ + public void setCacheControl(@Nullable final CacheControl cacheControl) { + this.cacheControl = cacheControl; + } + /** * Get the names of the unrecognizable properties of the {@link ChatCompletionTool}. * @@ -198,6 +232,7 @@ public Map toMap() { final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); if (type != null) declaredFields.put("type", type); if (function != null) declaredFields.put("function", function); + if (cacheControl != null) declaredFields.put("cacheControl", cacheControl); return declaredFields; } @@ -224,12 +259,13 @@ public boolean equals(@Nullable final java.lang.Object o) { final ChatCompletionTool chatCompletionTool = (ChatCompletionTool) o; return Objects.equals(this.cloudSdkCustomFields, chatCompletionTool.cloudSdkCustomFields) && Objects.equals(this.type, chatCompletionTool.type) - && Objects.equals(this.function, chatCompletionTool.function); + && Objects.equals(this.function, chatCompletionTool.function) + && Objects.equals(this.cacheControl, chatCompletionTool.cacheControl); } @Override public int hashCode() { - return Objects.hash(type, function, cloudSdkCustomFields); + return Objects.hash(type, function, cacheControl, cloudSdkCustomFields); } @Override @@ -239,6 +275,7 @@ public String toString() { sb.append("class ChatCompletionTool {\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" function: ").append(toIndentedString(function)).append("\n"); + sb.append(" cacheControl: ").append(toIndentedString(cacheControl)).append("\n"); cloudSdkCustomFields.forEach( (k, v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TextContent.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TextContent.java index b1e2e1b36..a91da6ae9 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TextContent.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TextContent.java @@ -90,6 +90,9 @@ public static TypeEnum fromValue(@Nonnull final String value) { @JsonProperty("text") private String text; + @JsonProperty("cache_control") + private CacheControl cacheControl; + @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -158,6 +161,37 @@ public void setText(@Nonnull final String text) { this.text = text; } + /** + * Set the cacheControl of this {@link TextContent} instance and return the same instance. + * + * @param cacheControl The cacheControl of this {@link TextContent} + * @return The same instance of this {@link TextContent} class + */ + @Nonnull + public TextContent cacheControl(@Nullable final CacheControl cacheControl) { + this.cacheControl = cacheControl; + return this; + } + + /** + * Get cacheControl + * + * @return cacheControl The cacheControl of this {@link TextContent} instance. + */ + @Nonnull + public CacheControl getCacheControl() { + return cacheControl; + } + + /** + * Set the cacheControl of this {@link TextContent} instance. + * + * @param cacheControl The cacheControl of this {@link TextContent} + */ + public void setCacheControl(@Nullable final CacheControl cacheControl) { + this.cacheControl = cacheControl; + } + /** * Get the names of the unrecognizable properties of the {@link TextContent}. * @@ -198,6 +232,7 @@ public Map toMap() { final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); if (type != null) declaredFields.put("type", type); if (text != null) declaredFields.put("text", text); + if (cacheControl != null) declaredFields.put("cacheControl", cacheControl); return declaredFields; } @@ -224,12 +259,13 @@ public boolean equals(@Nullable final java.lang.Object o) { final TextContent textContent = (TextContent) o; return Objects.equals(this.cloudSdkCustomFields, textContent.cloudSdkCustomFields) && Objects.equals(this.type, textContent.type) - && Objects.equals(this.text, textContent.text); + && Objects.equals(this.text, textContent.text) + && Objects.equals(this.cacheControl, textContent.cacheControl); } @Override public int hashCode() { - return Objects.hash(type, text, cloudSdkCustomFields); + return Objects.hash(type, text, cacheControl, cloudSdkCustomFields); } @Override @@ -239,6 +275,7 @@ public String toString() { sb.append("class TextContent {\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" cacheControl: ").append(toIndentedString(cacheControl)).append("\n"); cloudSdkCustomFields.forEach( (k, v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsagePromptTokensDetails.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsagePromptTokensDetails.java index 43bd23553..e5f15b423 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsagePromptTokensDetails.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsagePromptTokensDetails.java @@ -34,6 +34,12 @@ public class TokenUsagePromptTokensDetails @JsonProperty("cached_tokens") private Integer cachedTokens; + @JsonProperty("cache_creation_tokens") + private Integer cacheCreationTokens; + + @JsonProperty("cache_creation_token_details") + private CacheCreationTokenDetails cacheCreationTokenDetails; + @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -104,6 +110,77 @@ public void setCachedTokens(@Nullable final Integer cachedTokens) { this.cachedTokens = cachedTokens; } + /** + * Set the cacheCreationTokens of this {@link TokenUsagePromptTokensDetails} instance and return + * the same instance. + * + * @param cacheCreationTokens Number of tokens written to the cache (Anthropic only). + * @return The same instance of this {@link TokenUsagePromptTokensDetails} class + */ + @Nonnull + public TokenUsagePromptTokensDetails cacheCreationTokens( + @Nullable final Integer cacheCreationTokens) { + this.cacheCreationTokens = cacheCreationTokens; + return this; + } + + /** + * Number of tokens written to the cache (Anthropic only). + * + * @return cacheCreationTokens The cacheCreationTokens of this {@link + * TokenUsagePromptTokensDetails} instance. + */ + @Nonnull + public Integer getCacheCreationTokens() { + return cacheCreationTokens; + } + + /** + * Set the cacheCreationTokens of this {@link TokenUsagePromptTokensDetails} instance. + * + * @param cacheCreationTokens Number of tokens written to the cache (Anthropic only). + */ + public void setCacheCreationTokens(@Nullable final Integer cacheCreationTokens) { + this.cacheCreationTokens = cacheCreationTokens; + } + + /** + * Set the cacheCreationTokenDetails of this {@link TokenUsagePromptTokensDetails} instance and + * return the same instance. + * + * @param cacheCreationTokenDetails The cacheCreationTokenDetails of this {@link + * TokenUsagePromptTokensDetails} + * @return The same instance of this {@link TokenUsagePromptTokensDetails} class + */ + @Nonnull + public TokenUsagePromptTokensDetails cacheCreationTokenDetails( + @Nullable final CacheCreationTokenDetails cacheCreationTokenDetails) { + this.cacheCreationTokenDetails = cacheCreationTokenDetails; + return this; + } + + /** + * Get cacheCreationTokenDetails + * + * @return cacheCreationTokenDetails The cacheCreationTokenDetails of this {@link + * TokenUsagePromptTokensDetails} instance. + */ + @Nonnull + public CacheCreationTokenDetails getCacheCreationTokenDetails() { + return cacheCreationTokenDetails; + } + + /** + * Set the cacheCreationTokenDetails of this {@link TokenUsagePromptTokensDetails} instance. + * + * @param cacheCreationTokenDetails The cacheCreationTokenDetails of this {@link + * TokenUsagePromptTokensDetails} + */ + public void setCacheCreationTokenDetails( + @Nullable final CacheCreationTokenDetails cacheCreationTokenDetails) { + this.cacheCreationTokenDetails = cacheCreationTokenDetails; + } + /** * Get the names of the unrecognizable properties of the {@link TokenUsagePromptTokensDetails}. * @@ -146,6 +223,9 @@ public Map toMap() { final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); if (audioTokens != null) declaredFields.put("audioTokens", audioTokens); if (cachedTokens != null) declaredFields.put("cachedTokens", cachedTokens); + if (cacheCreationTokens != null) declaredFields.put("cacheCreationTokens", cacheCreationTokens); + if (cacheCreationTokenDetails != null) + declaredFields.put("cacheCreationTokenDetails", cacheCreationTokenDetails); return declaredFields; } @@ -175,12 +255,22 @@ public boolean equals(@Nullable final java.lang.Object o) { return Objects.equals( this.cloudSdkCustomFields, tokenUsagePromptTokensDetails.cloudSdkCustomFields) && Objects.equals(this.audioTokens, tokenUsagePromptTokensDetails.audioTokens) - && Objects.equals(this.cachedTokens, tokenUsagePromptTokensDetails.cachedTokens); + && Objects.equals(this.cachedTokens, tokenUsagePromptTokensDetails.cachedTokens) + && Objects.equals( + this.cacheCreationTokens, tokenUsagePromptTokensDetails.cacheCreationTokens) + && Objects.equals( + this.cacheCreationTokenDetails, + tokenUsagePromptTokensDetails.cacheCreationTokenDetails); } @Override public int hashCode() { - return Objects.hash(audioTokens, cachedTokens, cloudSdkCustomFields); + return Objects.hash( + audioTokens, + cachedTokens, + cacheCreationTokens, + cacheCreationTokenDetails, + cloudSdkCustomFields); } @Override @@ -190,6 +280,12 @@ public String toString() { sb.append("class TokenUsagePromptTokensDetails {\n"); sb.append(" audioTokens: ").append(toIndentedString(audioTokens)).append("\n"); sb.append(" cachedTokens: ").append(toIndentedString(cachedTokens)).append("\n"); + sb.append(" cacheCreationTokens: ") + .append(toIndentedString(cacheCreationTokens)) + .append("\n"); + sb.append(" cacheCreationTokenDetails: ") + .append(toIndentedString(cacheCreationTokenDetails)) + .append("\n"); cloudSdkCustomFields.forEach( (k, v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/UserChatMessageContentItem.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/UserChatMessageContentItem.java index 2de971c1a..c3f1d9721 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/UserChatMessageContentItem.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/UserChatMessageContentItem.java @@ -102,6 +102,9 @@ public static TypeEnum fromValue(@Nonnull final String value) { @JsonProperty("file") private FileContent _file; + @JsonProperty("cache_control") + private CacheControl cacheControl; + @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -233,6 +236,38 @@ public void setFile(@Nullable final FileContent _file) { this._file = _file; } + /** + * Set the cacheControl of this {@link UserChatMessageContentItem} instance and return the same + * instance. + * + * @param cacheControl The cacheControl of this {@link UserChatMessageContentItem} + * @return The same instance of this {@link UserChatMessageContentItem} class + */ + @Nonnull + public UserChatMessageContentItem cacheControl(@Nullable final CacheControl cacheControl) { + this.cacheControl = cacheControl; + return this; + } + + /** + * Get cacheControl + * + * @return cacheControl The cacheControl of this {@link UserChatMessageContentItem} instance. + */ + @Nonnull + public CacheControl getCacheControl() { + return cacheControl; + } + + /** + * Set the cacheControl of this {@link UserChatMessageContentItem} instance. + * + * @param cacheControl The cacheControl of this {@link UserChatMessageContentItem} + */ + public void setCacheControl(@Nullable final CacheControl cacheControl) { + this.cacheControl = cacheControl; + } + /** * Get the names of the unrecognizable properties of the {@link UserChatMessageContentItem}. * @@ -277,6 +312,7 @@ public Map toMap() { if (text != null) declaredFields.put("text", text); if (imageUrl != null) declaredFields.put("imageUrl", imageUrl); if (_file != null) declaredFields.put("_file", _file); + if (cacheControl != null) declaredFields.put("cacheControl", cacheControl); return declaredFields; } @@ -306,12 +342,13 @@ public boolean equals(@Nullable final java.lang.Object o) { && Objects.equals(this.type, userChatMessageContentItem.type) && Objects.equals(this.text, userChatMessageContentItem.text) && Objects.equals(this.imageUrl, userChatMessageContentItem.imageUrl) - && Objects.equals(this._file, userChatMessageContentItem._file); + && Objects.equals(this._file, userChatMessageContentItem._file) + && Objects.equals(this.cacheControl, userChatMessageContentItem.cacheControl); } @Override public int hashCode() { - return Objects.hash(type, text, imageUrl, _file, cloudSdkCustomFields); + return Objects.hash(type, text, imageUrl, _file, cacheControl, cloudSdkCustomFields); } @Override @@ -323,6 +360,7 @@ public String toString() { sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" imageUrl: ").append(toIndentedString(imageUrl)).append("\n"); sb.append(" _file: ").append(toIndentedString(_file)).append("\n"); + sb.append(" cacheControl: ").append(toIndentedString(cacheControl)).append("\n"); cloudSdkCustomFields.forEach( (k, v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); diff --git a/orchestration/src/main/resources/spec/orchestration.yaml b/orchestration/src/main/resources/spec/orchestration.yaml index 982a3d456..896d5eabc 100644 --- a/orchestration/src/main/resources/spec/orchestration.yaml +++ b/orchestration/src/main/resources/spec/orchestration.yaml @@ -565,6 +565,8 @@ components: $ref: "#/components/schemas/ImageContentUrl" file: $ref: "#/components/schemas/FileContent" + cache_control: + $ref: "#/components/schemas/CacheControl" required: - type ImageContentUrl: @@ -692,6 +694,37 @@ components: enum: ["text"] text: type: string + cache_control: + $ref: "#/components/schemas/CacheControl" + CacheControl: + type: object + description: > + Cache control directive for Anthropic prompt caching. Only applicable to + Anthropic Claude models. When set, marks the content block as a cache breakpoint. + additionalProperties: false + required: + - type + properties: + type: + type: string + enum: ["ephemeral"] + ttl: + type: string + description: > + Time-to-live for the cache entry. Default is "5m" (5 minutes). + "1h" (1 hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, Sonnet 4.5). + enum: ["5m", "1h"] + CacheCreationTokenDetails: + type: object + description: Breakdown of cache creation tokens by TTL (Anthropic only). + additionalProperties: false + properties: + ephemeral_5m_input_tokens: + type: integer + description: Tokens cached with 5-minute TTL. + ephemeral_1h_input_tokens: + type: integer + description: Tokens cached with 1-hour TTL. ChatDelta: type: object required: @@ -1096,6 +1129,12 @@ components: cached_tokens: type: integer description: Cached tokens present in the prompt. + cache_creation_tokens: + type: integer + description: > + Number of tokens written to the cache (Anthropic only). + cache_creation_token_details: + $ref: "#/components/schemas/CacheCreationTokenDetails" completion_tokens_details: type: object description: Breakdown of tokens used in a completion. @@ -1304,6 +1343,8 @@ components: description: The type of the tool. Currently, only `function` is supported. function: $ref: "#/components/schemas/FunctionObject" + cache_control: + $ref: "#/components/schemas/CacheControl" required: - type - function