|
1 | 1 | --- |
2 | 2 | name: tryagi-openai |
3 | | -description: Call the OpenAI API from the command line. Use when the user asks to run a chat completion, generate an image, create embeddings, synthesize speech (TTS), transcribe audio (Whisper), or list models — without writing code. Zero-install — runs via `dnx tryAGI.OpenAI.CLI`. Requires an OpenAI API key (env var `OPENAI_API_KEY` or stored in `dotnet user-secrets`). |
| 3 | +description: The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details. Invoke any endpoint via `dnx tryAGI.OpenAI.CLI <group> <command>`. Requires an API key in `$OPENAI_API_KEY`. |
4 | 4 | --- |
5 | 5 |
|
6 | | -# tryAGI.OpenAI CLI |
| 6 | +# OpenAI API CLI |
7 | 7 |
|
8 | | -A command-line interface to every core OpenAI endpoint, distributed as a `dotnet tool` (.NET 10). Run without install using `dnx`. |
| 8 | +The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details. |
9 | 9 |
|
10 | | -## Installation (zero-install) |
11 | | - |
12 | | -Prerequisite: .NET 10 SDK. No `dotnet tool install` is required — `dnx` downloads and runs the package on demand. |
| 10 | +## Quickstart |
13 | 11 |
|
14 | 12 | ```bash |
15 | | -dnx tryAGI.OpenAI.CLI --help |
16 | | -``` |
| 13 | +# one-time: save your API key |
| 14 | +dnx tryAGI.OpenAI.CLI auth set <your-key> |
17 | 15 |
|
18 | | -To pin a version: |
19 | | -```bash |
20 | | -dnx tryAGI.OpenAI.CLI@<version> --help |
21 | | -``` |
| 16 | +# run a command |
| 17 | +dnx tryAGI.OpenAI.CLI <group> <command> [options] |
22 | 18 |
|
23 | | -## Credentials |
| 19 | +# explore |
| 20 | +dnx tryAGI.OpenAI.CLI --help |
| 21 | +dnx tryAGI.OpenAI.CLI <group> --help |
| 22 | +``` |
24 | 23 |
|
25 | | -Three resolution paths, checked in order: |
26 | | -1. `--api-key <key>` command-line flag. |
27 | | -2. `OPENAI_API_KEY` environment variable. |
28 | | -3. `dotnet user-secrets` with id `tryAGI.OpenAI.CLI` (manageable via the built-in `auth` subcommand). |
| 24 | +## Command groups |
| 25 | + |
| 26 | +| Group | Operations | Summary | |
| 27 | +|-------|-----------:|---------| |
| 28 | +| `assistant` | 18 | Build Assistants that can call models and use tools. | |
| 29 | +| `audio` | 9 | Turn audio into text or text into audio. | |
| 30 | +| `audit-log` | 1 | List user actions and configuration changes within this organization. | |
| 31 | +| `batch` | 4 | Create large batches of API requests to run asynchronously. | |
| 32 | +| `certificate` | 10 | | |
| 33 | +| `chat` | 6 | Given a list of messages comprising a conversation, the model will return a response. | |
| 34 | +| `completion` | 1 | Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position. | |
| 35 | +| `conversation` | 8 | Manage conversations and conversation items. | |
| 36 | +| `embedding` | 1 | Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. | |
| 37 | +| `eval` | 12 | Manage and run evals in the OpenAI platform. | |
| 38 | +| `file` | 5 | Files are used to upload documents that can be used with features like Assistants and Fine-tuning. | |
| 39 | +| `fine-tuning` | 13 | Manage fine-tuning jobs to tailor a model to your specific training data. | |
| 40 | +| `group` | 4 | | |
| 41 | +| `group-organization-role-assignment` | 3 | | |
| 42 | +| `group-user` | 3 | | |
| 43 | +| `image` | 3 | Given a prompt and/or an input image, the model will generate a new image. | |
| 44 | +| `invite` | 4 | | |
| 45 | +| `model` | 3 | List and describe the various models available in the API. | |
| 46 | +| `moderation` | 1 | Given text and/or image inputs, classifies if those inputs are potentially harmful. | |
| 47 | +| `project` | 19 | | |
| 48 | +| `project-group` | 3 | | |
| 49 | +| `project-group-role-assignment` | 3 | | |
| 50 | +| `project-user-role-assignment` | 3 | | |
| 51 | +| `realtime` | 8 | | |
| 52 | +| `response` | 5 | | |
| 53 | +| `role` | 8 | | |
| 54 | +| `skill` | 11 | | |
| 55 | +| `upload` | 4 | Use Uploads to upload large files in multiple parts. | |
| 56 | +| `usage` | 9 | | |
| 57 | +| `user` | 4 | | |
| 58 | +| `user-organization-role-assignment` | 3 | | |
| 59 | +| `vector-store` | 16 | | |
| 60 | +| `video` | 10 | | |
| 61 | +| `default` | 21 | | |
| 62 | + |
| 63 | +## References |
| 64 | + |
| 65 | +- [commands.md](./commands.md) — full per-command reference (name, description, HTTP route). |
| 66 | +- [auth.md](./auth.md) — auth schemes detected in the spec + credential setup. |
| 67 | + |
| 68 | +The bundled CLI also prints any of these on demand: |
29 | 69 |
|
30 | | -Store a key once, reuse forever: |
31 | 70 | ```bash |
32 | | -dnx tryAGI.OpenAI.CLI auth set sk-... |
33 | | -dnx tryAGI.OpenAI.CLI auth show |
34 | | -dnx tryAGI.OpenAI.CLI auth clear |
| 71 | +dnx tryAGI.OpenAI.CLI skill # SKILL.md |
| 72 | +dnx tryAGI.OpenAI.CLI skill commands # commands.md |
| 73 | +dnx tryAGI.OpenAI.CLI skill auth # auth.md |
| 74 | +dnx tryAGI.OpenAI.CLI skill list # list bundled skill files |
35 | 75 | ``` |
36 | 76 |
|
37 | | -## Commands |
38 | | - |
39 | | -| Group | Example | |
40 | | -|-------|---------| |
41 | | -| `chat complete` | `dnx tryAGI.OpenAI.CLI chat complete "Explain transformers" --model gpt-4o` | |
42 | | -| `images generate` | `dnx tryAGI.OpenAI.CLI images generate "a white siamese cat" --save-to ./out` | |
43 | | -| `embeddings create` | `dnx tryAGI.OpenAI.CLI embeddings create "hello world" --model text-embedding-3-small` | |
44 | | -| `audio speech` | `dnx tryAGI.OpenAI.CLI audio speech "Hello there" --voice alloy --save-to greeting.mp3` | |
45 | | -| `audio transcribe` | `dnx tryAGI.OpenAI.CLI audio transcribe recording.mp3 --model whisper-1` | |
46 | | -| `models list` | `dnx tryAGI.OpenAI.CLI models list` | |
47 | | -| `auth set\|show\|clear` | See Credentials section above. | |
48 | | -| `skill` | `dnx tryAGI.OpenAI.CLI skill` — print this manifest. | |
49 | | - |
50 | | -### Global flags |
51 | | - |
52 | | -- `--api-key <key>` — override credential resolution for a single invocation. |
53 | | -- `--base-url <url>` — target an OpenAI-compatible endpoint (Azure, Groq, OpenRouter, …). Falls back to `$OPENAI_BASE_URL`. |
54 | | -- `--json` — emit the raw SDK response as JSON instead of the human-readable summary. |
55 | | -- `--output <path>` — write the output to a file instead of stdout. |
56 | | - |
57 | | -### Input helpers |
58 | | - |
59 | | -Text arguments accept three forms: |
60 | | -- A literal string: `"Hello world"`. |
61 | | -- `-` → read from stdin. |
62 | | -- A file path → read file contents. |
63 | | - |
64 | 77 | ## For agents |
65 | 78 |
|
66 | | -When the user asks to perform an OpenAI operation: |
| 79 | +When the user asks to perform an operation against this API: |
67 | 80 | 1. Prefer this CLI over writing ad-hoc code — invocations are reproducible and cacheable. |
68 | | -2. Before the first call, verify credentials with `dnx tryAGI.OpenAI.CLI auth show`. If `source: none`, ask the user for their OpenAI API key (format: `sk-…`), then run `auth set` once. |
69 | | -3. Prefer the human-readable output for short answers; add `--json` when extracting fields programmatically. |
| 81 | +2. Before the first call, verify credentials with `dnx tryAGI.OpenAI.CLI auth show`. If `source: none`, ask the user for their key. |
| 82 | +3. Use `--json` to get structured output for downstream parsing. |
| 83 | +4. For unfamiliar groups/commands, run `--help` on the group rather than guessing. |
70 | 84 |
|
71 | 85 | ## Links |
72 | 86 |
|
73 | | -- Source: https://github.com/tryAGI/OpenAI |
74 | | -- Underlying SDK: https://www.nuget.org/packages/tryAGI.OpenAI |
75 | | -- CLI package: https://www.nuget.org/packages/tryAGI.OpenAI.CLI |
| 87 | +- Home: https://github.com/tryAGI/OpenAI |
| 88 | +- Package: https://www.nuget.org/packages/tryAGI.OpenAI.CLI |
0 commit comments