### Install Typia with npm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Installs Typia using npm and runs the setup wizard. This is the recommended way to start. ```bash npm install typia npx typia setup ``` -------------------------------- ### Install and Setup Typia Source: https://github.com/samchon/typia/wiki/Setup Install Typia and run the setup wizard. The wizard helps configure the project for Typia's transformations. ```bash npm install --save typia npx typia setup --compiler (ttypescript|ts-patch) --manager (npm|pnpm|yarn) --project {tsconfig.json file path} ``` -------------------------------- ### Install Dependencies and Setup Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/utilization/mcp.mdx Commands to install the necessary @typia/mcp and @modelcontextprotocol/sdk packages, along with typia itself, and run the typia setup command. ```bash npm install @typia/mcp @modelcontextprotocol/sdk npm install typia npx typia setup ``` -------------------------------- ### Install Typia with Bun Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Install Typia using Bun and run the setup command. ```bash bun add typia bun typia setup ``` -------------------------------- ### Install Typia with bun Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Installs Typia using bun and runs the setup wizard, specifying bun as the package manager. ```bash bun add typia bun typia setup --manager bun ``` -------------------------------- ### Install Typia with NX Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Install Typia and run the setup command for NX projects using different package managers. ```bash npm install typia npx typia setup ``` ```bash pnpm install typia pnpm typia setup --manager pnpm ``` ```bash # Yarn Berry is NOT supported yarn add typia yarn typia setup --manager yarn ``` ```bash bun add typia bun typia setup --manager bun ``` -------------------------------- ### Install Typia with Yarn Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Install Typia using Yarn and run the setup command. This is for projects not using Yarn Berry. ```bash yarn add typia yarn typia setup --manager yarn ``` -------------------------------- ### Install @typia/langchain and Dependencies Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/utilization/langchain.mdx Installs the necessary packages for @typia/langchain integration, including @langchain/core and typia. Also runs the typia setup command. ```bash npm install @typia/langchain @langchain/core npm install typia npx typia setup ``` -------------------------------- ### Typia Setup with bun Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/index.mdx Install and set up Typia using bun, including TypeScript, ts-node, and ts-patch. This section covers installation, build, and direct execution commands. ```bash # install bun add typia bun add -d typescript ts-node ts-patch bun typia setup # build bun tsc ``` -------------------------------- ### Install Typia with yarn Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Installs Typia using yarn and runs the setup wizard. Note: Yarn Berry is not supported. ```bash # Yarn Berry is NOT supported yarn add typia yarn typia setup --manager yarn ``` -------------------------------- ### Typia Setup with pnpm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/index.mdx Install and set up Typia using pnpm, including TypeScript, ts-node, and ts-patch. This section covers installation, build, and direct execution commands. ```bash # install pnpm i typia pnpm i -D typescript ts-node ts-patch pnpm typia setup --manager pnpm # build pnpm tsc # run without building first pnpm ts-node src/index.ts ``` -------------------------------- ### Typia Setup with npm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/index.mdx Install and set up Typia using npm, including TypeScript, ts-node, and ts-patch. This section covers installation, build, and direct execution commands. ```bash # install npm i typia npm i -D typescript ts-node ts-patch npx typia setup # build npx tsc # run without building first npx ts-node src/index.ts ``` -------------------------------- ### Install Typia with pnpm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Installs Typia using pnpm and runs the setup wizard, specifying pnpm as the package manager. ```bash pnpm install typia pnpm typia setup --manager pnpm ``` -------------------------------- ### Install Dependencies Source: https://github.com/samchon/typia/blob/master/packages/vercel/README.md Install the necessary packages for @typia/vercel integration. ```bash npm install @typia/vercel ai typia npm install -D ttsc @typescript/native-preview ``` -------------------------------- ### Typia Setup with yarn Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/index.mdx Install and set up Typia using yarn (excluding Yarn Berry), including TypeScript, ts-node, and ts-patch. This section covers installation, build, and direct execution commands. ```bash # install # Yarn Berry is NOT supported yarn add typia yarn add -D typescript ts-node ts-patch yarn typia setup --manager yarn # build yarn tsc # run without building first yarn ts-node src/index.ts ``` -------------------------------- ### Install Typia and @typia/unplugin with npm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Installs Typia and the @typia/unplugin package using npm. Also runs the Typia setup command. ```bash npm install typia npx typia setup npm install -D @typia/unplugin ``` -------------------------------- ### Vercel AI SDK Setup with npm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/utilization/vercel.mdx Install the necessary packages for integrating typia with the Vercel AI SDK using npm. This includes `@typia/vercel`, `ai`, and `typia`. ```bash npm install @typia/vercel ai npm install typia npx typia setup ``` -------------------------------- ### Install Model Context Protocol dependencies Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/llm/application.mdx Install the necessary SDK for Model Context Protocol integration. ```bash npm i @modelcontextprotocol/sdk @typia/mcp ``` -------------------------------- ### Install Typia and ttsc with npm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/tsgo.mdx Install Typia's next version along with ttsc and the native TypeScript preview package using npm. This is the first step for using the TypeScript-Go compiler setup. ```bash npm i typia@next npm i -D ttsc @typescript/native-preview ``` -------------------------------- ### Install Typia and @typia/unplugin with pnpm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Installs Typia and the @typia/unplugin package using pnpm. Also runs the Typia setup command with the pnpm manager specified. ```bash pnpm install typia pnpm typia setup --manager pnpm pnpm install -D @typia/unplugin ``` -------------------------------- ### Full TypeScript Source for LLM Application Example Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/llm/application.mdx This snippet provides the complete TypeScript source code for an example demonstrating the use of `typia.llm.application`. It includes the service class definition and the application setup. ```typescript import typia from "typia"; // Define the interface for a BBS article interface IBbsArticle { id: string; title: string; } // Define the service class for BBS articles class BbsArticleService { /** * Create a new article. * @param props - The properties for creating a new article. * @returns A promise that resolves with the ID of the created article. */ public async create( props: { input: { title: string; body: string; }; }, ): Promise<{ id: string }> { console.log("Creating article:", props.input); // Simulate article creation const id = Math.random().toString(36).substring(2); return { id }; } /** * List recent articles. * @param props - The properties for listing recent articles. * @returns A promise that resolves with a list of recent articles. */ public async recent( props: { limit: number; }, ): Promise<{ items: Array }> { console.log("Listing recent articles with limit:", props.limit); // Simulate fetching recent articles const items: IBbsArticle[] = []; for (let i = 0; i < props.limit; i++) { items.push({ id: Math.random().toString(36).substring(2), title: `Article ${i + 1}`, }); } return { items }; } } // Generate the LLM application configuration from the service class const app = typia.llm.application(); // Example of how the generated functions might look (for demonstration) // console.log(JSON.stringify(app.functions, null, 2)); // You would typically pass `app.functions` to an LLM SDK // For example, with OpenAI: // const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY }); // const chatCompletion = await openai.chat.completions.create({ // model: "gpt-4", // messages: [ // { role: "user", content: "Create an article titled 'Hello World' with body 'This is a test.'" }, // ], // tools: app.functions.map((fn) => ({ type: "function", function: fn })), // tool_choice: "auto", // }); // console.log(chatCompletion.choices[0].message?.tool_calls); // To demonstrate the validation and execution: async function main() { // Validate and execute the 'create' function call const createResult = await app.functions[0].execute.call( new BbsArticleService(), app.functions[0].parse({ input: { title: "Hello Typia", body: "This is a test article.", }, }), ); console.log("Create result:", createResult); // Validate and execute the 'recent' function call const recentResult = await app.functions[1].execute.call( new BbsArticleService(), app.functions[1].parse({ limit: 5 }), ); console.log("Recent articles:", recentResult); } main().catch(console.error); ``` -------------------------------- ### Install Vercel AI SDK dependencies Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/llm/application.mdx Install the necessary packages for integrating with the Vercel AI SDK. ```bash npm i @ai-sdk/openai @typia/vercel ai ``` -------------------------------- ### Install LangChain dependencies Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/llm/application.mdx Install the required packages for integrating with LangChain. ```bash npm i @langchain/core @langchain/openai langchain @typia/langchain ``` -------------------------------- ### Install with TypeScript-Go (bun) Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/index.mdx Installs typia@next, ttsc, and @typescript/native-preview using bun. Note: Build and run commands for bun are not fully shown in this snippet. ```bash # install bun add typia@next bun add -d ttsc @typescript/native-preview # build bun ttsc ``` -------------------------------- ### Install typia/mcp and dependencies Source: https://github.com/samchon/typia/blob/master/packages/mcp/README.md Install the necessary packages for @typia/mcp, @modelcontextprotocol/sdk, and typia. Development dependencies like ttsc and @typescript/native-preview are also included. ```bash npm install @typia/mcp @modelcontextprotocol/sdk typia npm install -D ttsc @typescript/native-preview ``` -------------------------------- ### Install Typia and Development Dependencies (Ts-patch) Source: https://github.com/samchon/typia/wiki/Setup Install Typia and the necessary development dependencies for using ts-patch. Includes the command to install ts-patch and a prepare script for package.json. ```bash npm install --save typia # COMPILERS npm install --save-dev typescript npm install --save-dev ts-node npm install --save-dev ts-patch # ADDITIONAL COMMAND REQUIRED npx ts-patch install ``` ```json { "scripts": { "prepare": "ts-patch install" } } ``` -------------------------------- ### Install Typia and Development Dependencies (Ttypescript) Source: https://github.com/samchon/typia/wiki/Setup Install Typia and the necessary development dependencies for compiling TypeScript with transformations using ttypescript. ```bash npm install --save typia # ENSURE THOSE PACKAGES ARE INSTALLED npm install --save-dev typescript npm install --save-dev ts-node npm install --save-dev ttypescript ``` -------------------------------- ### Install ts-loader and webpack Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Install the necessary development dependencies for webpack and ts-loader. ```bash bun add -d ts-loader webpack webpack-cli ``` -------------------------------- ### TypeScript Source for createValidate Example Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/validators/validate.mdx This is the TypeScript source code for the `createValidate` example, demonstrating its usage. ```typescript import typia from "typia"; interface ISmallTodo { userId: number; /** @maximum 5 */ id: number; title: string; completed: boolean; } const validate = typia.createValidate(); const success = validate( { userId: 1, id: 5, title: "hello", completed: false, }, ); console.log(success); const failure = validate( { userId: 1, id: 10, title: "hello", completed: false, }, ); console.log(failure); ``` -------------------------------- ### Verify typia Setup with is() Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/index.mdx Run this code snippet after setup to confirm that the typia transformer is correctly configured and applied. It should output `true` if successful. ```typescript import typia from "typia"; console.log(typia.is<{ id: string }>({ id: "ok" })); // → true ``` -------------------------------- ### Install Typia and Webpack Dependencies with npm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Install Typia and the necessary Webpack and ts-loader packages using npm. ```bash # typia npm install typia npx typia setup # webpack + ts-loader npm install -D ts-loader webpack webpack-cli ``` -------------------------------- ### Install Typia and TypeScript Dependencies with bun Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Installs Typia and development dependencies like TypeScript and ts-patch using bun. ```bash bun add typia bun add -d typescript ts-patch ``` -------------------------------- ### TypeScript Source for createIs() Example Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/validators/is.mdx The original TypeScript code for the 'createIs.ts' example, demonstrating the creation and usage of a reusable type guard function. ```typescript import typia from "typia"; interface User { id: string; age: number; } const isUser = typia.createIs(); // ...elsewhere const input1 = { id: "abc", age: 1 }; const input2 = { id: "def", age: "2" }; console.log(isUser(input1)); // true console.log(isUser(input2)); // false ``` -------------------------------- ### Run prepare script with bun Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Executes the prepare script using bun to install ts-patch and apply necessary patches to the local TypeScript installation. ```bash bun prepare ``` -------------------------------- ### Install Dependencies for Typia LangChain Source: https://github.com/samchon/typia/blob/master/packages/langchain/README.md Installs the necessary packages for using @typia/langchain, @langchain/core, and typia. Includes development dependencies ttsc and @typescript/native-preview. ```bash npm install @typia/langchain @langchain/core typia npm install -D ttsc @typescript/native-preview ``` -------------------------------- ### Run prepare script with npm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Executes the prepare script using npm to install ts-patch and apply necessary patches to the local TypeScript installation. ```bash npm run prepare ``` -------------------------------- ### Compiled JavaScript for is() Example Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/validators/is.mdx The JavaScript code generated by typia for the 'hello-is.ts' example. This highlights the absence of runtime schema interpretation, demonstrating typia's performance optimization. ```javascript import typia from "typia"; const input = await fetchSomething(); if (typia.is(input, { "type": "object", "properties": { "id": { "type": "string" }, "age": { "type": "number" } }, "required": [ "id", "age" ] })) { console.log(input.age); } ``` -------------------------------- ### Install, Format, Build, and Test Typia Project Source: https://github.com/samchon/typia/blob/master/AGENTS.md These commands are used for setting up the project, ensuring code style, compiling the code, and running tests. Ensure Node.js 24.x and pnpm 10.6.4 are installed. ```bash pnpm install pnpm format pnpm build pnpm test ``` -------------------------------- ### Recommended Contributor Workflow Source: https://github.com/samchon/typia/blob/master/CONTRIBUTING.md Outlines the recommended sequence of commands for contributors to set up the environment, build, and test the project locally. ```bash pnpm install pnpm run build pnpm run test ``` -------------------------------- ### Install and Build with TypeScript-Go (pnpm) Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/index.mdx Installs typia@next, ttsc, and @typescript/native-preview using pnpm. Includes commands to build your project with ttsc and run TypeScript files directly with ttsx. ```bash # install pnpm i typia@next pnpm i -D ttsc @typescript/native-preview # build pnpm ttsc # run without building first pnpm ttsx src/index.ts ``` -------------------------------- ### Install and Build with TypeScript-Go (npm) Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/index.mdx Installs typia@next, ttsc, and @typescript/native-preview using npm. Includes commands to build your project with ttsc and run TypeScript files directly with ttsx. ```bash # install npm i typia@next npm i -D ttsc @typescript/native-preview # build npx ttsc # run without building first npx ttsx src/index.ts ``` -------------------------------- ### OpenAI Integration with JSON Schema Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/llm/parameters.mdx This example shows how to integrate `typia.llm.parameters()` with the OpenAI SDK. The generated schema is passed to the `response_format` parameter to guide the LLM in generating structured JSON output. ```typescript import OpenAI from "openai"; import typia, { tags } from "typia"; interface IMember { email: string & tags.Format<"email">; name: string; age: number; hobbies: string[]; joined_at: string & tags.Format<"date">; } const main = async (): Promise => { const client: OpenAI = new OpenAI({ apiKey: "", }); const completion: OpenAI.ChatCompletion = await client.chat.completions.create({ model: "gpt-4o", messages: [ { role: "user", content: [ "I am a new member of the community.", "", "My name is John Doe, and I am 25 years old.", "I like playing basketball and reading books,", "and joined to this community at 2022-01-01.", ].join("\n"), }, ], response_format: { type: "json_schema", json_schema: { name: "member", schema: typia.llm.parameters() as any, }, }, }); console.log(JSON.parse(completion.choices[0].message.content!)); }; main().catch(console.error); ``` -------------------------------- ### Local Build for Website Source: https://github.com/samchon/typia/blob/master/CONTRIBUTING.md Provides the commands to install dependencies and build the website locally, which has its own distinct pipeline. ```bash cd website && npm install && npm run build ``` -------------------------------- ### Install Typia with bun and Generate Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Install Typia and TypeScript using bun, then run the generation command to transform input files to the specified output directory. This is a workaround for build systems that do not support TypeScript transformers. ```bash bun add typia bun add -d typescript bun typia generate \ --input src/templates \ --output src/generated \ --project tsconfig.json ``` -------------------------------- ### Compiled JavaScript for createValidate Example Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/validators/validate.mdx This is the compiled JavaScript code for the `createValidate` example. ```javascript import typia from "typia"; const validate = typia.createValidate({ type: "object", properties: { userId: { type: "number", }, id: { type: "number", maximum: 5, }, title: { type: "string", }, completed: { type: "boolean", }, }, required: [ "userId", "id", "title", "completed", ], }); const success = validate({ userId: 1, id: 5, title: "hello", completed: false, }); console.log(success); const failure = validate({ userId: 1, id: 10, title: "hello", completed: false, }); console.log(failure); ``` -------------------------------- ### Install and Build with TypeScript-Go (yarn) Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/index.mdx Installs typia@next, ttsc, and @typescript/native-preview using yarn. Includes commands to build your project with ttsc and run TypeScript files directly with ttsx. ```bash # install yarn add typia@next yarn add -D ttsc @typescript/native-preview # build yarn ttsc # run without building first yarn ttsx src/index.ts ``` -------------------------------- ### Bun Runtime Plugin Setup Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/index.mdx Set up typia's transformer for the Bun runtime by importing `@typia/unplugin/bun` in your `preload.ts`. ```typescript import { plugin } from "bun"; import UnpluginTypia from "@typia/unplugin/bun"; plugin(UnpluginTypia()); ``` -------------------------------- ### Initialize HttpLlm Controller Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/llm/http.mdx Example of initializing an `HttpLlm` controller with a shopping API's OpenAPI document and connection details. This sets up the LLM to call the specified API. ```typescript import { HttpLlm } from "@typia/utils"; import { IHttpLlmController } from "@typia/interface"; const controller: IHttpLlmController = HttpLlm.controller({ name: "shopping", document: await fetch( "https://shopping-be.wrtn.ai/editor/swagger.json", ).then((r) => r.json()), connection: { host: "https://shopping-be.wrtn.ai", headers: { Authorization: "Bearer ********" }, }, }); // controller.application.functions: one IHttpLlmFunction per API operation // controller.execute(funcName, args): performs the actual HTTP call ``` -------------------------------- ### Compiled JavaScript for validate-map Example Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/validators/validate.mdx This is the compiled JavaScript code for the `validate-map` example, showing Map validation. ```javascript import typia from "typia"; const validate = typia.createValidate({ type: "object", properties: { value: { type: "object", // NOTE: Map is not a standard JSON type. It is represented as an array of key-value pairs. // The actual type is Map. items: { type: "array", items: { type: "array", items: [ { type: "number", }, { type: "string", }, ], minItems: 2, maxItems: 2, }, }, }, }, required: [ "value", ], }); const success = validate({ value: new Map([ [1, "one"], [2, "two"], ]), }); console.log(success); const failure = validate({ value: new Map([ [1, "one"], [2, "two"], ]), }); console.log(failure); ``` -------------------------------- ### Install Typia and Webpack Dependencies with pnpm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Install Typia and the necessary Webpack and ts-loader packages using pnpm. ```bash # typia pnpm install typia pnpm typia setup --manager pnpm # webpack + ts-loader pnpm install -D ts-loader webpack webpack-cli ``` -------------------------------- ### Install Typia and ttsc with bun Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/tsgo.mdx Install Typia's next version along with ttsc and the native TypeScript preview package using bun. This command is specific to bun users. ```bash bun add typia@next bun add -d ttsc @typescript/native-preview ``` -------------------------------- ### Install Typia and TypeScript Dependencies Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Installs Typia and development dependencies like TypeScript and ts-patch using npm. ```bash npm install typia npm install -D typescript ts-patch ``` -------------------------------- ### Example: Hello Structured Output Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/llm/structuredOutput.mdx Demonstrates how to use typia.llm.structuredOutput() to generate a schema, parse LLM output, and validate the result against a defined interface. ```typescript import typia from "typia"; interface IMember { email: string; name: string; age: number; hobbies: string[]; } const output = typia.llm.structuredOutput(); // hand `output.parameters` to your LLM SDK as JSON schema // then: const parsed = output.parse(rawLlmText); if (parsed.success) { const v = output.validate(parsed.data); if (v.success) doSomething(v.data); } ``` -------------------------------- ### Compiled JavaScript for validate-custom-tags Example Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/validators/validate.mdx This is the compiled JavaScript code for the `validate-custom-tags` example, showing validation with type tags. ```javascript import typia from "typia"; const validate = typia.createValidate({ type: "object", properties: { email: { type: "string", format: "email", }, age: { type: "number", maximum: 100, exclusiveMinimum: 1, }, }, required: [ "email", "age", ], }); const success = validate({ email: "test@example.com", age: 50, }); console.log(success); const failure = validate({ email: "invalid-email", age: 0, }); console.log(failure); ``` -------------------------------- ### Generated Structured Output Example Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/utilization/vercel.mdx This is an example of the structured output generated by the `generateObject` function, conforming to the `IMember` interface. ```json { email: 'john.doe@example.com', name: 'John Doe', age: 25, hobbies: [ 'playing basketball', 'reading books' ], joined_at: '2022-01-01' } ``` -------------------------------- ### Install Typia and TypeScript Dependencies with yarn Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Installs Typia and development dependencies like TypeScript and ts-patch using yarn. ```bash yarn add typia yarn add -D typescript ts-patch ``` -------------------------------- ### Install Typia and TypeScript Dependencies with pnpm Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Installs Typia and development dependencies like TypeScript and ts-patch using pnpm. ```bash pnpm install typia pnpm install -D typescript ts-patch ``` -------------------------------- ### Example: structuredOutput.ts (Compiled JavaScript) Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/llm/structuredOutput.mdx The compiled JavaScript output for the structuredOutput.ts example file, showing the generated JavaScript code. ```javascript "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.llm = void 0; const typia_1 = require("typia"); const output = (0, typia_1.default)().llm.structuredOutput(); // hand `output.parameters` to your LLM SDK as JSON schema // then: const parsed = output.parse(rawLlmText); if (parsed.success) { const v = output.validate(parsed.data); if (v.success) doSomething(v.data); } exports.llm = (() => { const output = typia_1.default.llm.structuredOutput(); return { parameters: output.parameters, parse: (input) => output.parse(input), coerce: (input) => output.coerce(input), validate: (input) => output.validate(input) }; })(); ``` -------------------------------- ### Install Typia with pnpm and Generate Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Install Typia and TypeScript using pnpm, then execute the generation command to transform input files into the output directory. This method is a fallback for build environments incompatible with direct TypeScript transformers. ```bash pnpm install typia pnpm install -D typescript pnpm typia generate \ --input src/templates \ --output src/generated \ --project tsconfig.json ``` -------------------------------- ### Install Typia Unplugin with Bun Source: https://github.com/samchon/typia/blob/master/website/src/content/docs/setup/legacy.mdx Add the Typia unplugin for Bun projects. ```bash bun add -D @typia/unplugin ```