Skip to content

Commit dae92d3

Browse files
committed
docs: update README with comprehensive CLI usage guide
Replace basic CLI examples with detailed documentation for all command groups (project, key, budget, client). Add authentication instructions, key generation workflow, output format options, and real-world usage examples.
1 parent d9033bb commit dae92d3

File tree

1 file changed

+163
-8
lines changed

1 file changed

+163
-8
lines changed

README.md

Lines changed: 163 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,169 @@ any-llm <provider>
3939

4040
### Command Line Interface
4141

42-
Interactive mode (prompts for provider):
42+
The CLI provides a unified interface for managing your any-llm platform:
43+
44+
```bash
45+
# Get help
46+
any-llm --help
47+
48+
# View available commands
49+
any-llm project --help
50+
any-llm key --help
51+
any-llm budget --help
52+
any-llm client --help
53+
```
54+
55+
#### Authentication
56+
57+
Set credentials for management commands:
58+
59+
```bash
60+
export ANY_LLM_USERNAME="your-email@example.com"
61+
export ANY_LLM_PASSWORD="your-password" # pragma: allowlist secret
62+
export ANY_LLM_PLATFORM_URL="http://localhost:8000/api/v1" # optional
63+
```
64+
65+
#### Managing Projects
66+
4367
```bash
68+
# List all projects
69+
any-llm project list
70+
71+
# Create a new project
72+
any-llm project create "My Project" --description "My project description"
73+
74+
# Show project details
75+
any-llm project show <project-id>
76+
77+
# Update a project
78+
any-llm project update <project-id> --name "Updated Name"
79+
80+
# Delete a project
81+
any-llm project delete <project-id>
82+
```
83+
84+
#### Managing Provider Keys
85+
86+
```bash
87+
# List provider keys for a project
88+
any-llm key list <project-id>
89+
90+
# Create a provider key
91+
any-llm key create <project-id> openai <encrypted-key>
92+
93+
# Update a provider key
94+
any-llm key update <provider-key-id> <encrypted-key>
95+
96+
# Archive a provider key (soft delete)
97+
any-llm key delete <provider-key-id>
98+
99+
# Permanently delete a provider key
100+
any-llm key delete <provider-key-id> --permanent
101+
102+
# Restore an archived key
103+
any-llm key unarchive <provider-key-id>
104+
```
105+
106+
#### Generating New Encryption Keys
107+
108+
Generate a new encryption key and automatically migrate provider keys:
109+
110+
```bash
111+
# Generate new key and migrate from old key
112+
any-llm key generate <project-id> --old-key "ANY.v1.<old-key>"
113+
114+
# Generate new key without migration (archives all provider keys)
115+
any-llm key generate <project-id>
116+
117+
# Skip confirmation prompts (for automation)
118+
any-llm key generate <project-id> --old-key "ANY.v1.<old-key>" --yes
119+
```
120+
121+
This command will:
122+
1. Generate a new X25519 keypair
123+
2. Update the project's encryption key
124+
3. Migrate all provider keys from the old key to the new key (if old key provided)
125+
4. Display the new ANY_LLM_KEY (save it securely!)
126+
127+
**Important:** Save the generated `ANY_LLM_KEY` in a secure location. It cannot be recovered if lost!
128+
129+
**Migration Behavior:**
130+
- **With old key:** Successfully decrypted provider keys are re-encrypted with the new key. Keys that fail to decrypt are archived.
131+
- **Without old key:** All encrypted provider keys are archived. You'll need to re-enter them in the web interface.
132+
- **Local providers** (e.g., Ollama with empty keys) are skipped during migration.
133+
134+
#### Decrypting Provider Keys
135+
136+
Decrypt a provider API key using your ANY_LLM_KEY:
137+
138+
```bash
139+
# Set your ANY_LLM_KEY
44140
export ANY_LLM_KEY='ANY.v1.<kid>.<fingerprint>-<base64_key>'
45-
any-llm
141+
142+
# Decrypt a provider key
143+
any-llm key decrypt openai
144+
any-llm key decrypt anthropic
145+
146+
# Or provide the key inline
147+
any-llm --any-llm-key 'ANY.v1...' key decrypt openai
148+
```
149+
150+
#### Managing Budgets
151+
152+
```bash
153+
# List budgets for a project
154+
any-llm budget list <project-id>
155+
156+
# Create a project budget
157+
any-llm budget create <project-id> 100.00 --period monthly
158+
159+
# Show a specific budget
160+
any-llm budget show <project-id> monthly
161+
162+
# Update a budget
163+
any-llm budget update <project-id> monthly 200.00
164+
165+
# Delete a budget
166+
any-llm budget delete <project-id> monthly
46167
```
47168

48-
Direct mode (specify provider as argument):
169+
Budget periods: `daily`, `weekly`, `monthly`
170+
171+
#### Managing Clients
172+
49173
```bash
50-
any-llm openai
174+
# List clients for a project
175+
any-llm client list <project-id>
176+
177+
# Create a new client
178+
any-llm client create <project-id> "My Client" --default
179+
180+
# Show client details
181+
any-llm client show <project-id> <client-id>
182+
183+
# Update a client
184+
any-llm client update <project-id> <client-id> --name "Updated Client"
185+
186+
# Set as default client
187+
any-llm client set-default <project-id> <client-id>
188+
189+
# Delete a client
190+
any-llm client delete <project-id> <client-id>
191+
```
192+
193+
#### Output Formats
194+
195+
All commands support two output formats:
196+
- `table` (default): Human-readable formatted output
197+
- `json`: Machine-readable JSON output for scripting
198+
199+
```bash
200+
# Get JSON output for scripting
201+
any-llm --format json project list
202+
203+
# Example: Extract project ID
204+
PROJECT_ID=$(any-llm --format json project create "New Project" | jq -r '.id')
51205
```
52206

53207
### Configuring the API Base URL
@@ -64,13 +218,12 @@ client = AnyLLMPlatformClient(any_llm_platform_url="https://api.example.com/v1")
64218
challenge_data = client.create_challenge(public_key)
65219
```
66220

67-
Or set the environment variable before running the CLI. The CLI will use the
68-
first defined of `--api-base-url` or `ANY_LLM_PLATFORM_URL`.
221+
Or set the `ANY_LLM_PLATFORM_URL` environment variable before running the CLI:
69222

70223
```bash
71224
# Example: temporarily point CLI to a staging backend
72225
export ANY_LLM_PLATFORM_URL="https://staging-api.example.com/v1"
73-
any-llm openai
226+
any-llm key decrypt openai
74227
```
75228

76229
### As a Python Library
@@ -166,7 +319,9 @@ asyncio.run(main())
166319
ANY.v1.<kid>.<fingerprint>-<base64_32byte_private_key>
167320
```
168321

169-
Generate your ANY_LLM_KEY from the project page in the web UI.
322+
You can generate a new ANY_LLM_KEY using:
323+
- The CLI: `any-llm key generate <project-id>`
324+
- The project page in the web UI
170325

171326
## Security Notes
172327

0 commit comments

Comments
 (0)