anthropic4s
GitHub

Reference Other APIs

Batches, Files and Models

The rest of the API, on client.batches, client.files and client.models.

Reference#

client.batches#

core · resources.scala
trait Batches[F[_]]
def create(requests: NonEmptyList[BatchRequest]): F[MessageBatch]
def retrieve(id: String): F[MessageBatch]
def list(params: ListParams): F[Page[MessageBatch]]
def list: F[Page[MessageBatch]]
def listAll: Stream[F, MessageBatch]
def cancel(id: String): F[MessageBatch]
def delete(id: String): F[Unit]
def results(id: String): Stream[F, BatchResult]
def awaitEnded(id: String, pollInterval: FiniteDuration): F[MessageBatch]
def awaitEnded(id: String): F[MessageBatch]

Caveats

core · resources.scala
for {
  batch <- client.batches.create(NonEmptyList.of(BatchRequest("q1", request1), BatchRequest("q2", request2)))
  _     <- client.batches.awaitEnded(batch.id)
  _     <- client.batches.results(batch.id).evalMap(handle).compile.drain
} yield ()

client.files#

core · resources.scala
trait Files[F[_]]
def upload(filename: String, mimeType: String, content: Stream[F, Byte]): F[FileMetadata]
def retrieveMetadata(id: String): F[FileMetadata]
def list(params: ListParams): F[Page[FileMetadata]]
def list: F[Page[FileMetadata]]
def listAll: Stream[F, FileMetadata]
def download(id: String): Stream[F, Byte]
def delete(id: String): F[Unit]

Caveats

core · resources.scala
for {
  file  <- client.files.upload("report.pdf", "application/pdf", Files[IO].readAll(path))
  reply <- client.messages.create(request.addMessages(MessageParam.user(
             ContentBlock.Document(Source.File(file.id)), ContentBlock.Text("Summarise this."))))
} yield reply

client.models#

core · AnthropicClient.scala
trait Models[F[_]]
def retrieve(model: Model): F[ModelInfo]
def list(params: ListParams): F[Page[ModelInfo]]
def list: F[Page[ModelInfo]]
def listAll: Stream[F, ModelInfo]

ListParams#

core · AnthropicClient.scala
def withLimit(n: Int): ListParams
def withAfterId(id: String): ListParams
def withBeforeId(id: String): ListParams

list returns one page; listAll streams every item, fetching pages as it goes.

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.