anthropic4s
GitHub

Reference Client

RequestOptions

Settings for one call. Anything left unset falls back to the client's AnthropicConfig.

Reference#

RequestOptions#

core · AnthropicConfig.scala
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#

core · AnthropicConfig.scala
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

ApiResponse[A]#

core · AnthropicConfig.scala
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

Usage#

One call with its own settings#

core · AnthropicConfig.scala
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.