> ## Documentation Index
> Fetch the complete documentation index at: https://glasser.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# glasser run

> 运行接口并获取输出。

## 用法

```bash theme={null}
glasser run -p <provider> -e <endpoint> [-i '<json>' | -f <file>]
```

运行一个接口，并为本次调用付费。省略幂等键时，CLI 会生成并显示一个键；遇到结果不明的失败时，使用同一个键重试，即可读取原 Run，避免再次扣费。

## 选项

| 选项 | 说明 |
| - | - |
| `--provider, -p` | 数据提供商标识，例如 pdl |
| `--endpoint, -e` | 接口键，例如 /v5/person/enrich |
| `--input, -i` | 数据提供商原生输入：内联 JSON 或 @path/to/file.json |
| `--input-file, -f` | 从 JSON 文件读取输入，也可使用 -i @file |
| `--endpoint-version` | 选择受支持的接口版本，不锁定价格；版本不可用或已停用时返回 409 |
| `--idempotency-key` | 使用同一个键安全重试；省略时自动生成并显示 |
| `--task` | 将本次 Run 关联到搜索响应中的 `task_id` |
| `--wait, -w` | 轮询至 Run 进入终态 |
| `--wait-timeout` | 最长等待秒数，默认为 300，需配合 --wait |
| `--output, -o` | 将 Run 的 output 字段写入文件，仅适用于有输出的 COMPLETED 状态 |

## 等待结果

未使用 `--wait` 时，异步接口可能返回 `QUEUED` 或 `RUNNING` 状态的 Run。使用 `--wait` 轮询至终态。`--wait-timeout` 必须为正整数，单位为秒，默认为 `300`。

等待超时以退出码 `1` 结束，但不会停止 Run。通过 `glasser runs get -r <runId> --wait` 继续等待，并分别检查 `status`、 `provider_response.http_status` 和 `charge_usd`。

传入 `--task`，可将 Run 与搜索、检查归入同一个 Task。详见 [将相关调用归入同一个 Task](https://glasser.ai/docs/zh/cli.md#keep-calls-in-one-task)。

全局选项、JSON 模式、退出码和环境变量见 [CLI 约定](https://glasser.ai/docs/zh/cli.md#global-flags)。

## 数据提供商错误

对于数据提供商错误，CLI 会显示 HTTP 状态和错误正文。使用 `--json` 时，请从返回的 Run 中读取 `provider_response.http_status` 和 `provider_response.error`。 `COMPLETED` 状态本身不表示数据提供商已接受请求。详见 [Run 响应处理](https://glasser.ai/docs/zh/api-reference/overview.md#read-the-result)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.