Packages
req_llm
1.26.0
1.28.0
1.27.0
1.26.0
1.25.0
1.24.0
1.23.0
1.22.0
1.21.1
1.21.0
1.20.0
1.19.0
1.18.0
1.17.1
1.17.0
1.16.0
1.15.0
1.14.0
1.13.0
1.12.0
1.11.0
1.10.0
1.9.0
1.8.0
1.7.1
1.7.0
1.6.0
1.5.1
1.5.0
1.4.1
1.4.0
1.3.0
1.2.0
1.1.0
1.0.0
1.0.0-rc.8
1.0.0-rc.7
1.0.0-rc.6
1.0.0-rc.5
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
Composable Elixir library for LLM interactions built on Req & Finch
Current section
Files
Jump to
Current section
Files
guides/github_copilot.md
# GitHub Copilot
GitHub Copilot exposes an OpenAI-compatible Chat Completions API at `https://api.githubcopilot.com`. ReqLLM supports it through the `:github_copilot` provider.
## Configuration
Use a GitHub token that has access to Copilot:
```bash
export COPILOT_GITHUB_TOKEN=gho_...
```
If no token is configured, ReqLLM falls back to:
1. `COPILOT_GITHUB_TOKEN`
2. `GH_TOKEN`
3. `GITHUB_TOKEN`
4. `gh auth token`
You can also pass a token per request:
```elixir
ReqLLM.generate_text("github_copilot:gpt-4o-mini", "Hello!", api_key: token)
```
## Streaming
```elixir
{:ok, response} =
ReqLLM.stream_text(
"github_copilot:gpt-4o-mini",
"Reply with one sentence.",
max_tokens: 120
)
response
|> ReqLLM.StreamResponse.tokens()
|> Enum.each(&IO.write/1)
```
## Provider Options
Provider options can be passed either top-level or nested under `:provider_options`.
```elixir
ReqLLM.stream_text(
"github_copilot:gpt-4o-mini",
"Hello!",
provider_options: [
github_copilot_integration_id: "vscode-chat",
github_copilot_auth: :auto
]
)
```
### `github_copilot_integration_id`
- **Type**: String
- **Default**: `"vscode-chat"`
- **Purpose**: Sets the required `Copilot-Integration-Id` request header.
### `github_copilot_auth`
- **Type**: `:auto` | `:token` | `:gh`
- **Default**: `:auto`
- **Purpose**: Controls credential lookup.
`auto` checks configured token sources first and then falls back to `gh auth token`. `token` only uses configured token sources. `gh` only uses the GitHub CLI.
## Model Specs
Copilot model availability is account-dependent. ReqLLM accepts unverified Copilot model IDs:
```elixir
ReqLLM.model!("github_copilot:gpt-4o-mini")
ReqLLM.model!("github_copilot:claude-sonnet-4.5")
```
If you need to use a different Copilot-compatible host, set `base_url`:
```elixir
model =
ReqLLM.model!(%{
provider: :github_copilot,
id: "gpt-4o-mini",
base_url: "https://api.individual.githubcopilot.com"
})
ReqLLM.stream_text(model, "Hello!")
```
## Token Exchange 404s
Some community examples call `https://api.github.com/copilot_internal/v2/token` before calling Copilot. That endpoint is internal and can return `404 Not Found` for valid GitHub CLI OAuth tokens or account types.
ReqLLM does not depend on that exchange. It sends the resolved token directly to `https://api.githubcopilot.com` as a bearer token, matching the path used by the successful streaming request.