OCaml Claude SDK using Eio and Jsont
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** Structured output wire format implementation. *)
7
8type t = { json_schema : Jsont.json }
9
10let of_json_schema schema = { json_schema = schema }
11let to_json_schema t = t.json_schema
12
13(* Codec for serializing structured output format to wire protocol *)
14let jsont : t Jsont.t =
15 Jsont.Object.map ~kind:"StructuredOutput" (fun json_schema -> { json_schema })
16 |> Jsont.Object.mem "jsonSchema" Jsont.json ~enc:(fun t -> t.json_schema)
17 |> Jsont.Object.finish