Coerce pre-parsed arguments to match expected schema types.
Use this only when the SDK (e.g., LangChain, Vercel AI, MCP) already parses JSON internally. For raw JSON strings from LLM output, use parse instead — it handles both lenient parsing and type coercion in one step.
LLMs often return values with incorrect types even after parsing:
"42" → 42 (when schema expects number)"true" → true (when schema expects boolean)"null" → null (when schema expects null)"{...}" → {...} (when schema expects object)"[...]" → [...] (when schema expects array)This function recursively coerces these double-stringified values based on the parameters schema.
Type validation is NOT performed — use validate after coercion.
Pre-parsed arguments object from SDK
Coerced arguments with corrected types
OptionaldeprecatedWhether this function is deprecated.
When true, indicates the function should no longer be used. LLMs may
still invoke deprecated functions but should prefer non-deprecated
alternatives when available.
OptionaldescriptionHuman-readable function description.
Explains what the function does, when to use it, and any important considerations. This description is crucial for LLMs to understand when to invoke this function. Extracted from JSDoc comments.
Function name for LLM invocation.
The identifier used by the LLM to call this function. Must be unique within the application.
OpenAI limits function names to 64 characters.
OptionaloutputSchema for the return type.
Defines the expected output type as an object parameters schema, wrapping
the return type in an ILlmSchema.IParameters object with $defs for
shared type definitions and properties for the structured output.
undefined when the function returns void or has no meaningful return
value.
Schema for function parameters.
Defines the expected argument types as a JSON Schema object. Contains
$defs for shared type definitions and properties for each named
parameter.
Lenient JSON parser with schema-based coercion.
Handles incomplete/malformed JSON commonly produced by LLMs:
// and multi-line)tru, fal, nul)Also coerces double-stringified values ("42" → 42) using the
parameters schema.
Type validation is NOT performed — use validate after parsing.
If the SDK (e.g., LangChain, Vercel AI, MCP) already parses JSON internally and provides a pre-parsed object, use coerce instead to apply schema-based type coercion without re-parsing.
Raw JSON string from LLM output
Parse result with data on success, or partial data with errors
OptionaltagsCategory tags for function organization.
Extracted from @tag JSDoc annotations. Useful for grouping related
functions and filtering the function list.
Validates LLM-generated arguments against the schema.
LLMs frequently make type errors such as returning strings instead of numbers or missing required properties. Use this validator to check arguments before execution.
When validation fails, use LlmJson.stringify from @typia/utils to
format the error for LLM feedback. The formatted output shows the invalid
JSON with inline error comments, helping the LLM understand and correct its
mistakes in the next turn.
The arguments generated by the LLM
Validation result with success status and any errors
LLM function calling schema for TypeScript functions.
Generated by
typia.llm.application<App>()as part of ILlmApplication.Author
Jeongho Nam - https://github.com/samchon