You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CLI generation is currently in **alpha** and available exclusively to
12
-
**Enterprise** customers. Features and configuration may change. [Contact
13
-
us](https://www.speakeasy.com/pricing) for access.
10
+
<Callouttype="warning"title="Alpha · Early Access">
11
+
CLI generation is currently in **alpha** and available exclusively to**early
12
+
access** customers. Features and configuration may change. [Contact
13
+
us](/book-demo) for access.
14
14
</Callout>
15
15
16
-
Speakeasy generates a fully functional command-line interface from your OpenAPI specification. The CLI is written in Go using [Cobra](https://cobra.dev/) and wraps a generated Go SDK, providing a per-operation command structure with built-in authentication, multiple output formats, and cross-platform distribution tooling.
16
+
Speakeasy generates a fully functional command-line interface from an OpenAPI specification. The CLI is written in Go using [Cobra](https://cobra.dev/) and wraps a generated Go SDK, providing per-operation commands, built-in authentication, multiple output formats, shell completions, and cross-platform distribution tooling.
17
17
18
18
## Prerequisites
19
19
20
20
- The [Speakeasy CLI](/docs/speakeasy-reference/cli/getting-started)
│ ├── output/ # Output formatting and agent-mode behavior
90
+
│ ├── usage/ # Grouped help and machine-readable usage schema
91
+
│ ├── explorer/ # Interactive command explorer (when enabled)
96
92
│ └── sdk/ # Auto-generated Go SDK
97
93
├── scripts/
98
94
│ ├── install.sh # Linux/macOS install script
@@ -111,103 +107,228 @@ go build -o petstore ./cmd/petstore
111
107
112
108
### 4. Configure authentication
113
109
114
-
Run the interactive setup wizard to configure API credentials:
110
+
Run the interactive setup wizard to configure API credentials and global settings:
115
111
116
112
```bash
117
-
./my-cli configure
113
+
./petstore configure
118
114
```
119
115
120
-
This stores credentials securely in the OS keychain (macOS Keychain, Windows Credential Manager, or Linux Secret Service) and generates a config file at `~/.config/<cliName>/config.yaml`.
116
+
When available, secrets are stored in the OS keychain (macOS Keychain, Windows Credential Manager, or Linux Secret Service / keyring-compatible backends). Non-secret configuration is stored in `~/.config/<cliName>/config.yaml`.
117
+
118
+
If interactive auth is enabled and the API has global security, generated CLIs also expose an `auth` command group:
119
+
120
+
```bash
121
+
./petstore auth login
122
+
./petstore auth whoami
123
+
./petstore auth logout
124
+
```
121
125
122
-
## Key features
126
+
## How generated CLIs behave
123
127
124
128
### Per-operation commands
125
129
126
130
Every API operation becomes a CLI command. Operations are grouped by tags, with smart stutter removal to keep command names clean:
127
131
128
132
```bash
129
-
# If your API has a "users" tag with a "list-users" operation:
130
-
my-cli users list# "-users" suffix is removed from "list-users"
133
+
# If the API has a "users" tag with a "list-users" operation:
134
+
petstore users list
131
135
132
136
# View all available commands:
133
-
my-cli --help
137
+
petstore --help
134
138
```
135
139
136
-
### Multiple output formats
140
+
### Request input options
141
+
142
+
Generated CLIs support multiple request input styles with predictable precedence:
137
143
138
-
Control output format with the `--output-format` flag (or `-o` for short):
144
+
- Individual flags (highest priority)
145
+
-`--body` JSON
146
+
- stdin JSON (lowest priority)
139
147
140
148
```bash
141
-
my-cli users list -o json # JSON output
142
-
my-cli users list -o yaml # YAML output
143
-
my-cli users list -o table # Tabular output
144
-
my-cli users list -o pretty # Colored key-value output (default)
For binary-only operations, the CLI blocks writing raw binary directly to an interactive terminal and instructs the user to use `--output-file`, `--output-b64`, or piping.
172
211
173
-
The CLI resolves credentials with a 4-tier priority:
212
+
### Response headers
174
213
175
-
-**Flags** — `--api-key`, `--bearer-token`, etc.
176
-
-**Environment variables** — `<PREFIX>_API_KEY`, `<PREFIX>_BEARER_TOKEN`, etc.
These are emitted incrementally rather than buffered.
237
+
238
+
### Retries, timeout, and custom headers
239
+
240
+
Generated CLIs include runtime controls that map to the underlying SDK behavior. Retry flags are available when retry support is enabled for the generated target/spec:
241
+
242
+
```bash
243
+
petstore users list --timeout 30s
244
+
petstore users list --no-retries
245
+
petstore users list --retry-max-elapsed-time 10s
246
+
petstore users list --header "X-Request-ID: abc-123"
187
247
```
188
248
189
249
### Diagnostics
190
250
191
-
Debug API calls without making real requests:
251
+
The CLI includes built-in diagnostics that are safe for scripts and CI:
252
+
253
+
```bash
254
+
petstore users list --dry-run
255
+
petstore users list --debug
256
+
```
257
+
258
+
-`--dry-run` shows the request that would be sent without making a network call
259
+
-`--debug` logs request/response diagnostics to stderr
260
+
- both paths automatically redact common secret-bearing headers and payload fields
261
+
262
+
### Interactive mode
263
+
264
+
Interactive mode is enabled by default in the generator and improves the human terminal experience:
265
+
266
+
- auto-prompting for unresolved required fields
267
+
- an `explore` TUI for browsing and launching commands
268
+
- interactive `configure` flows
269
+
- interactive `auth login` flows when auth is available and interactive auth is enabled
192
270
193
271
```bash
194
-
my-cli users list --dry-run # Show the request without sending it
195
-
my-cli users list --debug # Show full request/response with secret redaction
272
+
petstore explore
273
+
petstore users create
274
+
petstore users create --no-interactive
196
275
```
197
276
277
+
Interactive prompting and explorer auto-launch only happen when stdin and stdout are TTYs.
278
+
279
+
### Agent mode
280
+
281
+
Generated CLIs also support an agent-aware runtime mode optimized for AI coding assistants and non-human terminal drivers.
282
+
283
+
```bash
284
+
petstore users list --agent-mode
285
+
petstore users list --agent-mode=false
286
+
```
287
+
288
+
Agent mode can also auto-enable when the CLI detects well-known agent environments such as Claude Code, Cursor, Codex, Aider, Cline, Windsurf, GitHub Copilot, Amazon Q, Gemini Code Assist, and Cody.
289
+
290
+
When agent mode is active:
291
+
292
+
- the default output format becomes `toon`
293
+
- errors become structured and machine-readable
294
+
- interactive surfaces are suppressed or blocked
295
+
- explorer auto-launch is disabled
296
+
297
+
### Machine-readable usage schema
298
+
299
+
Generated CLIs provide both standard Cobra help and a machine-readable usage schema:
300
+
301
+
```bash
302
+
petstore users create --help
303
+
petstore users create --usage
304
+
```
305
+
306
+
`--usage` emits a KDL representation of the selected command, including flags, defaults, help text, aliases, and configuration metadata.
307
+
198
308
### Shell completions
199
309
200
-
Generate shell completions for your CLI:
310
+
Generated CLIs support Cobra’s built-in completion command:
201
311
202
312
```bash
203
-
my-cli completion bash# Bash
204
-
my-cli completion zsh# Zsh
205
-
my-cli completion fish# Fish
206
-
my-cli completion powershell# PowerShell
313
+
petstore completion bash
314
+
petstore completion zsh
315
+
petstore completion fish
316
+
petstore completion powershell
207
317
```
208
318
319
+
Source the generated output directly in a shell session or install completion scripts as part of the CLI setup.
320
+
321
+
## Authentication and configuration precedence
322
+
323
+
The generated CLI resolves values in a predictable order:
0 commit comments