> This page is for SDK, version Current (default).
> For other versions, use one of these documentation indexes:
> - Current (default): https://buildwithfern.com/learn/sdks/current/llms.txt
> - Legacy: https://buildwithfern.com/learn/sdks/legacy/llms.txt

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt.

# 自定义方法名称

> 了解如何在 Fern 中自定义 SDK 方法名称，创建直观、用户友好的代码。配置组名和方法结构以实现更好的 API 客户端设计。

您可以精细调整 SDK 方法和组名称，创建直观、用户友好的代码，以匹配您的 API 用途。例如，您可以将 SDK 配置为使用 `client.users.create()` 而不是 `client.postUsers`。

## 生成的 SDK 行为

Fern 使用您配置的组名和方法名称生成 SDK 方法。命名格式会自动适配各种语言（Python 中的 `snake_case`、TypeScript 中的 `camelCase`、Go 中的 `PascalCase` 等），因此您只需定义一次端点结构，就能在所有生成的 SDK 中获得正确格式的方法。

#### TypeScript

```ts
const response = await client.users.create();
```

#### Python

```python
response = client.users.create()
# or async
response = await async_client.users.create()
```

#### Java

```java
const response = client.users().create();
```

#### Go

```go
const response = client.Users.Create();
```

## 设置方法名称

在 API 定义中配置端点如何映射到 SDK 方法和组名称：

**`openapi.yaml`**

```yaml title="openapi.yaml" {4-5}
paths:
  /users:
    post:
      x-fern-sdk-group-name: users
      x-fern-sdk-method-name: create
```

有关完整的配置详情，请参阅 [OpenAPI 中的方法名称](/learn/zh/api-definitions/openapi/extensions/method-names)。