Reference Client
RequestOptions
Settings for one call. Anything left unset falls back to the client's
AnthropicConfig.
Reference#
RequestOptions#
final case class RequestOptions private (
timeout: Option[FiniteDuration],
retryPolicy: Option[RetryPolicy],
betas: Set[Beta],
headers: List[(String, String)],
query: List[(String, String)],
conversationId: Option[String]
)
val default: RequestOptions
withX methods#
def withTimeout(d: FiniteDuration): RequestOptions
def withRetryPolicy(p: RetryPolicy): RequestOptions
def withMaxRetries(n: Int): RequestOptions
def withBetas(bs: Beta*): RequestOptions
def withHeader(name: String, value: String): RequestOptions
def withQueryParam(name: String, value: String): RequestOptions
def withConversationId(id: String): RequestOptions
withTimeout: this call's timeout, instead of the client's.withRetryPolicy, withMaxRetries: this call's retries.withBetas: beta features for this call, added to the client's.withHeader, withQueryParam: an extra header or query parameter.withConversationId: recorded asgen_ai.conversation.idon the call's span, to group the calls of one conversation.
ApiResponse[A]#
final case class ApiResponse[A] private[anthropic4s] (
value: A,
status: Int,
headers: List[(String, String)],
requestId: Option[String]
)
def header(name: String): Option[String]
What createRaw returns: the decoded reply with its status, headers and request id.
Caveats
headerlooks the name up case-insensitively.
Usage#
One call with its own settings#
RequestOptions.default.withTimeout(30.seconds).withBetas(Beta.TaskBudgets)
Every method on messages takes the options as its second argument.
Every signature and example on this page is copied, character for character, from the public source of anthropic4s and its Scaladoc. The complete API, every type included, is in the Scaladoc of each module.