This section details the available configuration options for the TypeScript SDK. All configuration is managed in the gen.yaml file under the typescript section.
Custom npm scripts to add to the package.json file. Scripts with the same name as default scripts will override them.
Default Value
{}
generateExamples
Required
false
Description
Whether to generate example files in an examples directory demonstrating SDK usage.
Default Value
true
compileCommand
Required
false
Description
The command to use for compiling the SDK. Must be an array where the first element is the command and the rest are arguments.
Default Value
N/A
usageSDKInit
Required
false
Description
The SDK initialization code to use in usage examples (e.g., new Petstore({})).
Default Value
N/A
usageSDKInitImports
Required
false
Description
Array of imports to add when usageSDKInit is configured. Each import should have package, import, and optionally type fields (options: typeImport, packageImport, aliasImport).
Default Value
[]
Name
Required
Default Value
Description
additionalScripts
false
{}
Custom npm scripts to add to the package.json file. Scripts with the same name as default scripts will override them.
generateExamples
false
true
Whether to generate example files in an examples directory demonstrating SDK usage.
compileCommand
false
N/A
The command to use for compiling the SDK. Must be an array where the first element is the command and the rest are arguments.
usageSDKInit
false
N/A
The SDK initialization code to use in usage examples (e.g., new Petstore({})).
usageSDKInitImports
false
[]
Array of imports to add when usageSDKInit is configured. Each import should have package, import, and optionally type fields (options: typeImport, packageImport, aliasImport).
Determines the ordering of method arguments when flattening parameters and body fields. Options: parameters-first or body-first.
Default Value
parameters-first
methodArguments
Required
false
Description
Determines how arguments for SDK methods are generated. If set to infer-optional-args, the method argument will be optional when all parameters and the request body are optional. Options: infer-optional-args or require-security-and-request.
Determines the ordering of method arguments when flattening parameters and body fields. Options: parameters-first or body-first.
methodArguments
false
infer-optional-args
Determines how arguments for SDK methods are generated. If set to infer-optional-args, the method argument will be optional when all parameters and the request body are optional. Options: infer-optional-args or require-security-and-request.
Sets the module format to use when compiling the SDK. Options: commonjs, esm, or dual. New SDKs default to esm for modern module resolution. Existing SDKs default to dual for backward compatibility.
Default Value
esm (new SDKs), dual (existing SDKs)
legacyFileNaming
Required
false
Description
When true, uses legacy file naming (camelCase/lowercase). When false, uses kebab-case (e.g., simple-object.ts). New SDKs default to false (kebab-case).
Sets the module format to use when compiling the SDK. Options: commonjs, esm, or dual. New SDKs default to esm for modern module resolution. Existing SDKs default to dual for backward compatibility.
legacyFileNaming
false
false (new SDKs)
When true, uses legacy file naming (camelCase/lowercase). When false, uses kebab-case (e.g., simple-object.ts). New SDKs default to false (kebab-case).
Performance optimization
For optimal bundle size and tree-shaking performance in modern applications, consider using moduleFormat: "esm" together with useIndexModules: false. This combination provides the best possible bundler optimizations. Use dual if CommonJS compatibility is required.
Prefix used for internal class fields and methods in the generated SDK (for example, this.#hooks, this.#httpClient). Defaults to # (ECMAScript hard-private fields). Set to _, __, $, or an empty string for strict TypeScript linters that reject hard-private fields (e.g., tsetse's TS21216 error emitted by ban-private-fields rule, or the equivalent no-restricted-syntax ESLint rule).
Default
Type
string
Property
Description
Type
Default
privateIdentifierPrefix
Prefix used for internal class fields and methods in the generated SDK (for example, this.#hooks, this.#httpClient). Defaults to # (ECMAScript hard-private fields). Set to _, __, $, or an empty string for strict TypeScript linters that reject hard-private fields (e.g., tsetse's TS21216 error emitted by ban-private-fields rule, or the equivalent no-restricted-syntax ESLint rule).
When true, custom enum names provided via x-speakeasy-enums are preserved exactly as written, with only illegal character sanitization applied. No PascalCase or other casing transformations are performed. Only affects enums with x-speakeasy-enums overrides.
Default
false
Type
boolean
clientServerStatusCodesAsErrors
Description
Treats 4XX and 5XX status codes as errors. Set to false to treat them as normal responses.
Default
true
Type
boolean
defaultErrorName
Description
The name of the fallback error class if no more specific error class is matched. Must start with a capital letter and contain only letters and numbers.
Default
SDKError
Type
string
baseErrorName
Description
The name of the base error class used for HTTP error responses. Must start with a capital letter and contain only letters and numbers.
Default
HTTPError
Type
string
acceptHeaderEnum
Description
Whether to generate TypeScript enums for controlling the return content type of SDK methods when multiple accept types are available.
When true, custom enum names provided via x-speakeasy-enums are preserved exactly as written, with only illegal character sanitization applied. No PascalCase or other casing transformations are performed. Only affects enums with x-speakeasy-enums overrides.
boolean
false
clientServerStatusCodesAsErrors
Treats 4XX and 5XX status codes as errors. Set to false to treat them as normal responses.
boolean
true
defaultErrorName
The name of the fallback error class if no more specific error class is matched. Must start with a capital letter and contain only letters and numbers.
string
SDKError
baseErrorName
The name of the base error class used for HTTP error responses. Must start with a capital letter and contain only letters and numbers.
string
HTTPError
acceptHeaderEnum
Whether to generate TypeScript enums for controlling the return content type of SDK methods when multiple accept types are available.
Sets the JSONPath implementation to use. Options: legacy (deprecated) or rfc9535 (recommended). The rfc9535 option follows the JSONPath specification and should be preferred for new SDKs.
Default
rfc9535
Type
string
zodVersion
Description
The version of Zod to use for schema validation. Options: v3, v4, or v4-mini.
Default
v4-mini
Type
string
constFieldsAlwaysOptional
Description
Whether const fields should be treated as optional in TypeScript types and schemas regardless of OpenAPI spec requirements. When true (legacy behavior), all const fields are optional. When false (recommended), const fields respect the OpenAPI spec's required array.
Property naming convention to use. Options: camel (converts to camelCase) or snake (converts to snake_case).
Default
camel
Type
string
unionStrategy
Description
Strategy for deserializing union types. Options: left-to-right (tries each type in order and returns the first valid match) or populated-fields (tries all types and returns the one with the most matching fields, including optional fields).
Default
populated-fields
Type
string
laxMode
Description
Controls validation strictness. When set to lax, required fields will be coerced to their zero value (e.g., a missing required string will fallback to ""). Lax mode also applies other coercions (e.g., boolean schemas will accept the string "true"). Lax mode only applies to deserialization of responses. When laxMode is enabled, unionStrategy is automatically set to populated-fields. Options: lax or strict.
Default
lax
Type
string
alwaysIncludeInboundAndOutbound
Description
Whether to always include both inbound and outbound schemas for all types regardless of usage.
Default
false
Type
boolean
exportZodModelNamespace
Description
Whether to export the deprecated $ namespace containing inboundSchema and outboundSchema aliases.
Default
false
Type
boolean
Property
Description
Type
Default
jsonpath
Sets the JSONPath implementation to use. Options: legacy (deprecated) or rfc9535 (recommended). The rfc9535 option follows the JSONPath specification and should be preferred for new SDKs.
string
rfc9535
zodVersion
The version of Zod to use for schema validation. Options: v3, v4, or v4-mini.
string
v4-mini
constFieldsAlwaysOptional
Whether const fields should be treated as optional in TypeScript types and schemas regardless of OpenAPI spec requirements. When true (legacy behavior), all const fields are optional. When false (recommended), const fields respect the OpenAPI spec's required array.
Property naming convention to use. Options: camel (converts to camelCase) or snake (converts to snake_case).
string
camel
unionStrategy
Strategy for deserializing union types. Options: left-to-right (tries each type in order and returns the first valid match) or populated-fields (tries all types and returns the one with the most matching fields, including optional fields).
string
populated-fields
laxMode
Controls validation strictness. When set to lax, required fields will be coerced to their zero value (e.g., a missing required string will fallback to ""). Lax mode also applies other coercions (e.g., boolean schemas will accept the string "true"). Lax mode only applies to deserialization of responses. When laxMode is enabled, unionStrategy is automatically set to populated-fields. Options: lax or strict.
string
lax
alwaysIncludeInboundAndOutbound
Whether to always include both inbound and outbound schemas for all types regardless of usage.
boolean
false
exportZodModelNamespace
Whether to export the deprecated $ namespace containing inboundSchema and outboundSchema aliases.
These options control how the SDK handles API evolution, allowing older SDK versions to continue working when APIs add new enum values, union types, or fields.
typescript:
forwardCompatibleEnumsByDefault: true
forwardCompatibleUnionsByDefault: tagged-only
Property
forwardCompatibleEnumsByDefault
Description
Controls whether enums used in responses are treated as open enums that accept unknown values. When true, SDKs gracefully handle new enum values added by the API instead of rejecting the response. Individual enums can be controlled with x-speakeasy-unknown-values: allow or x-speakeasy-unknown-values: disallow in the OpenAPI spec.
Default
true
Type
boolean
forwardCompatibleUnionsByDefault
Description
Controls whether discriminated unions accept unknown discriminator values. When set to tagged-only, SDKs capture unknown union variants in a type-safe way instead of failing deserialization. Individual unions can be controlled with x-speakeasy-unknown-values: allow or x-speakeasy-unknown-values: disallow in the OpenAPI spec.
Default
tagged-only
Type
string
Property
Description
Type
Default
forwardCompatibleEnumsByDefault
Controls whether enums used in responses are treated as open enums that accept unknown values. When true, SDKs gracefully handle new enum values added by the API instead of rejecting the response. Individual enums can be controlled with x-speakeasy-unknown-values: allow or x-speakeasy-unknown-values: disallow in the OpenAPI spec.
boolean
true
forwardCompatibleUnionsByDefault
Controls whether discriminated unions accept unknown discriminator values. When set to tagged-only, SDKs capture unknown union variants in a type-safe way instead of failing deserialization. Individual unions can be controlled with x-speakeasy-unknown-values: allow or x-speakeasy-unknown-values: disallow in the OpenAPI spec.
string
tagged-only
Forward compatibility and fault tolerance
These options work together with laxMode and unionStrategy to provide robust forward compatibility. When all four features are enabled (the default for new TypeScript SDKs), your SDK will gracefully handle API evolution including new enum values, new union types, missing fields, and type mismatches. See the forward compatibility guide for more details.
Whether to flatten SSE (Server-Sent Events) responses by extracting the data field from wrapper models, providing direct access to the event data instead of the wrapper object.
Whether to flatten SSE (Server-Sent Events) responses by extracting the data field from wrapper models, providing direct access to the event data instead of the wrapper object.
These options update the TypeScript SDK build toolchain to use faster, modern build tools. Enabling both options can speed up generation time by up to 35% in GitHub Actions and locally.
typescript:
useOxlint: true
useTsgo: true
Property
useOxlint
Description
Replace ESLint with OxLint, a Rust-based linter that is 50-100x faster. When enabled, the generated SDK uses OxLint for linting instead of ESLint, significantly reducing lint times in CI and local development.
Default
true (new SDKs), false (existing SDKs)
Type
boolean
useTsgo
Description
Replace the standard TypeScript compiler (tsc) with TSGo, Microsoft's native Go-based TypeScript compiler. When enabled, the generated SDK uses TSGo for type checking and compilation, delivering up to 10x faster build times with lower memory usage.
Default
true (new SDKs), false (existing SDKs)
Type
boolean
Property
Description
Type
Default
useOxlint
Replace ESLint with OxLint, a Rust-based linter that is 50-100x faster. When enabled, the generated SDK uses OxLint for linting instead of ESLint, significantly reducing lint times in CI and local development.
boolean
true (new SDKs), false (existing SDKs)
useTsgo
Replace the standard TypeScript compiler (tsc) with TSGo, Microsoft's native Go-based TypeScript compiler. When enabled, the generated SDK uses TSGo for type checking and compilation, delivering up to 10x faster build times with lower memory usage.
boolean
true (new SDKs), false (existing SDKs)
Generation speed optimization
For fastest generation times, enable both useOxlint and useTsgo together. OxLint replaces ESLint with a Rust-based linter that processes files in parallel, while TSGo replaces tsc with a native Go compiler that delivers up to 10x faster type checking. Combined, these tools can reduce SDK generation time by up to 35%.
Deprecated. Previously used to generate an MCP server as part of the TypeScript SDK. Users should leave this set to false and use the standalone MCP server generation target (mcp-typescript) instead.
Deprecated. Previously used to generate an MCP server as part of the TypeScript SDK. Users should leave this set to false and use the standalone MCP server generation target (mcp-typescript) instead.