GenerationOptions
Tune generation behavior with GenerationOptions. Leave a field as nil / null to fall back to the defaults packaged with the model bundle.
- Kotlin
- Swift
| Field | Type | Description |
|---|---|---|
temperature | Float? | Sampling temperature. |
topP | Float? | Nucleus sampling probability mass. |
minP | Float? | Minimum probability threshold. |
repetitionPenalty | Float? | Penalizes repeated tokens. |
jsonSchemaConstraint | String? | JSON schema string for Constrained Generation. |
functionCallParser | LeapFunctionCallParser? | Parser for tool-call tokens. Default is LFMFunctionCallParser. Use HermesFunctionCallParser for Hermes/Qwen3 formats, or null for raw text. |
injectSchemaIntoPrompt | Boolean | Whether to inject the JSON schema into the system prompt. |
topK | Int? | Top-K sampling: only the K most likely tokens are considered. |
rngSeed | Long? | Random number generator seed for reproducible outputs. |
enableThinking | Boolean | Enable the model’s thinking/reasoning mode. |
setResponseFormat to populate jsonSchemaConstraint from a @Generatable-annotated data class:Constrained Generation Utilities
For full usage details, see the Constrained Generation guide.JSONSchemaGenerator
Generates a JSON schema string from a @Generatable-annotated type. This schema is passed to GenerationOptions.jsonSchemaConstraint to activate constrained generation.
- Kotlin
- Swift
klass— the Kotlin class object created fromT::class. It must be a data class annotated with@Generatable.indentSpaces— a non-null value will format the JSON output into a pretty style with the given indent spaces.
LeapGeneratableSchematizationException is thrown.GeneratableFactory
Deserializes a JSON object into an instance of a @Generatable-annotated type. Available on all platforms (commonMain).
- Kotlin
- Swift
jsonObject— the JSON object used as the data source for creating the generatable data class instance.klass— the Kotlin class object created fromT::class. It must be a data class annotated with@Generatable.
Annotations
- Kotlin
- Swift
@Generatablemarks a data class for use as a generation constraint.@Guideadds a human-readable description to a field, helping the model produce accurate values.
Function Calling Types
For full usage details, see the Function Calling guide.LeapFunction
Describes the signature of a function that can be called by the model.
- Kotlin
- Swift
name— name of the function.description— a human- and LLM-readable description of the function.parameters— the list of parameters accepted by the function.
LeapFunctionParameter
Describes the signature of a parameter in a function.
- Kotlin
- Swift
name— name of the parameter.type— data type of the parameter.description— a human- and LLM-readable description of the parameter.optional— whether this parameter is optional.
LeapFunctionParameterType
Represents a data type for function parameters. All types must be valid JSON Schema types.
- Kotlin
- Swift
| Variant | Description |
|---|---|
String | A string literal. enumValues restricts accepted values. |
Number | A number (integer or floating point). enumValues restricts accepted values. |
Integer | An integer literal. enumValues restricts accepted values. |
Boolean | A boolean literal. |
Null | Accepts only null. |
Array | An array. itemType describes the element type. |
Object | An object. properties maps property names to types; required lists mandatory properties. |
LeapFunctionCall
Describes a function call request generated by the model.
- Kotlin
- Swift
name— name of the function to be called.arguments— the arguments for the call. Values can be strings, numbers, booleans, null, lists (arrays), or maps/dictionaries (objects).
Function Call Parsers
Function call parsers convert raw tool-call tokens from the model intoLeapFunctionCall instances.
- Kotlin
- Swift
Two built-in implementations of
LeapFunctionCallParser:LFMFunctionCallParser— parses Liquid Foundation Model (LFM2) Pythonic function calls. This is the default.HermesFunctionCallParser— parses Hermes/Qwen3 function calling format.
nil / null in GenerationOptions to receive raw tool-call text instead.