1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Add GitHub Models in Actions docs (#55174)

Co-authored-by: Sophie <29382425+sophietheking@users.noreply.github.com>
This commit is contained in:
Sean Goedecke
2025-04-11 16:12:40 +10:00
committed by GitHub
parent fe94f48fd5
commit 2e0d2f30d4
3 changed files with 46 additions and 1 deletions

View File

@@ -30,6 +30,47 @@ If you have a {% data variables.product.prodname_copilot_short %} subscription,
* Executing prompts using a particular model. This is especially useful when you want to use a model that is not currently available in multi-model {% data variables.product.prodname_copilot_chat_short %}.
* Listing models currently available through {% data variables.product.prodname_github_models %}
## Using AI models with {% data variables.product.prodname_actions %}
You can use the {% data variables.product.prodname_actions %} token (`GITHUB_TOKEN`) to call AI models directly inside your workflows.
### Setting permissions
To use AI models in your workflows, you need to ensure that the `models` permission is enabled in your workflow configuration. This permission allows workflows to access the {% data variables.product.prodname_github_models %} inference API. You can either set this permission itself or use the general `read-all` or `write-all` permissions. See [AUTOTITLE](/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-actions).
### Writing your workflow file
You can call the inference API directly from your workflow. For instance:
```yaml
name: Use GitHub Models
on:
workflow_dispatch:
permissions:
models: read
jobs:
call-model:
runs-on: ubuntu-latest
steps:
- name: Call AI model
run: |
curl -X POST "https://models.inference.ai.azure.com/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-d '{
"messages": [
{
"role": "user",
"content": "Explain the concept of recursion."
}
],
"model": "gpt-4o"
}'
```
## Using AI models from the command line
> [!NOTE] The {% data variables.product.prodname_github_models %} extension for {% data variables.product.prodname_cli %} is in {% data variables.release-phases.public_preview %} and is subject to change.