diff --git a/content/github-models/integrating-ai-models-into-your-development-workflow.md b/content/github-models/integrating-ai-models-into-your-development-workflow.md index d1ac910660..af238b2817 100644 --- a/content/github-models/integrating-ai-models-into-your-development-workflow.md +++ b/content/github-models/integrating-ai-models-into-your-development-workflow.md @@ -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. diff --git a/data/reusables/actions/github-token-available-permissions.md b/data/reusables/actions/github-token-available-permissions.md index 8e6c4860a6..94cea05a10 100644 --- a/data/reusables/actions/github-token-available-permissions.md +++ b/data/reusables/actions/github-token-available-permissions.md @@ -8,7 +8,8 @@ permissions: contents: read|write|none deployments: read|write|none{% ifversion fpt or ghec %} id-token: write|none{% endif %} - issues: read|write|none + issues: read|write|none{% ifversion not ghes %} + models: read|none{% endif %} discussions: read|write|none packages: read|write|none pages: read|write|none diff --git a/data/reusables/actions/github-token-scope-descriptions.md b/data/reusables/actions/github-token-scope-descriptions.md index 0360ced985..552b1a9f24 100644 --- a/data/reusables/actions/github-token-scope-descriptions.md +++ b/data/reusables/actions/github-token-scope-descriptions.md @@ -16,6 +16,9 @@ Available permissions and details of what each allows an action to do: | `id-token` | Fetch an OpenID Connect (OIDC) token. This requires `id-token: write`. For more information, see [AUTOTITLE](/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#updating-your-actions-for-oidc) | | {% endif %} | | `issues` | Work with issues. For example, `issues: write` permits an action to add a comment to an issue. For more information, see [AUTOTITLE](/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-issues). | +| {% ifversion not ghes %} | +| `models` | Generate AI inference responses with {% data variables.product.prodname_github_models %}. For example, `models: read` permits an action to use the {% data variables.product.prodname_github_models %} inference API. See [AUTOTITLE](/github-models/prototyping-with-ai-models). | +| {% endif %} | | `packages` | Work with GitHub Packages. For example, `packages: write` permits an action to upload and publish packages on GitHub Packages. For more information, see [AUTOTITLE](/packages/learn-github-packages/about-permissions-for-github-packages#about-scopes-and-permissions-for-package-registries). | | `pages` | Work with GitHub Pages. For example, `pages: write` permits an action to request a GitHub Pages build. For more information, see [AUTOTITLE](/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-pages). | | `pull-requests` | Work with pull requests. For example, `pull-requests: write` permits an action to add a label to a pull request. For more information, see [AUTOTITLE](/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-pull-requests). |