@azure-tools/openai-typespec

中文文档
1.34.1发布于 2026/11/04MITES Module零依赖近 30 天下载 3.7万

The TypeSpec definition is an automatic import of the OpenAI OpenAPI description using tsp-openapi3.

原始使用文档
文档目录9 节
  1. Using the package
  2. Installing the package
  3. Example definition
  4. Versioning policy
  5. Weekly refresh
  6. Manual refresh
  7. Publishing a new version
  8. Bumping the version
  9. Publishing the package

OpenAI TypeSpec definition

The TypeSpec definition is an automatic import of the OpenAI OpenAPI description using tsp-openapi3.

PLEASE DO NOT SUBMIT ANY MANUAL MODIFICATIONS AS THEY'LL BE OVERWRITTEN BY THE NEXT IMPORT.

Using the package

Installing the package

You can install the package by running npm i @azure-tools/openai-typespec or an equivalent command for your package manager.

Example definition

Here is an example on how you can use the type definitions after installing them.

// using an import with a path instead of the whole package is important
// to avoid importing operations which you most likely don't want in your definition
import "@azure-tools/openapi-typespec/models/responses";

using OpenAI;

model MyModel {
   someOpenAIProperty: OpenAI.Response;
}

Versioning policy

This package DOES NOT follow semantic versioning (SemVer). This means ANY version update MAY contain source breaking changes, either directly for the consuming definitions, or indirectly for the assets generated those definitions. The main reason for such a policy being this package is an automatic import of the OpenAPI description shared by OpenAI, and those description do not follow any specific versioning scheme.

Weekly refresh

The definitions are being updated weekly by the following workflow .github/workflows/weekly-ts.yml.

Manual refresh

If you want to manually refresh the definitions you can either:

  • Queue a new run for the workflow.

  • Run the following commands locally:

    yarn install
    yarn import-openapi
    yarn tsp:all
    yarn tsp:validate
    yarn tsp:validate:export
    

Publishing a new version

Bumping the version

Bumping the version is handled automatically by the release please workflow. Make sure you follow conventional commits to trigger new releases.

Publishing the package

GitHub releases

Upon the tag push, the publish.yml workflow will create a new GitHub release automatically. It can also be queued manually from the web interface/CLI, make sure you select a tag as the source branch.

Public npm feed

After the workflow above is completed running, make sure you manually queue the partner pipeline with the following team name: azureaifoundrydevx.

版本与发布记录

@azure-tools/openai-typespec 共发布 50 个版本,首次发布于 2025/11/13;过去 12 个月发布了 50 个版本。

版本发布日期距今
1.34.1latest2026/11/043 天前
1.34.02026/11/035 天前
1.33.02026/10/318 天前
1.32.02026/10/2019 天前
1.31.02026/10/1919 天前
1.30.02026/09/291 个月前

关于 @azure-tools/openai-typespec 的常见问题

@azure-tools/openai-typespec 是什么?

The TypeSpec definition is an automatic import of the OpenAI OpenAPI description using tsp-openapi3.

如何安装 @azure-tools/openai-typespec?

在项目目录运行 npm install @azure-tools/openai-typespec,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@typespec/http(^1.14.0)、@typespec/openapi(^1.14.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@azure-tools/openai-typespec 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/azure-tools__openai-typespec 是否存在。

@azure-tools/openai-typespec 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@azure-tools/openai-typespec 可以商用吗?

@azure-tools/openai-typespec 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@azure-tools/openai-typespec 的下载量有多少?

根据 npm 官方下载统计,@azure-tools/openai-typespec 在 2026/10/08 – 2026/11/06 这 30 天内被下载 36,997 次,日均约 1,233 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@azure-tools/openai-typespec 还在维护吗?

最新版本 1.34.1 发布于 2026/11/04(3 天前);至今共发布 50 个版本,其中过去 12 个月发布了 50 个;首次发布于 2025/11/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。