Docs Background
Design notes
The API ships new fields and block types constantly. Most of the design is about not breaking when it does.
Forward compatible#
Unknown content blocks and stream events are kept and sent back untouched; every object carries unmodeled
fields in extras; enums are open (Model.of("..."), StopReason.of("...")).
request.withExtra(key, json) sends anything this SDK does not model yet.
Binary compatible by construction#
SDK types have private constructors and withX methods, so a new API field does not break code
compiled against an older version. Your own case classes are untouched. Every 1.x release is binary compatible
with 1.0.0, and MiMa checks that in CI.
One type tree#
Beta features are flags (RequestOptions.withBetas), not a parallel set of types.
No sampling parameters#
temperature, top_p and top_k are rejected by the current API version, so
they are not modeled.
Build choices#
- Pure Scala
- No dependency on the Java SDK, so no Kotlin runtime and no Jackson version pinning in Play apps.
- Effects
- Tagless-final
F[_]on Cats Effect 3. Streams arefs2.Stream, the client is aResource. - Codecs
- Hand-written circe codecs through a small field DSL. Same source on Scala 2.13 and 3, no macros.
- Telemetry
- Traces only in v1. Prompt and response content is exported only in opt-in content mode.
What is covered#
Covered
- Messages: create, stream, count tokens
- Tools
- Structured outputs
- Batches
- Files
- Models
Not yet
- Bedrock / Vertex / Foundry
- Managed Agents
- The Admin API
- Scala 3 beyond the wire model
Batches, Files and Models have no chapter here yet: reach them through client, or from Play through
anthropic.client. Issues and pull requests are welcome on
GitHub.
Every snippet on this page is copied, character for character, from the
anthropic4s repository: its README, docs/play.md or examples/,
which compiles with the build.