Module Chatoyant_provider.AnthropicSource

Raw Anthropic Messages API request shapes.

Sourcetype role =
  1. | User
  2. | Assistant
Sourcetype cache_ttl =
  1. | Ttl_5m
  2. | Ttl_1h
  3. | Cache_ttl of string
Sourcetype cache_control =
  1. | Ephemeral_cache of cache_ttl option
  2. | Raw_cache_control of Chatoyant_runtime.Json.t
    (*

    Prompt caching marker. Anthropic accepts cache_control at the request top level, on cacheable content blocks, and on tool definitions.

    *)
Sourcetype content_block =
  1. | Text of string
  2. | Cached_block of {
    1. block : content_block;
    2. cache_control : cache_control;
    }
  3. | Thinking of string
  4. | Redacted_thinking of string
  5. | Tool_use of {
    1. id : string;
    2. name : string;
    3. input : Chatoyant_runtime.Json.t;
    }
  6. | Tool_result of {
    1. tool_use_id : string;
    2. content : string;
    3. is_error : bool option;
    }
  7. | Server_tool_use of {
    1. id : string;
    2. name : string;
    3. input : Chatoyant_runtime.Json.t;
    4. raw : Chatoyant_runtime.Json.t;
    }
  8. | Web_search_tool_result of {
    1. tool_use_id : string;
    2. content : Chatoyant_runtime.Json.t;
    3. raw : Chatoyant_runtime.Json.t;
    }
  9. | Web_fetch_tool_result of {
    1. tool_use_id : string;
    2. content : Chatoyant_runtime.Json.t;
    3. raw : Chatoyant_runtime.Json.t;
    }
  10. | Code_execution_tool_result of {
    1. tool_use_id : string;
    2. content : Chatoyant_runtime.Json.t;
    3. raw : Chatoyant_runtime.Json.t;
    }
  11. | Container_upload of {
    1. file_id : string option;
    2. raw : Chatoyant_runtime.Json.t;
    }
  12. | Raw_block of Chatoyant_runtime.Json.t
Sourcetype message = {
  1. message_role : role;
  2. message_content : content_block list;
}
Sourcetype tool = {
  1. tool_name : string;
  2. tool_description : string option;
  3. input_schema : Chatoyant_runtime.Json.t;
  4. tool_cache_control : cache_control option;
}
Sourcetype tool_choice =
  1. | Auto
  2. | Any
  3. | Tool of string
  4. | No_tool
Sourcetype thinking =
  1. | Disabled
  2. | Adaptive of {
    1. display_summarized : bool;
    }
    (*

    Adaptive thinking for the Claude 4.6+ generation; display_summarized opts back into readable thinking summaries where the model defaults to omitted text.

    *)
  3. | Enabled of {
    1. budget_tokens : int;
    }
Sourcetype request = {
  1. model : string;
  2. messages : message list;
  3. system : string option;
  4. system_blocks : content_block list;
  5. max_tokens : int;
  6. stream : bool;
  7. temperature : float option;
  8. top_p : float option;
  9. top_k : int option;
  10. stop_sequences : string list;
  11. metadata_user_id : string option;
  12. tools : tool list;
  13. tool_choice : tool_choice option;
  14. thinking : thinking option;
  15. cache_control : cache_control option;
  16. extra : (string * Chatoyant_runtime.Json.t) list;
}
Sourcetype stop_reason =
  1. | End_turn
  2. | Max_tokens
  3. | Stop_sequence
  4. | Tool_use_stop
  5. | Pause_turn
  6. | Refusal
  7. | Unknown_stop of string
Sourcetype response = {
  1. response_id : string option;
  2. response_model : string option;
  3. response_role : role option;
  4. response_content : content_block list;
  5. response_stop_reason : stop_reason option;
  6. response_stop_sequence : string option;
  7. response_usage : usage;
  8. response_raw : Chatoyant_runtime.Json.t;
}
Sourcetype api_error = {
  1. error_type : string option;
  2. error_message : string;
  3. error_raw : Chatoyant_runtime.Json.t option;
}
Sourcetype model = {
  1. model_id : string;
  2. model_display_name : string option;
  3. model_created_at : string option;
  4. model_type : string option;
  5. model_raw : Chatoyant_runtime.Json.t;
}
Sourcetype model_list = {
  1. models : model list;
  2. first_id : string option;
  3. last_id : string option;
  4. has_more : bool;
  5. raw : Chatoyant_runtime.Json.t;
}
Sourcetype batch_request = {
  1. custom_id : string;
  2. params : request;
}
Sourcetype batch_counts = {
  1. processing : int;
  2. succeeded : int;
  3. errored : int;
  4. canceled : int;
  5. expired : int;
}
Sourcetype batch_status =
  1. | In_progress
  2. | Canceling
  3. | Ended
  4. | Unknown_batch_status of string
Sourcetype message_batch = {
  1. batch_id : string;
  2. batch_type : string option;
  3. processing_status : batch_status;
  4. request_counts : batch_counts;
  5. ended_at : string option;
  6. created_at : string option;
  7. expires_at : string option;
  8. archived_at : string option;
  9. cancel_initiated_at : string option;
  10. results_url : string option;
  11. raw : Chatoyant_runtime.Json.t;
}
Sourcetype batch_list = {
  1. batches : message_batch list;
  2. first_id : string option;
  3. last_id : string option;
  4. has_more : bool;
  5. raw : Chatoyant_runtime.Json.t;
}
Sourcetype batch_result =
  1. | Batch_succeeded of response
  2. | Batch_errored of api_error
  3. | Batch_canceled
  4. | Batch_expired
  5. | Batch_unknown of Chatoyant_runtime.Json.t
Sourcetype batch_result_line = {
  1. result_custom_id : string;
  2. result : batch_result;
  3. result_raw : Chatoyant_runtime.Json.t;
}
Sourcetype file_upload = {
  1. upload_filename : string;
  2. upload_content_type : string option;
  3. upload_body : string;
}
Sourcetype file_metadata = {
  1. file_id : string;
  2. file_type : string option;
  3. filename : string option;
  4. mime_type : string option;
  5. size_bytes : int option;
  6. created_at : string option;
  7. downloadable : bool option;
  8. file_raw : Chatoyant_runtime.Json.t;
}
Sourcetype file_list = {
  1. files : file_metadata list;
  2. first_id : string option;
  3. last_id : string option;
  4. has_more : bool;
  5. raw : Chatoyant_runtime.Json.t;
}
Sourcetype file_delete = {
  1. deleted_file_id : string option;
  2. deleted : bool;
  3. raw : Chatoyant_runtime.Json.t;
}
Sourcetype stream_delta =
  1. | Text_delta of string
  2. | Thinking_delta of string
  3. | Signature_delta of string
  4. | Input_json_delta of string
  5. | Unknown_delta of Chatoyant_runtime.Json.t
Sourcetype stream_event =
  1. | Message_start of response
  2. | Content_block_start of {
    1. index : int;
    2. block : content_block;
    }
  3. | Content_block_delta of {
    1. index : int;
    2. delta : stream_delta;
    }
  4. | Content_block_stop of int
  5. | Message_delta of {
    1. stop_reason : stop_reason option;
    2. stop_sequence : string option;
    3. usage : usage;
    }
  6. | Message_stop
  7. | Ping
  8. | Error of api_error
  9. | Unknown_event of {
    1. event_type : string option;
    2. raw : Chatoyant_runtime.Json.t;
    }
Sourcetype stream_state
Sourceval empty_stream_state : stream_state
Sourceval apply_stream_event : stream_state -> stream_event -> stream_state
Sourceval stream_state_to_response : stream_state -> response
Sourceval role_to_string : role -> string
Sourceval cache_ttl_to_string : cache_ttl -> string
Sourceval cache_control_json : cache_control -> Chatoyant_runtime.Json.t
Sourceval ephemeral_cache_control : ?ttl:cache_ttl -> unit -> cache_control
Sourceval content_block_json : content_block -> Chatoyant_runtime.Json.t
Sourceval web_search_tool_json : ?name:string -> ?cache_control:cache_control -> ?max_uses:int -> ?allowed_domains:string list -> ?blocked_domains:string list -> ?user_location:Chatoyant_runtime.Json.t -> unit -> Chatoyant_runtime.Json.t
Sourceval web_fetch_tool_json : ?name:string -> ?cache_control:cache_control -> unit -> Chatoyant_runtime.Json.t
Sourceval code_execution_tool_json : ?name:string -> ?cache_control:cache_control -> unit -> Chatoyant_runtime.Json.t
Sourceval request_json_with_raw_tools : request -> Chatoyant_runtime.Json.t list -> Chatoyant_runtime.Json.t
Sourceval authorization_headers : api_key:string -> (string * string) list
Sourceval content_block_of_json : Chatoyant_runtime.Json.t -> content_block
Sourceval response_of_json : Chatoyant_runtime.Json.t -> response
Sourceval api_error_of_json : Chatoyant_runtime.Json.t -> api_error
Sourceval model_of_json : Chatoyant_runtime.Json.t -> model
Sourceval model_list_of_json : Chatoyant_runtime.Json.t -> model_list
Sourceval batch_create_json : batch_request list -> Chatoyant_runtime.Json.t
Sourceval message_batch_of_json : Chatoyant_runtime.Json.t -> message_batch
Sourceval batch_list_of_json : Chatoyant_runtime.Json.t -> batch_list
Sourceval batch_result_line_of_json : Chatoyant_runtime.Json.t -> batch_result_line
Sourceval batch_result_lines_of_jsonl : string -> (batch_result_line list, string) result
Sourceval file_metadata_of_json : Chatoyant_runtime.Json.t -> file_metadata
Sourceval file_list_of_json : Chatoyant_runtime.Json.t -> file_list
Sourceval file_delete_of_json : Chatoyant_runtime.Json.t -> file_delete
Sourceval stream_event_of_sse : Chatoyant_runtime.Sse.event -> (stream_event, string) result
Sourceval stream_events_of_chunks : string list -> (stream_event list, string) result
Sourceval response_of_stream_chunks : string list -> (response, string) result
Sourceval text_of_response : response -> string
Sourceval generation_of_response : response -> Provider.generation