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
## Description
Updates to intro and Quickstart
## PR Type
<!-- Delete the types that don't apply --!>
📚 Documentation
## Checklist
- [X] I have added unit tests that prove my fix/feature works
- [X] New and existing tests pass locally
- [X] Documentation was updated where necessary
- [X] I have read and followed the [contribution
guidelines](https://github.com/mozilla-ai/any-llm/blob/main/CONTRIBUTING.md)```
Copy file name to clipboardExpand all lines: docs/quickstart.md
+23-47Lines changed: 23 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,59 +3,41 @@
3
3
### Requirements
4
4
5
5
- Python 3.11 or newer
6
-
-API_KEYS to access to whichever LLM you choose to use.
6
+
-API keys for your chosen LLM provider
7
7
8
8
### Installation
9
+
```bash
10
+
pip install any-llm-sdk[all] # Install with all provider support
11
+
```
9
12
10
-
#### Direct Usage
13
+
#### Installing Specific Providers
11
14
12
-
In your pip install, include the [supported providers](./providers.md) that you plan on using, or use the `all` option if you want to install support for all `any-llm` supported providers.
15
+
If you want to install a specific provider from our [supported providers](./providers.md):
13
16
14
17
```bash
15
18
pip install any-llm-sdk[mistral] # For Mistral provider
16
19
pip install any-llm-sdk[ollama] # For Ollama provider
17
20
# install multiple providers
18
21
pip install any-llm-sdk[mistral,ollama]
19
-
# or install support for all providers
20
-
pip install any-llm-sdk[all]
21
22
```
22
23
23
24
#### Library Integration
24
25
25
-
If you're integrating `any-llm` into your own library that others will use, you only need to install the base package:
26
-
27
-
```bash
28
-
pip install any-llm-sdk
29
-
```
30
-
31
-
In this scenario, the end users of your library will be responsible for installing the appropriate provider dependencies when they want to use specific providers. `any-llm` is designed so that you'll only encounter exceptions at runtime if you try to use a provider without having the required dependencies installed.
32
-
33
-
Those exceptions will clearly describe what needs to be installed to resolve the issue.
34
-
35
-
Make sure you have the appropriate API key environment variable set for your provider. Alternatively,
36
-
you could use the `api_key` parameter when making a completion call instead of setting an environment variable.
37
-
38
-
```bash
39
-
export MISTRAL_API_KEY="YOUR_KEY_HERE"# or OPENAI_API_KEY, etc
40
-
```
41
-
42
-
### Basic Usage
43
-
44
-
`any-llm` provides two main approaches for working with LLM providers, each optimized for different use cases:
45
-
46
-
#### Option 1: Direct API Functions
26
+
If you're building a library, install just the base package (`pip install any-llm-sdk`) and let your users install provider dependencies.
47
27
48
-
[`completion`][any_llm.completion] and [`acompletion`][any_llm.acompletion] provide a unified interface across all providers - perfect for simple use cases and quick prototyping.
28
+
> **API Keys:** Set your provider's API key as an environment variable (e.g., `export MISTRAL_API_KEY="your-key"`) or pass it directly using the `api_key` parameter.
49
29
50
-
**Recommended approach:** Use separate `provider` and `model` parameters:
30
+
### Your First API Call
51
31
52
32
```python
53
33
import os
54
34
55
35
from any_llm import completion
56
36
57
-
# Make sure you have the appropriate environment variable set
58
-
assert os.environ.get('MISTRAL_API_KEY')
37
+
# Make sure you have the appropriate API key set
38
+
api_key = os.environ.get('MISTRAL_API_KEY')
39
+
ifnot api_key:
40
+
raiseValueError("Please set MISTRAL_API_KEY environment variable")
59
41
60
42
# Recommended: separate provider and model parameters
61
43
response = completion(
@@ -66,26 +48,19 @@ response = completion(
66
48
print(response.choices[0].message.content)
67
49
```
68
50
69
-
**Alternative syntax:** You can also use the combined `provider:model` format:
- Building applications that make multiple requests with the same provider
114
89
- You want to avoid repeated provider instantiation overhead
115
90
116
-
The provider_id should be specified according to the [provider ids supported by any-llm](./providers.md).
117
-
The `model_id` portion is passed directly to the provider internals: to understand what model ids are available for a provider,
118
-
you will need to refer to the provider documentation or use our [`list_models`](./api/list_models.md) API if the provider supports that API.
91
+
**Finding model names:** Check the [providers page](./providers.md) for provider IDs, or use the [`list_models`](./api/list_models.md) API to see available models for your provider.
0 commit comments