Skip to Content
📖 Guide DocumentsLLM Function Callingapplication() functions

application() function

undefined

typia
export namespace llm { // LLM FUNCTION CALLING APPLICATION SCHEMA export function application< App extends Record<string, any>, Config extends Partial<ILlmSchema.IConfig> = {}, >( config?: Partial<Pick<ILlmApplication.IConfig, "validate">>, ): ILlmApplication; // STRUCTURED OUTPUT export function parameters< Parameters extends Record<string, any>, Config extends Partial<ILlmSchema.IConfig> = {}, >(): ILlmSchema.IParameters; // TYPE SCHEMA export function schema< T, Config extends Partial<ILlmSchema.IConfig> = {}, >( $defs: Record<string, ILlmSchema>, ): ILlmSchema; }

LLM function calling application schema from a native TypeScript class or interface type.

typia.llm.application<App>() is a function composing LLM (Large Language Model) calling application schema from a native TypeScript class or interface type. The function returns an ILlmApplication instance, which is a data structure representing a collection of LLM function calling schemas.

If you put LLM function schema instances registered in the ILlmApplication.functions to the LLM provider like OpenAI ChatGPT, the LLM will select a proper function to call with parameter values of the target function in the conversations with the user. This is the “LLM Function Calling”.

Let’s make A.I. Chatbot super-easily with typia.llm.application<App>() function.

LLM Function Calling and Structured Output

LLM selects proper function and fill arguments.

In nowadays, most LLM (Large Language Model) like OpenAI are supporting “function calling” feature. The “LLM function calling” means that LLM automatically selects a proper function and fills parameter values from conversation with the user (may by chatting text).

Structured output is another feature of LLM. The “structured output” means that LLM automatically transforms the output conversation into a structured data format like JSON.

example/src/llm/application.ts
import typia, { ILlmApplication } from "typia"; import { BbsArticleService } from "./BbsArticleService"; const app: ILlmApplication = typia.llm.application<BbsArticleService>(); console.log(app);

💻 Playground Link

Validation Feedback

typia.llm.application<App>() embeds typia.validate<T>() in every function for automatic argument validation. When validation fails, the error is returned as text content with inline // ❌ comments at each invalid property:

{ "name": "John", "age": "twenty", // ❌ [{"path":"$input.age","expected":"number"}] "email": "not-an-email", // ❌ [{"path":"$input.email","expected":"string & Format<\"email\">"}] "hobbies": "reading" // ❌ [{"path":"$input.hobbies","expected":"Array<string>"}] }

The LLM reads this feedback and self-corrects on the next turn.

In the AutoBe  project (AI-powered backend code generator), qwen3-coder-next showed only 6.75% raw function calling success rate on compiler AST types. However, with validation feedback, it reached 100%.

Working on compiler AST means working on any type and any use case.

AutoBeTest.IExpression
// Compiler AST may be the hardest type structure possible // // Unlimited union types + unlimited depth + recursive references export type IExpression = | IBooleanLiteral | INumericLiteral | IStringLiteral | IArrayLiteralExpression // <- recursive (contains IExpression[]) | IObjectLiteralExpression // <- recursive (contains IExpression) | INullLiteral | IUndefinedKeyword | IIdentifier | IPropertyAccessExpression // <- recursive | IElementAccessExpression // <- recursive | ITypeOfExpression // <- recursive | IPrefixUnaryExpression // <- recursive | IPostfixUnaryExpression // <- recursive | IBinaryExpression // <- recursive (left & right) | IArrowFunction // <- recursive (body is IExpression) | ICallExpression // <- recursive (args are IExpression[]) | INewExpression // <- recursive | IConditionalPredicate // <- recursive (then & else branches) | ... // 30+ expression types total

Restrictions

typia.llm.application<App>() follows the same restrictions of below.

About the function parameters type, it follows the restriction of both typia.llm.parameters<Params>() and typia.llm.schema<T>() functions. Therefore, the parameters must be a keyworded object type with static keys without any dynamic keys. Also, the object type must not be nullable or optional.

About the return value type, it also follows the restriction of typia.llm.parameters<Params>() function. Therefore, the return type must be a keyworded object type with static keys, or void. Primitive types (like number, string, boolean), array types, and union types with undefined are not allowed as return types. If you need to return a primitive or array value, wrap it in an object type (e.g., { value: number } or { items: T[] }).

example/src/llm/application.violation.ts
import typia, { ILlmApplication, tags } from "typia"; const app: ILlmApplication = typia.llm.application<BbsArticleController>(); console.log(app); interface BbsArticleController { /** * Create a new article. * * Writes a new article and archives it into the DB. * * @param props Properties of create function * @returns Newly created article */ create(props: { /** * Information of the article to create */ input: IBbsArticle.ICreate; }): Promise<IBbsArticle | undefined>; /** * Add two numbers. * * @param props Properties of add function * @returns The sum value */ add(props: { x: number; y: number }): number; erase(id: string & tags.Format<"uuid">): Promise<void>; }
Last updated on