package ocaml-ai-sdk

  1. Overview
  2. Docs
OCaml AI SDK - Provider abstraction for AI models

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ocaml-ai-sdk-0.6.3.tbz
sha256=0cc0a957784c295877b6bcc4f80c0dba0f6507d3c282e7d6cbd71038050376de
sha512=f8e082376b4de194a877d0df193892cdaa8139a4789f51eebac651acf8b6d4064b95242e158d86c1a32776d99130d43ed4c1119e2d54e738e93bdba2a6ad9a33

doc/ocaml-ai-sdk.ai_provider_anthropic/Ai_provider_anthropic/Thinking/index.html

Module Ai_provider_anthropic.ThinkingSource

Thinking configuration for Claude models.

Sourcetype budget_tokens = private int

Thinking budget — always >= 1024 tokens. Use budget or budget_exn to construct.

Sourceval budget : int -> (budget_tokens, string) result

Returns Error if budget < 1024.

Sourceval budget_exn : int -> budget_tokens

Raises Invalid_argument if budget < 1024.

Sourceval to_int : budget_tokens -> int

Extract the integer value.

Sourcetype display =
  1. | Summarized
  2. | Omitted
Sourcetype t =
  1. | Enabled of {
    1. budget_tokens : budget_tokens;
    2. display : display option;
    }
    (*

    Manual thinking with an explicit token budget. Among the models the catalog knows, only pre-adaptive ones accept it, and Claude Haiku 4.5 is the last of those; the adaptive generation (Fable 5, Mythos 5, Opus 5, Opus 4.8, Sonnet 5) rejects it, so use Adaptive with an effort level there. A custom model id has unknown capabilities, so the SDK passes manual budgets through untouched and the API decides. Manual thinking also cannot be combined with a forced tool choice.

    *)
  2. | Adaptive of {
    1. display : display option;
    }
    (*

    Adaptive thinking: the model decides how much to think, and Anthropic_options.effort sets how hard. This pair is the successor to Enabled's token budgets. There is no faithful conversion from a budget to an effort level, so the caller picks the level rather than the SDK guessing one. Pre-adaptive models reject Adaptive.

    *)
  3. | Disabled
    (*

    Turn thinking off. Not universally accepted: some models always think and reject it outright. On Claude Opus 5 it is accepted at any effort, but pairing it with Xhigh or Max lowers the effort to High and emits a warning rather than raising.

    *)

How a model should think.

Which constructors a model accepts depends on its catalog capabilities, and passing an unsupported one raises Invalid_argument before the request is sent, mirroring the 400 the API would return.

Leaving thinking unset is not the same as Disabled. Whether omission leaves thinking on depends on the model: Fable 5, Mythos 5, Opus 5, and Sonnet 5 think by default, while Opus 4.8 and Haiku 4.5 do not. Only Disabled asks for thinking to be turned off explicitly.