-
Notifications
You must be signed in to change notification settings - Fork 3.7k
docs: Add Hugging Face Inference Providers documentation #4611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
davanstrien
wants to merge
3
commits into
Aider-AI:main
Choose a base branch
from
davanstrien:add-huggingface-inference-providers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+82
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| --- | ||
| parent: Connecting to LLMs | ||
| nav_order: 450 | ||
| --- | ||
|
|
||
| # Hugging Face Inference Providers | ||
|
|
||
| Aider can connect to [Hugging Face Inference Providers](https://huggingface.co/docs/inference-providers/) using the OpenAI-compatible client. Inference Providers gives you access to multiple AI providers through a single OpenAI-compatible API. | ||
|
|
||
| You'll need a [Hugging Face account](https://huggingface.co/join) and an [access token](https://huggingface.co/settings/tokens). | ||
|
|
||
| First, install aider: | ||
|
|
||
| {% include install.md %} | ||
|
|
||
| Then configure your API key and base URL: | ||
|
|
||
| ``` | ||
| # Mac/Linux: | ||
| export OPENAI_API_BASE=https://router.huggingface.co/v1 | ||
| export HUGGINGFACE_API_KEY=<your-hf-token> | ||
|
|
||
| # Windows: | ||
| setx OPENAI_API_BASE https://router.huggingface.co/v1 | ||
| setx HUGGINGFACE_API_KEY <your-hf-token> | ||
| # ... restart shell after setx commands | ||
| ``` | ||
|
|
||
| **Note:** `OPENAI_API_BASE` is required because Hugging Face Inference Providers uses an OpenAI-compatible endpoint. You can also use `HF_TOKEN` instead of `HUGGINGFACE_API_KEY`. | ||
|
|
||
| Start working with aider on your codebase: | ||
|
|
||
| ```bash | ||
| # Change directory into your codebase | ||
| cd /to/your/project | ||
|
|
||
| # Use any model from Inference Providers | ||
| # Prefix the model name with huggingface/ | ||
| aider --model huggingface/<model-name> | ||
|
|
||
| # Using MiniMaxAI/MiniMax-M2: | ||
| aider --model huggingface/MiniMaxAI/MiniMax-M2 | ||
| ``` | ||
|
|
||
| ## Selecting a specific provider | ||
|
|
||
| By default, Inference Providers automatically routes requests to the best available provider. If you want to use a specific provider you can append the provider name to the model: | ||
|
|
||
| ```bash | ||
| aider --model huggingface/<model-name>:<provider> | ||
|
|
||
| # Using GLM-4.6 via zai-org provider: | ||
| aider --model huggingface/zai-org/GLM-4.6:zai-org | ||
| ``` | ||
|
|
||
| You can also use `:cheapest` or `:fastest` to automatically select based on cost or throughput: | ||
|
|
||
| ```bash | ||
| # Use the cheapest available provider: | ||
| aider --model huggingface/MiniMaxAI/MiniMax-M2:cheapest | ||
|
|
||
| # Use the fastest available provider: | ||
| aider --model huggingface/MiniMaxAI/MiniMax-M2:fastest | ||
| ``` | ||
|
|
||
| You can find the provider-specific syntax on any model card's "Use this model" → "Inference Providers" section. | ||
|
|
||
| ## Finding models | ||
|
|
||
| You can discover models available via Inference Providers in several ways: | ||
|
|
||
| 1. **Browse models on Hugging Face**: Visit [models with Inference Providers](https://huggingface.co/models?pipeline_tag=text-generation&inference_provider=all&sort=trending) to see all models with at least one Inference Provider hosting them. | ||
|
|
||
| 2. **From model cards**: On any model card page (like [zai-org/GLM-4.6](https://huggingface.co/zai-org/GLM-4.6)), click "Use this model" → "Inference Providers" to see the code snippet with the exact model name. | ||
|
|
||
| 3. **See the docs**: Check the [Inference Providers Hub API docs](https://huggingface.co/docs/inference-providers/hub-api) for programmatic model discovery | ||
|
|
||
| ## More information | ||
|
|
||
| - [Inference Providers documentation](https://huggingface.co/docs/inference-providers/) | ||
| - [Pricing details](https://huggingface.co/docs/inference-providers/pricing) | ||
| - [Supported providers](https://huggingface.co/docs/inference-providers/index#partners) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.