Core

What every LLM4S application uses, whatever else it builds on top: a client for a provider, a call, its Result, and the options around it.

Calling a model

  • Basic Usage - Get started with LLM calls, client creation, and error handling
  • Providers - Overview of supported providers and how to configure them
  • Error Handling - Work with Result[A] and LLMError: pattern matching, for-comprehensions, every error type, recovery and testing
  • Reliable LLM Calling - ReliableClient: retry policies, a circuit breaker, deadlines and local rate limiting around any client
  • Cost Controls - Thinking and reasoning effort per provider, provider-side prompt caching and service tiers
  • Caching - Cache embeddings (exact) and model responses (semantic): configuration, keys, TTL, eviction and what the cache reports
  • Your HTTP Client - llm4s-sttp sends the provider clients’ requests through the sttp backend your service already has

Prompts and typed replies

  • Typed Prompts - prompt"..." and system"...": values rendered by a type class checked at compile time, and untrusted input fenced
  • Structured Output - completeStructured: typed replies from a schema, which providers enforce it, and what a bad reply looks like
  • Derived Schemas - Write the type once: llm4s-schema-derivation builds the completeStructured schema from a case class with derives
  • JSON Libraries - Use circe, play-json, zio-json or jsoniter-scala with LLM4S: converting at the boundary, structured output and tools

Images, speech and decisions

  • Multimodal Content - Send images and documents in a user message or a tool result, and check before the request whether the provider takes them
  • Media Types - llm4s-media: the MediaType, MediaCategory and MediaSource vocabulary that multimodal messages, image generation and RAG extraction share
  • Capability-Typed Clients - Check once that a model can see images or call tools, and let the compiler refuse an unchecked client (experimental)
  • Image Generation - Generate images with OpenAI GPT Image, Stability AI, Hugging Face or a Stable Diffusion server
  • Speech - Speech-to-text (STT) and text-to-speech (TTS), local and cloud
  • STT Domain Model - STTOptions, WordTimestamp, Transcription and the STTError cases
  • Jev decision model - Ask TypeSafe’s Jev typed questions (Noul, Choice, Score) and get typed answers: a decision client, not a chat model

Testing and extending


Table of contents