cu-cli 0.1.0b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. cu_cli-0.1.0b1/PKG-INFO +345 -0
  2. cu_cli-0.1.0b1/README.md +305 -0
  3. cu_cli-0.1.0b1/pyproject.toml +102 -0
  4. cu_cli-0.1.0b1/setup.cfg +4 -0
  5. cu_cli-0.1.0b1/src/cu_cli/__init__.py +17 -0
  6. cu_cli-0.1.0b1/src/cu_cli/__main__.py +11 -0
  7. cu_cli-0.1.0b1/src/cu_cli/apiversion.py +124 -0
  8. cu_cli-0.1.0b1/src/cu_cli/cli.py +138 -0
  9. cu_cli-0.1.0b1/src/cu_cli/client.py +138 -0
  10. cu_cli-0.1.0b1/src/cu_cli/commands/__init__.py +4 -0
  11. cu_cli-0.1.0b1/src/cu_cli/commands/_command_spec.py +94 -0
  12. cu_cli-0.1.0b1/src/cu_cli/commands/_help.py +33 -0
  13. cu_cli-0.1.0b1/src/cu_cli/commands/_infra_models.py +184 -0
  14. cu_cli-0.1.0b1/src/cu_cli/commands/_infra_wizard.py +630 -0
  15. cu_cli-0.1.0b1/src/cu_cli/commands/_model_setup.py +46 -0
  16. cu_cli-0.1.0b1/src/cu_cli/commands/_options.py +112 -0
  17. cu_cli-0.1.0b1/src/cu_cli/commands/analyze.py +631 -0
  18. cu_cli-0.1.0b1/src/cu_cli/commands/analyzer.py +1462 -0
  19. cu_cli-0.1.0b1/src/cu_cli/commands/defaults.py +172 -0
  20. cu_cli-0.1.0b1/src/cu_cli/commands/doctor.py +166 -0
  21. cu_cli-0.1.0b1/src/cu_cli/commands/env_var.py +67 -0
  22. cu_cli-0.1.0b1/src/cu_cli/commands/infra.py +302 -0
  23. cu_cli-0.1.0b1/src/cu_cli/commands/profile_cmd.py +525 -0
  24. cu_cli-0.1.0b1/src/cu_cli/commands/upgrade.py +120 -0
  25. cu_cli-0.1.0b1/src/cu_cli/core/__init__.py +17 -0
  26. cu_cli-0.1.0b1/src/cu_cli/core/analyze.py +44 -0
  27. cu_cli-0.1.0b1/src/cu_cli/core/analyzers.py +30 -0
  28. cu_cli-0.1.0b1/src/cu_cli/core/azure_resources.py +486 -0
  29. cu_cli-0.1.0b1/src/cu_cli/core/defaults.py +18 -0
  30. cu_cli-0.1.0b1/src/cu_cli/core/doctor.py +42 -0
  31. cu_cli-0.1.0b1/src/cu_cli/core/foundry.py +68 -0
  32. cu_cli-0.1.0b1/src/cu_cli/core/infra_models.py +367 -0
  33. cu_cli-0.1.0b1/src/cu_cli/core/inputs.py +209 -0
  34. cu_cli-0.1.0b1/src/cu_cli/core/schema.py +24 -0
  35. cu_cli-0.1.0b1/src/cu_cli/errors.py +174 -0
  36. cu_cli-0.1.0b1/src/cu_cli/exit_codes.py +20 -0
  37. cu_cli-0.1.0b1/src/cu_cli/modality.py +24 -0
  38. cu_cli-0.1.0b1/src/cu_cli/output.py +179 -0
  39. cu_cli-0.1.0b1/src/cu_cli/profile.py +30 -0
  40. cu_cli-0.1.0b1/src/cu_cli/py.typed +0 -0
  41. cu_cli-0.1.0b1/src/cu_cli/resources/__init__.py +4 -0
  42. cu_cli-0.1.0b1/src/cu_cli/resources/azd_template/README.md +187 -0
  43. cu_cli-0.1.0b1/src/cu_cli/resources/azd_template/azure.yaml +27 -0
  44. cu_cli-0.1.0b1/src/cu_cli/resources/azd_template/hooks/postprovision.ps1 +320 -0
  45. cu_cli-0.1.0b1/src/cu_cli/resources/azd_template/hooks/postprovision.sh +299 -0
  46. cu_cli-0.1.0b1/src/cu_cli/resources/azd_template/infra/main.bicep +115 -0
  47. cu_cli-0.1.0b1/src/cu_cli/resources/azd_template/infra/main.parameters.json +30 -0
  48. cu_cli-0.1.0b1/src/cu_cli/resources/azd_template/infra/models.json +1 -0
  49. cu_cli-0.1.0b1/src/cu_cli/resources/azd_template/infra/modules/foundry.bicep +122 -0
  50. cu_cli-0.1.0b1/src/cu_cli/schema_validate.py +28 -0
  51. cu_cli-0.1.0b1/src/cu_cli/spec_validate.py +18 -0
  52. cu_cli-0.1.0b1/src/cu_cli/telemetry.py +42 -0
  53. cu_cli-0.1.0b1/src/cu_cli/update_check.py +154 -0
  54. cu_cli-0.1.0b1/src/cu_cli/update_provider.py +92 -0
  55. cu_cli-0.1.0b1/src/cu_cli/windows_self_upgrade.py +245 -0
  56. cu_cli-0.1.0b1/src/cu_cli.egg-info/PKG-INFO +345 -0
  57. cu_cli-0.1.0b1/src/cu_cli.egg-info/SOURCES.txt +59 -0
  58. cu_cli-0.1.0b1/src/cu_cli.egg-info/dependency_links.txt +1 -0
  59. cu_cli-0.1.0b1/src/cu_cli.egg-info/entry_points.txt +3 -0
  60. cu_cli-0.1.0b1/src/cu_cli.egg-info/requires.txt +19 -0
  61. cu_cli-0.1.0b1/src/cu_cli.egg-info/top_level.txt +1 -0
@@ -0,0 +1,345 @@
1
+ Metadata-Version: 2.4
2
+ Name: cu-cli
3
+ Version: 0.1.0b1
4
+ Summary: Author, validate, and run Azure Content Understanding custom analyzers from the terminal — advanced document layout, industry-leading OCR, and grounded field extraction with confidence, all backed by Azure Content Understanding.
5
+ Author: Microsoft Corporation
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Azure/content-understanding-toolkit/tree/main/cu-cli
8
+ Project-URL: Repository, https://github.com/Azure/content-understanding-toolkit
9
+ Project-URL: Issues, https://github.com/Azure/content-understanding-toolkit/issues
10
+ Project-URL: Documentation, https://aka.ms/cu-doc
11
+ Keywords: azure,content-understanding,document-intelligence,ocr,pdf,extract,field-extraction,analyzer,cli,markdown
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Text Processing
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: cu-cli-core<0.2.0,>=0.1.0b1
25
+ Requires-Dist: azure-ai-contentunderstanding>=1.2.0b3
26
+ Requires-Dist: azure-identity>=1.19
27
+ Requires-Dist: azure-mgmt-cognitiveservices>=13.5
28
+ Requires-Dist: click>=8.1
29
+ Requires-Dist: packaging>=23.2
30
+ Requires-Dist: requests>=2.31
31
+ Requires-Dist: rich>=13.7
32
+ Requires-Dist: rich-click>=1.7
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.4; extra == "dev"
35
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
36
+ Requires-Dist: mypy<2,>=1.8; extra == "dev"
37
+ Requires-Dist: ruff<0.16,>=0.5; extra == "dev"
38
+ Requires-Dist: tomli>=2.0; python_version < "3.11" and extra == "dev"
39
+ Requires-Dist: vcrpy>=6.0; extra == "dev"
40
+
41
+ # CU CLI
42
+
43
+ `cu` is the preview command-line interface for Azure Content Understanding in
44
+ Foundry Tools. Use it to provision the required Microsoft Foundry resource,
45
+ optionally deploy selected supported large language models (LLMs) and embeddings
46
+ models, configure Content Understanding defaults, analyze local files, manage
47
+ analyzers, and manage local configuration.
48
+
49
+ > [!IMPORTANT]
50
+ > CU CLI is in preview. Commands and package contracts may change before general
51
+ > availability.
52
+
53
+ ## Content Understanding concepts
54
+
55
+ Content Understanding processes unstructured content, including documents,
56
+ images, audio, and video, into structured output for automation, analytics, and
57
+ search workflows. It is a Foundry Tool that you access through a Microsoft
58
+ Foundry resource in Azure.
59
+
60
+ The Content Understanding documentation uses these terms:
61
+
62
+ - A **file** is the input. It can be a document, image, audio file, video, or
63
+ other [supported file type](https://learn.microsoft.com/azure/ai-services/content-understanding/service-limits#input-file-limits).
64
+ - An **analyzer** defines how Content Understanding processes a file and
65
+ extracts content and structured fields.
66
+ - An **analyzer result** is the output from processing a file. It can include
67
+ extracted Markdown content, structured fields, and modality-specific details.
68
+ - A **prebuilt analyzer** is a ready-to-use analyzer supplied by Content
69
+ Understanding for common content extraction, search, and domain scenarios.
70
+ - A **custom analyzer** is an analyzer you define for your scenario. It uses a
71
+ base analyzer for a content type and a field schema that describes the
72
+ structured fields to extract.
73
+
74
+ CU CLI lets you configure a Microsoft Foundry resource, select an analyzer,
75
+ submit local files, and save analyzer results without calling the REST API
76
+ directly.
77
+
78
+ Further reading:
79
+
80
+ - [What is Content Understanding?](https://learn.microsoft.com/azure/ai-services/content-understanding/overview)
81
+ - [Content Understanding terminology](https://learn.microsoft.com/azure/ai-services/content-understanding/glossary)
82
+
83
+ ## Install
84
+
85
+ Requirements:
86
+
87
+ - Python 3.10 or later
88
+ - [Azure CLI](https://aka.ms/azcli) for login and resource discovery
89
+ - [Azure Developer CLI](https://aka.ms/azd) only when using `cu infra generate`
90
+
91
+ ```bash
92
+ python -m pip install cu-cli
93
+ cu --version
94
+ cu --help
95
+ ```
96
+
97
+ macOS includes an unrelated system command named `cu`. Use the equivalent
98
+ `cu-cli` executable on macOS:
99
+
100
+ ```bash
101
+ cu-cli --help
102
+ ```
103
+
104
+ ## Connect to Microsoft Foundry and check setup
105
+
106
+ You need a Microsoft Foundry resource endpoint. LLM-based prebuilt analyzers and
107
+ custom analyzers also need supported LLM and embeddings deployments plus Content
108
+ Understanding defaults. If any of these are missing, follow the complete
109
+ [Microsoft Foundry provisioning guide](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/provisioning.md).
110
+
111
+ A CU CLI profile is local configuration for one Microsoft Foundry resource. It
112
+ stores the endpoint, authentication method, API version, and optional model
113
+ deployment mappings; it is not an Azure resource. For a ready resource,
114
+ configure the automatically available `default` profile. With Microsoft Entra
115
+ ID authentication:
116
+
117
+ ```bash
118
+ cu profile set endpoint https://<resource-name>.services.ai.azure.com/
119
+ cu profile set auth_mode login
120
+ az login
121
+ cu doctor
122
+ ```
123
+
124
+ Alternatively, use a resource key:
125
+
126
+ ```bash
127
+ cu profile set endpoint https://<resource-name>.services.ai.azure.com/
128
+ cu profile set api_key <key>
129
+ cu doctor
130
+ ```
131
+
132
+ The API key is redacted by `cu profile get` and `cu profile show`. `cu doctor`
133
+ checks the API version, endpoint, authentication, service connectivity, and
134
+ Content Understanding defaults. It exits nonzero when a required check fails,
135
+ so it can serve as a readiness gate.
136
+
137
+ ## Supported Content Understanding API versions
138
+
139
+ Content Understanding API version. Known versions: 2025-11-01 (GA) and
140
+ 2026-06-01-preview (preview); any YYYY-MM-DD-preview version is also accepted.
141
+
142
+ CU CLI defaults to `2025-11-01`. Override the version with `cu profile set
143
+ api_version <version>`, the `--api-version` flag, or the `CU_API_VERSION`
144
+ environment variable; run `cu profile show` to see the active profile's
145
+ configured version.
146
+
147
+ The preview API adds capabilities beyond the GA version. CU CLI returns
148
+ result-based capabilities, such as document metadata and signatures, through
149
+ the normal analysis result without dedicated CLI options. Inline analysis is
150
+ the only preview capability that requires a new CU CLI option:
151
+ `cu analyze --inline` runs supported analysis synchronously and returns the
152
+ result directly instead of using the default long-running-operation (LRO)
153
+ polling flow.
154
+
155
+ ```bash
156
+ cu analyze --inline --api-version 2026-06-01-preview document.pdf --analyzer prebuilt-layout
157
+ ```
158
+
159
+ Save the preview version to a profile to avoid passing `--api-version` on every
160
+ call: `cu profile set api_version 2026-06-01-preview`. Pin to `2025-11-01` for
161
+ production workloads that don't need preview capabilities.
162
+
163
+ Further reading:
164
+
165
+ - [What's new in the `2026-06-01-preview` API](https://learn.microsoft.com/azure/ai-services/content-understanding/whats-new#july-2026)
166
+ - Run `cu analyze --help` for all analyze options.
167
+
168
+ ## Use prebuilt analyzers
169
+
170
+ List the prebuilt analyzers available to the configured resource:
171
+
172
+ ```bash
173
+ cu analyzer list
174
+ ```
175
+
176
+ Start with the `prebuilt-layout` content extraction analyzer. It extracts text,
177
+ paragraphs, tables, figures, and document structure without requiring a language
178
+ model or embeddings model. `-a` is the short form of `--analyzer`:
179
+
180
+ ```bash
181
+ # Generate Markdown from the analyzer result with the CU SDK's to_llm_input().
182
+ cu analyze ./document.pdf -a prebuilt-layout
183
+ ```
184
+
185
+ Markdown generated by the Content Understanding SDK's `to_llm_input()` helper is
186
+ the default output format. The helper formats field extraction results as
187
+ Markdown with YAML frontmatter so they can be used as generative AI model input.
188
+ Use `--llm-input` to select this default view explicitly, or use `--json` to
189
+ return the complete analyzer result as JSON. See the
190
+ [Content Understanding SDK `to_llm_input()` helper](https://learn.microsoft.com/azure/ai-services/content-understanding/whats-new#april-2026).
191
+
192
+ Domain-specific prebuilt analyzers, such as `prebuilt-invoice`, extract a
193
+ defined set of structured fields. They require the model setup described in
194
+ [Deploy models and configure defaults](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/provisioning.md#deploy-models-and-configure-defaults):
195
+
196
+ ```bash
197
+ cu analyze ./invoice.pdf --analyzer prebuilt-invoice --json
198
+ ```
199
+
200
+ The command returns an analyzer result. Use `--json` when you want the
201
+ structured result as JSON.
202
+
203
+ Analyze several files into one output directory. `--pattern` requires
204
+ `--source`, because a positional path can be either a file or a directory and
205
+ `--pattern` only makes sense once a directory is named explicitly:
206
+
207
+ ```bash
208
+ cu analyze --source ./documents --pattern "*.pdf" --output-dir ./results
209
+ ```
210
+
211
+ Each result is written under `./results` and keeps the input path relative to
212
+ `./documents`. For example, `./documents/invoice-01.pdf` produces
213
+ `./results/invoice-01.pdf.result.md`. Markdown results use the
214
+ `.result.md` suffix; adding `--json` produces `.result.json` files instead.
215
+
216
+ Further reading:
217
+
218
+ - [Prebuilt analyzers](https://learn.microsoft.com/azure/ai-services/content-understanding/concepts/prebuilt-analyzers)
219
+ - [Supported input files and service limits](https://learn.microsoft.com/azure/ai-services/content-understanding/service-limits#input-file-limits)
220
+ - Run `cu analyze --help` for input, output, overwrite, concurrency, and reporting options.
221
+
222
+ ## Create a custom analyzer
223
+
224
+ A custom analyzer lets you define the structured fields needed by your
225
+ application. Its analyzer schema identifies a base analyzer for the content type
226
+ and includes a field schema that describes the field names, value types, and
227
+ generation methods.
228
+
229
+ Custom analyzers require supported model deployments and configured Content
230
+ Understanding defaults. Confirm the model-to-deployment mappings before creating
231
+ the analyzer:
232
+
233
+ ```bash
234
+ # Show the Content Understanding defaults configured on the resource.
235
+ cu defaults show
236
+ ```
237
+
238
+ If the required mappings are missing, follow
239
+ [Configure defaults manually](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/provisioning.md#configure-defaults-manually)
240
+ to configure them. Then generate a starter analyzer schema from a representative
241
+ file:
242
+
243
+ ```bash
244
+ # Generate a schema from a representative document.
245
+ cu analyzer schema create \
246
+ --from-sample ./invoice.pdf \
247
+ --output-file ./invoice-schema.json
248
+
249
+ # Review and update the generated schema for your extraction requirements,
250
+ # then create the analyzer.
251
+ cu analyzer create --name invoice_v1 --schema ./invoice-schema.json
252
+
253
+ # Run the analyzer against the sample and summarize whether fields were returned
254
+ # and any confidence values supplied by the service. This is not an accuracy
255
+ # benchmark and does not compare the result with labeled ground truth.
256
+ cu analyzer test invoice_v1 ./invoice.pdf
257
+
258
+ cu analyze ./invoice.pdf --analyzer invoice_v1 --json
259
+ ```
260
+
261
+ Schema generation preserves existing files by default. Pass `--force` only when
262
+ you intentionally want to replace the selected `--output-file`.
263
+
264
+ Further reading:
265
+
266
+ - [Create a custom analyzer](https://learn.microsoft.com/azure/ai-services/content-understanding/tutorial/create-custom-analyzer)
267
+ - [Supported generative models](https://learn.microsoft.com/azure/ai-services/content-understanding/service-limits#supported-generative-models)
268
+ - Run `cu analyzer --help` for analyzer management and testing commands.
269
+
270
+ ## Command overview
271
+
272
+ | Command | Purpose |
273
+ | --- | --- |
274
+ | `cu analyze` | Analyze local files and return analyzer results. |
275
+ | `cu analyzer` | List, show, create, copy, delete, and test analyzers; create and validate local analyzer schemas. |
276
+ | `cu defaults` | Read or configure Content Understanding defaults that map models to deployments. |
277
+ | `cu profile` | Manage local CU CLI endpoint, authentication, API, and model settings. |
278
+ | `cu infra generate` | Generate an azd/Bicep project used to provision a Microsoft Foundry resource and configure Content Understanding. Run `azd up` to provision it. |
279
+ | `cu doctor` | Verify the active CU CLI profile, authentication, and model readiness. |
280
+ | `cu env-var` | Inspect supported environment-variable overrides. |
281
+
282
+ Every command provides examples:
283
+
284
+ ```bash
285
+ cu profile --help
286
+ cu analyzer copy --help
287
+ cu infra generate --help
288
+ ```
289
+
290
+ ## CU CLI usage guide
291
+
292
+ Use this README for installation, resource connection, and the first successful
293
+ analysis. For Azure provisioning, see the
294
+ [Microsoft Foundry provisioning guide](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/provisioning.md). For detailed
295
+ operational guidance, see the
296
+ [CU CLI usage guide](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/usage-guide.md). It explains:
297
+
298
+ - CU CLI profile resolution and environment-variable overrides
299
+ - safe batch previews, output handling, and machine-readable reports
300
+ - analyzer schema, lifecycle, testing, and cross-resource copy workflows
301
+ - Content Understanding defaults and troubleshooting
302
+
303
+ ## More information
304
+
305
+ - [Azure Content Understanding documentation](https://aka.ms/cu-doc)
306
+ - [Support](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/SUPPORT.md)
307
+ - [Contributing](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/CONTRIBUTING.md)
308
+
309
+ The standalone distribution is `cu-cli`. It depends on the separately built
310
+ `cu-cli-core` implementation package in this same product tree. `cu-cli-core`
311
+ is an internal implementation boundary for official CU command-line frontends;
312
+ install and use `cu-cli` rather than importing the core package directly.
313
+
314
+ ## Telemetry
315
+
316
+ CU CLI adds `cu-cli/<version>` to the standard Azure SDK `User-Agent` header on
317
+ requests to the Azure Content Understanding service. Microsoft uses this
318
+ identifier to understand CU CLI adoption. CU CLI does not add customer content
319
+ or separate usage and analytics events to this telemetry.
320
+
321
+ To remove the `cu-cli/<version>` identifier, set `CU_TELEMETRY=off` (also
322
+ accepts `0`, `false`, or `no`) before running CU CLI. The Azure SDK continues to
323
+ send its standard `User-Agent` as part of service requests. See the repository
324
+ [data collection notice](https://github.com/Azure/content-understanding-toolkit#data-collection)
325
+ for more information.
326
+
327
+ ## Use multiple profiles
328
+
329
+ If you work with multiple resources, create named profiles and either activate
330
+ one or select it per command:
331
+
332
+ ```bash
333
+ cu profile create dev
334
+ cu profile set endpoint https://<dev-resource>.services.ai.azure.com/ --name dev
335
+ cu profile create prod
336
+ cu profile set endpoint https://<prod-resource>.services.ai.azure.com/ --name prod
337
+
338
+ cu profile set-active dev
339
+ cu analyzer list
340
+ cu analyzer list --profile prod
341
+ cu doctor --profile prod
342
+ ```
343
+
344
+ See the [CU CLI profile usage guide](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/usage-guide.md#cu-cli-profiles) for
345
+ profile resolution and environment-variable overrides.
@@ -0,0 +1,305 @@
1
+ # CU CLI
2
+
3
+ `cu` is the preview command-line interface for Azure Content Understanding in
4
+ Foundry Tools. Use it to provision the required Microsoft Foundry resource,
5
+ optionally deploy selected supported large language models (LLMs) and embeddings
6
+ models, configure Content Understanding defaults, analyze local files, manage
7
+ analyzers, and manage local configuration.
8
+
9
+ > [!IMPORTANT]
10
+ > CU CLI is in preview. Commands and package contracts may change before general
11
+ > availability.
12
+
13
+ ## Content Understanding concepts
14
+
15
+ Content Understanding processes unstructured content, including documents,
16
+ images, audio, and video, into structured output for automation, analytics, and
17
+ search workflows. It is a Foundry Tool that you access through a Microsoft
18
+ Foundry resource in Azure.
19
+
20
+ The Content Understanding documentation uses these terms:
21
+
22
+ - A **file** is the input. It can be a document, image, audio file, video, or
23
+ other [supported file type](https://learn.microsoft.com/azure/ai-services/content-understanding/service-limits#input-file-limits).
24
+ - An **analyzer** defines how Content Understanding processes a file and
25
+ extracts content and structured fields.
26
+ - An **analyzer result** is the output from processing a file. It can include
27
+ extracted Markdown content, structured fields, and modality-specific details.
28
+ - A **prebuilt analyzer** is a ready-to-use analyzer supplied by Content
29
+ Understanding for common content extraction, search, and domain scenarios.
30
+ - A **custom analyzer** is an analyzer you define for your scenario. It uses a
31
+ base analyzer for a content type and a field schema that describes the
32
+ structured fields to extract.
33
+
34
+ CU CLI lets you configure a Microsoft Foundry resource, select an analyzer,
35
+ submit local files, and save analyzer results without calling the REST API
36
+ directly.
37
+
38
+ Further reading:
39
+
40
+ - [What is Content Understanding?](https://learn.microsoft.com/azure/ai-services/content-understanding/overview)
41
+ - [Content Understanding terminology](https://learn.microsoft.com/azure/ai-services/content-understanding/glossary)
42
+
43
+ ## Install
44
+
45
+ Requirements:
46
+
47
+ - Python 3.10 or later
48
+ - [Azure CLI](https://aka.ms/azcli) for login and resource discovery
49
+ - [Azure Developer CLI](https://aka.ms/azd) only when using `cu infra generate`
50
+
51
+ ```bash
52
+ python -m pip install cu-cli
53
+ cu --version
54
+ cu --help
55
+ ```
56
+
57
+ macOS includes an unrelated system command named `cu`. Use the equivalent
58
+ `cu-cli` executable on macOS:
59
+
60
+ ```bash
61
+ cu-cli --help
62
+ ```
63
+
64
+ ## Connect to Microsoft Foundry and check setup
65
+
66
+ You need a Microsoft Foundry resource endpoint. LLM-based prebuilt analyzers and
67
+ custom analyzers also need supported LLM and embeddings deployments plus Content
68
+ Understanding defaults. If any of these are missing, follow the complete
69
+ [Microsoft Foundry provisioning guide](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/provisioning.md).
70
+
71
+ A CU CLI profile is local configuration for one Microsoft Foundry resource. It
72
+ stores the endpoint, authentication method, API version, and optional model
73
+ deployment mappings; it is not an Azure resource. For a ready resource,
74
+ configure the automatically available `default` profile. With Microsoft Entra
75
+ ID authentication:
76
+
77
+ ```bash
78
+ cu profile set endpoint https://<resource-name>.services.ai.azure.com/
79
+ cu profile set auth_mode login
80
+ az login
81
+ cu doctor
82
+ ```
83
+
84
+ Alternatively, use a resource key:
85
+
86
+ ```bash
87
+ cu profile set endpoint https://<resource-name>.services.ai.azure.com/
88
+ cu profile set api_key <key>
89
+ cu doctor
90
+ ```
91
+
92
+ The API key is redacted by `cu profile get` and `cu profile show`. `cu doctor`
93
+ checks the API version, endpoint, authentication, service connectivity, and
94
+ Content Understanding defaults. It exits nonzero when a required check fails,
95
+ so it can serve as a readiness gate.
96
+
97
+ ## Supported Content Understanding API versions
98
+
99
+ Content Understanding API version. Known versions: 2025-11-01 (GA) and
100
+ 2026-06-01-preview (preview); any YYYY-MM-DD-preview version is also accepted.
101
+
102
+ CU CLI defaults to `2025-11-01`. Override the version with `cu profile set
103
+ api_version <version>`, the `--api-version` flag, or the `CU_API_VERSION`
104
+ environment variable; run `cu profile show` to see the active profile's
105
+ configured version.
106
+
107
+ The preview API adds capabilities beyond the GA version. CU CLI returns
108
+ result-based capabilities, such as document metadata and signatures, through
109
+ the normal analysis result without dedicated CLI options. Inline analysis is
110
+ the only preview capability that requires a new CU CLI option:
111
+ `cu analyze --inline` runs supported analysis synchronously and returns the
112
+ result directly instead of using the default long-running-operation (LRO)
113
+ polling flow.
114
+
115
+ ```bash
116
+ cu analyze --inline --api-version 2026-06-01-preview document.pdf --analyzer prebuilt-layout
117
+ ```
118
+
119
+ Save the preview version to a profile to avoid passing `--api-version` on every
120
+ call: `cu profile set api_version 2026-06-01-preview`. Pin to `2025-11-01` for
121
+ production workloads that don't need preview capabilities.
122
+
123
+ Further reading:
124
+
125
+ - [What's new in the `2026-06-01-preview` API](https://learn.microsoft.com/azure/ai-services/content-understanding/whats-new#july-2026)
126
+ - Run `cu analyze --help` for all analyze options.
127
+
128
+ ## Use prebuilt analyzers
129
+
130
+ List the prebuilt analyzers available to the configured resource:
131
+
132
+ ```bash
133
+ cu analyzer list
134
+ ```
135
+
136
+ Start with the `prebuilt-layout` content extraction analyzer. It extracts text,
137
+ paragraphs, tables, figures, and document structure without requiring a language
138
+ model or embeddings model. `-a` is the short form of `--analyzer`:
139
+
140
+ ```bash
141
+ # Generate Markdown from the analyzer result with the CU SDK's to_llm_input().
142
+ cu analyze ./document.pdf -a prebuilt-layout
143
+ ```
144
+
145
+ Markdown generated by the Content Understanding SDK's `to_llm_input()` helper is
146
+ the default output format. The helper formats field extraction results as
147
+ Markdown with YAML frontmatter so they can be used as generative AI model input.
148
+ Use `--llm-input` to select this default view explicitly, or use `--json` to
149
+ return the complete analyzer result as JSON. See the
150
+ [Content Understanding SDK `to_llm_input()` helper](https://learn.microsoft.com/azure/ai-services/content-understanding/whats-new#april-2026).
151
+
152
+ Domain-specific prebuilt analyzers, such as `prebuilt-invoice`, extract a
153
+ defined set of structured fields. They require the model setup described in
154
+ [Deploy models and configure defaults](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/provisioning.md#deploy-models-and-configure-defaults):
155
+
156
+ ```bash
157
+ cu analyze ./invoice.pdf --analyzer prebuilt-invoice --json
158
+ ```
159
+
160
+ The command returns an analyzer result. Use `--json` when you want the
161
+ structured result as JSON.
162
+
163
+ Analyze several files into one output directory. `--pattern` requires
164
+ `--source`, because a positional path can be either a file or a directory and
165
+ `--pattern` only makes sense once a directory is named explicitly:
166
+
167
+ ```bash
168
+ cu analyze --source ./documents --pattern "*.pdf" --output-dir ./results
169
+ ```
170
+
171
+ Each result is written under `./results` and keeps the input path relative to
172
+ `./documents`. For example, `./documents/invoice-01.pdf` produces
173
+ `./results/invoice-01.pdf.result.md`. Markdown results use the
174
+ `.result.md` suffix; adding `--json` produces `.result.json` files instead.
175
+
176
+ Further reading:
177
+
178
+ - [Prebuilt analyzers](https://learn.microsoft.com/azure/ai-services/content-understanding/concepts/prebuilt-analyzers)
179
+ - [Supported input files and service limits](https://learn.microsoft.com/azure/ai-services/content-understanding/service-limits#input-file-limits)
180
+ - Run `cu analyze --help` for input, output, overwrite, concurrency, and reporting options.
181
+
182
+ ## Create a custom analyzer
183
+
184
+ A custom analyzer lets you define the structured fields needed by your
185
+ application. Its analyzer schema identifies a base analyzer for the content type
186
+ and includes a field schema that describes the field names, value types, and
187
+ generation methods.
188
+
189
+ Custom analyzers require supported model deployments and configured Content
190
+ Understanding defaults. Confirm the model-to-deployment mappings before creating
191
+ the analyzer:
192
+
193
+ ```bash
194
+ # Show the Content Understanding defaults configured on the resource.
195
+ cu defaults show
196
+ ```
197
+
198
+ If the required mappings are missing, follow
199
+ [Configure defaults manually](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/provisioning.md#configure-defaults-manually)
200
+ to configure them. Then generate a starter analyzer schema from a representative
201
+ file:
202
+
203
+ ```bash
204
+ # Generate a schema from a representative document.
205
+ cu analyzer schema create \
206
+ --from-sample ./invoice.pdf \
207
+ --output-file ./invoice-schema.json
208
+
209
+ # Review and update the generated schema for your extraction requirements,
210
+ # then create the analyzer.
211
+ cu analyzer create --name invoice_v1 --schema ./invoice-schema.json
212
+
213
+ # Run the analyzer against the sample and summarize whether fields were returned
214
+ # and any confidence values supplied by the service. This is not an accuracy
215
+ # benchmark and does not compare the result with labeled ground truth.
216
+ cu analyzer test invoice_v1 ./invoice.pdf
217
+
218
+ cu analyze ./invoice.pdf --analyzer invoice_v1 --json
219
+ ```
220
+
221
+ Schema generation preserves existing files by default. Pass `--force` only when
222
+ you intentionally want to replace the selected `--output-file`.
223
+
224
+ Further reading:
225
+
226
+ - [Create a custom analyzer](https://learn.microsoft.com/azure/ai-services/content-understanding/tutorial/create-custom-analyzer)
227
+ - [Supported generative models](https://learn.microsoft.com/azure/ai-services/content-understanding/service-limits#supported-generative-models)
228
+ - Run `cu analyzer --help` for analyzer management and testing commands.
229
+
230
+ ## Command overview
231
+
232
+ | Command | Purpose |
233
+ | --- | --- |
234
+ | `cu analyze` | Analyze local files and return analyzer results. |
235
+ | `cu analyzer` | List, show, create, copy, delete, and test analyzers; create and validate local analyzer schemas. |
236
+ | `cu defaults` | Read or configure Content Understanding defaults that map models to deployments. |
237
+ | `cu profile` | Manage local CU CLI endpoint, authentication, API, and model settings. |
238
+ | `cu infra generate` | Generate an azd/Bicep project used to provision a Microsoft Foundry resource and configure Content Understanding. Run `azd up` to provision it. |
239
+ | `cu doctor` | Verify the active CU CLI profile, authentication, and model readiness. |
240
+ | `cu env-var` | Inspect supported environment-variable overrides. |
241
+
242
+ Every command provides examples:
243
+
244
+ ```bash
245
+ cu profile --help
246
+ cu analyzer copy --help
247
+ cu infra generate --help
248
+ ```
249
+
250
+ ## CU CLI usage guide
251
+
252
+ Use this README for installation, resource connection, and the first successful
253
+ analysis. For Azure provisioning, see the
254
+ [Microsoft Foundry provisioning guide](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/provisioning.md). For detailed
255
+ operational guidance, see the
256
+ [CU CLI usage guide](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/usage-guide.md). It explains:
257
+
258
+ - CU CLI profile resolution and environment-variable overrides
259
+ - safe batch previews, output handling, and machine-readable reports
260
+ - analyzer schema, lifecycle, testing, and cross-resource copy workflows
261
+ - Content Understanding defaults and troubleshooting
262
+
263
+ ## More information
264
+
265
+ - [Azure Content Understanding documentation](https://aka.ms/cu-doc)
266
+ - [Support](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/SUPPORT.md)
267
+ - [Contributing](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/CONTRIBUTING.md)
268
+
269
+ The standalone distribution is `cu-cli`. It depends on the separately built
270
+ `cu-cli-core` implementation package in this same product tree. `cu-cli-core`
271
+ is an internal implementation boundary for official CU command-line frontends;
272
+ install and use `cu-cli` rather than importing the core package directly.
273
+
274
+ ## Telemetry
275
+
276
+ CU CLI adds `cu-cli/<version>` to the standard Azure SDK `User-Agent` header on
277
+ requests to the Azure Content Understanding service. Microsoft uses this
278
+ identifier to understand CU CLI adoption. CU CLI does not add customer content
279
+ or separate usage and analytics events to this telemetry.
280
+
281
+ To remove the `cu-cli/<version>` identifier, set `CU_TELEMETRY=off` (also
282
+ accepts `0`, `false`, or `no`) before running CU CLI. The Azure SDK continues to
283
+ send its standard `User-Agent` as part of service requests. See the repository
284
+ [data collection notice](https://github.com/Azure/content-understanding-toolkit#data-collection)
285
+ for more information.
286
+
287
+ ## Use multiple profiles
288
+
289
+ If you work with multiple resources, create named profiles and either activate
290
+ one or select it per command:
291
+
292
+ ```bash
293
+ cu profile create dev
294
+ cu profile set endpoint https://<dev-resource>.services.ai.azure.com/ --name dev
295
+ cu profile create prod
296
+ cu profile set endpoint https://<prod-resource>.services.ai.azure.com/ --name prod
297
+
298
+ cu profile set-active dev
299
+ cu analyzer list
300
+ cu analyzer list --profile prod
301
+ cu doctor --profile prod
302
+ ```
303
+
304
+ See the [CU CLI profile usage guide](https://github.com/Azure/content-understanding-toolkit/blob/main/cu-cli/docs/usage-guide.md#cu-cli-profiles) for
305
+ profile resolution and environment-variable overrides.