Octri

get_sdk_methods

展示如何通过生成的 SDK 调用端点。这是代理应该编写的代码,而不是对 SDK 名称的猜测。代码片段来自 SDK 设置,因此会使用你的客户端形态:包名称、命名空间和方法名称。

何时会列出

适用于每台服务器和每种工具模式。工具组可以不包含文档工具。

参数

slugstring

按 slug 指定一个端点。省略此项则适用于所有端点。

languagestring

指定一种语言,例如 typescript、python 或 go。省略此项则适用于生成的所有语言。

projectIdstring

要读取的项目。省略此项:服务器已知晓其项目,传入其他项目则会改为读取该项目。

返回值

每个端点都有一个标题,其中包含其 SDK 方法名称和 METHOD /path,然后每种语言各有一个代码片段。

提示

客户端读取的注释,用于判断哪些操作可以在不询问用户的情况下运行。

提示值为 true 时,表示
readOnlyHinttrue不会更改任何内容
destructiveHintfalse可以更改或删除数据
idempotentHinttrue调用两次不会比调用一次做得更多
openWorldHinttrue会通过网络访问服务器之外的资源

示例

一种语言中的一个端点

Call
{
  "name": "get_sdk_methods",
  "arguments": {
    "slug": "post-customers",
    "language": "typescript"
  }
}
Result
## Create a customer: `createCustomer()`
`POST /customers`

**typescript**
```typescript
import { Client } from "acme-sdk";

const client = new Client({
  baseUrl: "https://api.acme.com/v1",
  auth: { bearer: process.env.API_TOKEN! },
  retry: { maxAttempts: 3 },
});

const result = await client.customers.create({
  name: "Untitled",
  email: "jane.doe@example.com",
});
```