Setup and run AI inference via Copilot CLI
mainThe actions/ai-inference action allows you to run AI inference in GitHub workflows using the GitHub Copilot CLI.
Important Requirements:
- The action is Copilot-only. The
providerinput defaults tocopilot, and it is currently the only supported value. - The Copilot CLI is not pre-installed on GitHub-hosted runners. You must install and authenticate it before using the action.
- Authentication is typically handled by providing a
COPILOT_GITHUB_TOKENenvironment variable (e.g., using a Personal Access Token stored in GitHub Secrets).
To use the action, install the CLI globally via npm and then invoke the action in your workflow steps.
name: AI inference
on: workflow_dispatch
jobs:
inference:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
- name: Install Copilot CLI
run: npm install -g @github/copilot
- name: Run AI Inference via Copilot
id: inference
uses: actions/ai-inference@v1
with:
prompt: Summarize the latest changes in this repository.
model: gpt-4.1
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_PAT }}
- name: Print output
run: echo "${{ steps.inference.outputs.response }}"