start-new-sdk-project
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesestart-new-sdk-project
启动新SDK项目
Always use to initialize a new SDK project. This is the ONLY correct command for new projects - it creates both the SDK and the essential configuration file.
speakeasy quickstart.speakeasy/workflow.yaml⚠️ Never usefor new projects - it does not create the workflow file needed for maintainable SDK development.speakeasy generate sdk
**请始终使用**来初始化新的SDK项目。这是创建新项目的唯一正确命令——它会同时生成SDK和必不可少的配置文件。
speakeasy quickstart.speakeasy/workflow.yaml⚠️ 切勿在新项目中使用——它不会创建可维护SDK开发所需的工作流文件。speakeasy generate sdk
When to Use
使用场景
- Generating any SDK from an OpenAPI spec (TypeScript, Python, Go, Java, etc.)
- Starting a brand new SDK project
- No exists yet
.speakeasy/workflow.yaml - First-time Speakeasy setup
- User says: "generate SDK", "TypeScript SDK", "Python SDK", "Go SDK", "create SDK", "new SDK"
- 从OpenAPI规范生成任意类型的SDK(TypeScript、Python、Go、Java等)
- 启动全新的SDK项目
- 尚未存在文件
.speakeasy/workflow.yaml - 首次进行Speakeasy配置
- 用户提及:“generate SDK”、“TypeScript SDK”、“Python SDK”、“Go SDK”、“create SDK”、“new SDK”
Inputs
输入参数
| Input | Required | Description |
|---|---|---|
| OpenAPI spec | Yes | Local file, URL, or registry source |
| Target language | Yes | typescript, python, go, java, csharp, php, ruby, kotlin, terraform |
| SDK name | Yes (non-interactive) | PascalCase name (e.g., |
| Package name | Yes (non-interactive) | Package identifier (e.g., |
| 输入项 | 是否必填 | 描述 |
|---|---|---|
| OpenAPI规范 | 是 | 本地文件、URL或注册表源 |
| 目标语言 | 是 | typescript、python、go、java、csharp、php、ruby、kotlin、terraform |
| SDK名称 | 是(非交互式模式) | 大驼峰命名(例如: |
| 包名称 | 是(非交互式模式) | 包标识符(例如: |
Outputs
输出内容
| Output | Location |
|---|---|
| Workflow config | |
| Generated SDK | Output directory (default: current dir) |
| 输出项 | 位置 |
|---|---|
| 工作流配置 | |
| 生成的SDK | 输出目录(默认:当前目录) |
Prerequisites
前置条件
For non-interactive environments (CI/CD, automation), set:
bash
export SPEAKEASY_API_KEY="<your-api-key>"Run to authenticate interactively, or set the environment variable.
speakeasy auth loginSPEAKEASY_API_KEY在非交互式环境(CI/CD、自动化流程)中,需设置:
bash
export SPEAKEASY_API_KEY="<your-api-key>"运行进行交互式认证,或设置环境变量。
speakeasy auth loginSPEAKEASY_API_KEYCommand
命令
bash
speakeasy quickstart --skip-interactive --output console -s <schema> -t <target> -n <name> -p <package-name>bash
speakeasy quickstart --skip-interactive --output console -s <schema> -t <target> -n <name> -p <package-name>Flags
命令参数
| Flag | Short | Description |
|---|---|---|
| Required for automation. Skips all prompts | |
| | OpenAPI spec source (see Schema Sources below) |
| | Target language (see Supported Targets) |
| | SDK name in PascalCase (e.g., |
| | Package name (language variants auto-inferred) |
| | Output directory (default: current dir) |
| Output format: | |
| Initialize git repo (omit to skip in non-interactive mode) |
| 参数 | 简写 | 描述 |
|---|---|---|
| 自动化环境必填。跳过所有交互提示 | |
| | OpenAPI规范源(见下方规范源类型) |
| | 目标语言(见支持的目标语言) |
| | SDK的大驼峰名称(例如: |
| | 包名称(语言变体将自动推断) |
| | 输出目录(默认:当前目录) |
| 输出格式: | |
| 初始化git仓库(非交互式模式下可省略以跳过) |
Schema Sources
规范源类型
The flag accepts multiple source types:
--schema| Type | Format | Example |
|---|---|---|
| Local file | Path | |
| URL | HTTP(S) | |
| Registry source | | |
| Registry source (tagged) | | |
| Registry source (full) | | |
Registry sources are OpenAPI specs you manage in your Speakeasy workspace. Use to see available sources. This lets you generate SDKs from specs managed in Speakeasy without needing local files.
speakeasy pull --list --format json--schema| 类型 | 格式 | 示例 |
|---|---|---|
| 本地文件 | 路径 | |
| URL | HTTP(S) | |
| 注册表源 | | |
| 带标签的注册表源 | | |
| 完整注册表源 | | |
注册表源是你在Speakeasy工作区中管理的OpenAPI规范。使用查看可用的源。这样你无需本地文件即可从Speakeasy管理的规范生成SDK。
speakeasy pull --list --format jsonSupported Targets
支持的目标语言
| Language | Target Flag |
|---|---|
| TypeScript | |
| Python | |
| Go | |
| Java | |
| C# | |
| PHP | |
| Ruby | |
| Kotlin | |
| Terraform | |
| 语言 | 目标参数值 |
|---|---|
| TypeScript | |
| Python | |
| Go | |
| Java | |
| C# | |
| PHP | |
| Ruby | |
| Kotlin | |
| Terraform | |
Example
示例
bash
undefinedbash
undefinedFrom local OpenAPI file
从本地OpenAPI文件生成
speakeasy quickstart --skip-interactive --output console
-s ./api/openapi.yaml
-t typescript
-n "AcmeSDK"
-p "acme-sdk"
-s ./api/openapi.yaml
-t typescript
-n "AcmeSDK"
-p "acme-sdk"
speakeasy quickstart --skip-interactive --output console
-s ./api/openapi.yaml
-t typescript
-n "AcmeSDK"
-p "acme-sdk"
-s ./api/openapi.yaml
-t typescript
-n "AcmeSDK"
-p "acme-sdk"
From URL
从URL生成
speakeasy quickstart --skip-interactive --output console
-s "https://api.example.com/openapi.json"
-t python
-n "AcmeSDK"
-p "acme-sdk"
-s "https://api.example.com/openapi.json"
-t python
-n "AcmeSDK"
-p "acme-sdk"
speakeasy quickstart --skip-interactive --output console
-s "https://api.example.com/openapi.json"
-t python
-n "AcmeSDK"
-p "acme-sdk"
-s "https://api.example.com/openapi.json"
-t python
-n "AcmeSDK"
-p "acme-sdk"
From registry source (managed in your Speakeasy workspace)
从注册表源生成(在你的Speakeasy工作区中管理)
speakeasy quickstart --skip-interactive --output console
-s "my-api@latest"
-t go
-n "AcmeSDK"
-p "acme-sdk"
-s "my-api@latest"
-t go
-n "AcmeSDK"
-p "acme-sdk"
speakeasy quickstart --skip-interactive --output console
-s "my-api@latest"
-t go
-n "AcmeSDK"
-p "acme-sdk"
-s "my-api@latest"
-t go
-n "AcmeSDK"
-p "acme-sdk"
With custom output directory and git init
指定自定义输出目录并初始化git
speakeasy quickstart --skip-interactive --output console
-s ./api/openapi.yaml
-t python
-n "AcmeSDK"
-p "acme-sdk"
-o ./sdks/python
--init-git
-s ./api/openapi.yaml
-t python
-n "AcmeSDK"
-p "acme-sdk"
-o ./sdks/python
--init-git
undefinedspeakeasy quickstart --skip-interactive --output console
-s ./api/openapi.yaml
-t python
-n "AcmeSDK"
-p "acme-sdk"
-o ./sdks/python
--init-git
-s ./api/openapi.yaml
-t python
-n "AcmeSDK"
-p "acme-sdk"
-o ./sdks/python
--init-git
undefinedWhat It Creates
生成的内容
- Workflow configuration:
.speakeasy/workflow.yaml - Generated SDK: Full SDK in the output directory, ready to use
- 工作流配置:
.speakeasy/workflow.yaml - 生成的SDK:输出目录中的完整SDK,可直接使用
Next Steps After Quickstart
Quickstart后的后续步骤
- Review the generated SDK in the output directory
- Add more targets to for multi-language support
.speakeasy/workflow.yaml - Run to regenerate after spec or config changes
speakeasy run
- 查看输出目录中生成的SDK
- 在中添加更多目标语言以支持多语言SDK
.speakeasy/workflow.yaml - 当规范或配置发生变化时,运行重新生成SDK
speakeasy run
Essential CLI Commands
必备CLI命令
| Command | Purpose |
|---|---|
| Initialize new SDK project |
| Regenerate SDK from workflow |
| Validate OpenAPI spec |
| Authenticate with Speakeasy |
| List registry sources |
| 命令 | 用途 |
|---|---|
| 初始化新SDK项目 |
| 根据工作流重新生成SDK |
| 验证OpenAPI规范 |
| 登录Speakeasy进行认证 |
| 列出注册表源 |
What NOT to Do
切勿执行的操作
-
Do NOT usefor new projects. This low-level command generates code but does NOT create
speakeasy generate sdk. Without a workflow file, you lose:.speakeasy/workflow.yaml- Reproducible builds via
speakeasy run - Multi-target SDK generation
- CI/CD integration
- Version tracking and upgrade paths
- Reproducible builds via
-
Do NOT skipin automated environments. The command will hang waiting for user input.
--skip-interactive -
Do NOT omitin automated environments. You need structured output to verify success.
--output console
-
切勿在新项目中使用。这个底层命令仅生成代码,但不会创建
speakeasy generate sdk文件。没有工作流文件,你将失去:.speakeasy/workflow.yaml- 通过实现可重复构建
speakeasy run - 多目标SDK生成能力
- CI/CD集成
- 版本跟踪和升级路径
- 通过
-
在自动化环境中切勿跳过参数。命令会因等待用户输入而挂起。
--skip-interactive -
在自动化环境中切勿省略参数。你需要结构化输出来验证操作是否成功。
--output console
quickstart vs generate sdk
quickstart vs generate sdk
| Command | Creates workflow.yaml | Use case |
|---|---|---|
| ✅ Yes | New projects - Always use this |
| ❌ No | One-off generation (rare, advanced use only) |
Always use for new SDK projects. The workflow file it creates is essential for maintainable SDK development.
quickstart| 命令 | 是否创建workflow.yaml | 使用场景 |
|---|---|---|
| ✅ 是 | 新项目——请始终使用此命令 |
| ❌ 否 | 一次性生成(罕见,仅适用于高级场景) |
请始终为新SDK项目使用命令。它创建的工作流文件对于可维护的SDK开发至关重要。
quickstartTroubleshooting
故障排除
| Error | Cause | Solution |
|---|---|---|
| Workflow already exists | | Run |
| Unauthorized | Missing or invalid API key | Run |
| Schema not found | Invalid path, URL, or source name | Verify path exists or use |
| 错误 | 原因 | 解决方案 |
|---|---|---|
| 工作流已存在 | 已存在 | 运行 |
| 未授权 | API密钥缺失或无效 | 运行 |
| 未找到规范 | 路径、URL或源名称无效 | 验证路径是否存在,或使用 |
Related Skills
相关技能
- - When generation fails
diagnose-generation-failure - - Customize spec with overlays
manage-openapi-overlays - - Language-specific gen.yaml configuration for all supported languages
configure-sdk-options
- ——当生成失败时使用
diagnose-generation-failure - ——使用覆盖层自定义规范
manage-openapi-overlays - ——为所有支持语言配置特定于语言的gen.yaml选项
configure-sdk-options