Typescript SDK: use snake_case/camelCase for request parameters

Last updated: October 10, 2024

In the Typescript SDKs generated by Stainless, request parameters use the same naming conventions as defined by the API, whether that's snake_case or camelCase.

This decision ensures direct alignment with the API's design and promotes consistency. Here's why we follow this approach:

  • Direct API Representation: Keeping parameter names identical to those in the API ensures that the types in the SDK accurately represent the API's expectations. This consistency helps prevent confusion and reduces the likelihood of errors.

  • Type Safety with Direct Calls: Developers who prefer making direct API calls (e.g., using fetch('...')) benefit from having type definitions that match the API exactly. This alignment enhances type safety without requiring additional transformations.

  • Simplified SDK: Avoiding conversion between naming conventions keeps SDKs lightweight and less complex. This focus on simplicity helps maintain performance and reduces potential bugs related to parameter name transformations.

While some JavaScript developers might expect camelCase parameter names in TypeScript code, prioritizing consistency with the API's parameter naming—whether snake_case or camelCase—ensures clarity and efficiency for all users.