Skip to content

Instantly share code, notes, and snippets.

@gabrielmoreira
Created September 4, 2026 21:58
Show Gist options
  • Select an option

  • Save gabrielmoreira/29c13a4ae49cbfbeef31e3602e043c09 to your computer and use it in GitHub Desktop.

Select an option

Save gabrielmoreira/29c13a4ae49cbfbeef31e3602e043c09 to your computer and use it in GitHub Desktop.
Run Claude Code through OMP and GitHub Copilot

Run Claude Code through OMP and GitHub Copilot

This setup routes a local Claude Code session through OMP's Anthropic-compatible gateway, then uses the GitHub Copilot credential already stored by OMP.

Claude Code
    |
    | POST /v1/messages
    v
OMP auth-gateway :4000 -----------------> GitHub Copilot -> selected model
    |
    | credential lookup and refresh
    v
OMP auth-broker :8765

The broker does not carry inference traffic. It stores, resolves, and refreshes credentials. The gateway receives Claude Code requests, obtains the appropriate credential from the broker, and calls the selected provider.

Scope and limitations

  • This applies to the local Claude Code CLI. It does not route claude.ai, the web app, or mobile apps.
  • Sonnet through GitHub Copilot is the lower-risk first test because the client and final model both use Anthropic semantics.
  • GPT through GitHub Copilot is experimental. OMP translates the Anthropic Messages request into the provider protocol and translates the response back. Anthropic does not guarantee Claude Code compatibility with non-Claude models.
  • GitHub Copilot entitlement, quota, and organization policies still apply.
  • Keep both services on 127.0.0.1. Do not expose them publicly.

Requirements

  1. OMP already works with your GitHub Copilot account.
  2. omp auth-broker --help and omp auth-gateway --help both work.
  3. Claude Code 2.1.257 or newer is installed. Check with:
claude --version

Update Claude Code if needed:

claude update

Run the broker and gateway as the same operating-system user and with the same OMP configuration directory used by your normal OMP installation. That is how the broker finds the existing GitHub Copilot credential.

No OMP config file change is required for this trial. The commands below use a terminal-scoped environment variable instead.

1. Start the credential broker

Open terminal 1.

macOS with zsh

omp auth-broker serve --bind=127.0.0.1:8765

Windows with PowerShell

omp auth-broker serve --bind=127.0.0.1:8765

Leave this terminal running.

The broker uses the GitHub Copilot OAuth credential already stored by OMP. You do not need to copy that credential into Claude Code.

If OMP is not yet logged into GitHub Copilot, stop here and run:

omp auth-broker login github-copilot

The command is the same in PowerShell.

2. Start the Anthropic-compatible gateway

Open terminal 2.

macOS with zsh

export OMP_AUTH_BROKER_URL="http://127.0.0.1:8765"
omp auth-gateway serve --bind=127.0.0.1:4000

Windows with PowerShell

$env:OMP_AUTH_BROKER_URL = "http://127.0.0.1:8765"
omp auth-gateway serve --bind=127.0.0.1:4000

Leave this terminal running. The gateway should print a listening URL and the path of its bearer-token file.

Do not use --no-auth. When both services run under the same user and OMP configuration directory, the gateway resolves the broker token automatically. You do not need to set OMP_AUTH_BROKER_TOKEN.

3. Find GitHub Copilot model IDs

Open terminal 3.

macOS with zsh

GATEWAY_URL="http://127.0.0.1:4000"
GATEWAY_TOKEN="$(omp auth-gateway token)"

curl -fsS "$GATEWAY_URL/v1/models" \
  -H "Authorization: Bearer $GATEWAY_TOKEN" \
  | jq -r '
      .data[]
      | select(.owned_by == "github-copilot")
      | select(.id | test("claude-sonnet|gpt-5"))
      | [.id, .display_name, .api]
      | @tsv
    '

jq is only used to format the response. On macOS, install it with brew install jq, or remove the pipe to see the raw JSON.

Windows with PowerShell

$gatewayUrl = "http://127.0.0.1:4000"
$gatewayToken = (omp auth-gateway token).Trim()
$headers = @{
    Authorization       = "Bearer $gatewayToken"
    "anthropic-version" = "2023-06-01"
}

$models = (
    Invoke-RestMethod `
        -Uri "$gatewayUrl/v1/models" `
        -Headers $headers
).data

$models |
    Where-Object {
        $_.owned_by -eq "github-copilot" -and
        $_.id -match "claude-sonnet|gpt-5"
    } |
    Sort-Object id |
    Format-Table id, display_name, api

Use the complete provider-qualified ID, such as:

github-copilot/claude-sonnet-4.6
github-copilot/gpt-5.6-sol

These are examples, not fixed recommendations. Use IDs returned by your running gateway.

A model appearing in /v1/models means OMP knows how to route it. It does not prove that your GitHub Copilot account is entitled to use it. The next step checks that.

4. Test a model before configuring Claude Code

Test Sonnet first. If it works, repeat the request with a GPT model ID.

macOS with zsh

Set the exact model ID returned by /v1/models:

MODEL="github-copilot/claude-sonnet-4.6"

REQUEST_BODY="$(jq -nc --arg model "$MODEL" '{
  model: $model,
  max_tokens: 32,
  messages: [
    {role: "user", content: "Reply with exactly: OK"}
  ]
}')"

curl -sS \
  -w '\nHTTP %{http_code}\n' \
  "$GATEWAY_URL/v1/messages" \
  -H "Authorization: Bearer $GATEWAY_TOKEN" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  --data "$REQUEST_BODY"

Change MODEL, rebuild REQUEST_BODY, and rerun the curl command to test GPT:

MODEL="github-copilot/gpt-5.6-sol"

Windows with PowerShell

$model = "github-copilot/claude-sonnet-4.6"

$body = @{
    model      = $model
    max_tokens = 32
    messages   = @(
        @{
            role    = "user"
            content = "Reply with exactly: OK"
        }
    )
} | ConvertTo-Json -Depth 6

try {
    $response = Invoke-RestMethod `
        -Method Post `
        -Uri "$gatewayUrl/v1/messages" `
        -Headers $headers `
        -ContentType "application/json" `
        -Body $body

    $response.content |
        Where-Object { $_.type -eq "text" } |
        ForEach-Object { $_.text }
}
catch {
    $_.ErrorDetails.Message
}

Change $model, rebuild $body, and rerun the request to test GPT:

$model = "github-copilot/gpt-5.6-sol"

Keep only model IDs that return a real response. model_not_supported usually means the model is present in OMP's catalog but unavailable to your account or organization.

5. Create a dedicated Claude Code profile

Use one Sonnet ID that passed the request above. Add a GPT ID only if its request also passed.

macOS path

~/.claude/profiles/omp-github-copilot.json

Create it with:

mkdir -p "$HOME/.claude/profiles"
${EDITOR:-nano} "$HOME/.claude/profiles/omp-github-copilot.json"

Windows path

$HOME\.claude\profiles\omp-github-copilot.json

Create it with:

New-Item -ItemType Directory -Force "$HOME\.claude\profiles" | Out-Null
notepad "$HOME\.claude\profiles\omp-github-copilot.json"

Paste this strict JSON. Replace every <SONNET_MODEL_ID> and <GPT_MODEL_ID> with IDs that passed the direct gateway test.

{
  "apiKeyHelper": "omp auth-gateway token",
  "model": "<SONNET_MODEL_ID>",
  "availableModels": [
    "<SONNET_MODEL_ID>",
    "<GPT_MODEL_ID>"
  ],
  "enforceAvailableModels": true,
  "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:4000",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "<SONNET_MODEL_ID>",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "<SONNET_MODEL_ID>",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "<SONNET_MODEL_ID>",
    "ANTHROPIC_DEFAULT_FABLE_MODEL": "<SONNET_MODEL_ID>",
    "CLAUDE_CODE_SUBAGENT_MODEL": "<SONNET_MODEL_ID>",
    "CLAUDE_CODE_SUBAGENT_MODEL_FORCE": "1"
  },
  "modelPicker": {
    "options": [
      {
        "model": "<SONNET_MODEL_ID>",
        "label": "Sonnet via GitHub Copilot",
        "description": "Primary Claude Code route through OMP"
      },
      {
        "model": "<GPT_MODEL_ID>",
        "label": "GPT via GitHub Copilot",
        "description": "Experimental non-Claude route through OMP"
      }
    ],
    "replaceBuiltInOptions": true
  }
}

If no GPT model passed the direct test, remove <GPT_MODEL_ID> from availableModels and remove its object from modelPicker.options.

This profile deliberately maps Claude Code's internal Opus, Sonnet, Haiku, Fable, and subagent choices to the tested Sonnet route. That prevents background work from selecting an unavailable model. The main session can still switch to the tested GPT entry from /model.

CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY is intentionally omitted. The profile exposes only the models you tested instead of importing the full gateway catalog.

6. Launch Claude Code through OMP

Shell-level ANTHROPIC_* variables can override values from a settings file. Start the gateway profile without inherited Anthropic endpoint or credential variables.

macOS with zsh

env \
  -u ANTHROPIC_BASE_URL \
  -u ANTHROPIC_AUTH_TOKEN \
  -u ANTHROPIC_API_KEY \
  claude --settings "$HOME/.claude/profiles/omp-github-copilot.json"

Windows with PowerShell

Use a dedicated PowerShell terminal:

Remove-Item Env:ANTHROPIC_BASE_URL -ErrorAction SilentlyContinue
Remove-Item Env:ANTHROPIC_AUTH_TOKEN -ErrorAction SilentlyContinue
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue

claude --settings "$HOME\.claude\profiles\omp-github-copilot.json"

Inside Claude Code:

  1. Run /status and confirm that the extra settings file is listed.
  2. Run /model. The custom Sonnet and GPT labels should be the available choices.
  3. Test Sonnet first with a simple prompt and a read-only tool call.
  4. Switch to GPT and repeat the test.
  5. Use the session-only model-selection action. Do not save the gateway model as the global Claude default.

The profile uses apiKeyHelper to run omp auth-gateway token. Claude Code receives only the local gateway token. It does not receive the GitHub Copilot OAuth credential or the broker token.

7. Return to direct Claude usage

Exit Claude Code, then launch it normally without the profile:

claude

The command is the same in PowerShell.

--settings and the profile's environment variables apply only to the gateway launch. A normal launch continues to use your existing Claude configuration and login.

Stop the services with Ctrl+C when finished. Stop auth-gateway first, then auth-broker.

Troubleshooting

omp auth-gateway serve says the broker is not configured

Set OMP_AUTH_BROKER_URL in the same terminal that starts the gateway. An export in terminal 1 does not affect terminal 2.

The gateway returns HTTP 401

Confirm that omp auth-gateway token prints one token with no surrounding log output. If Claude Code reports that the helper cannot find omp, use command -v omp on macOS or Get-Command omp in PowerShell, then put the resulting absolute executable path in apiKeyHelper.

The model is listed but the request fails

The catalog and your account entitlement are different things. Try another provider-qualified model ID returned by /v1/models.

Claude Code still shows or selects built-in models

Check claude --version, then inspect /status for the effective setting sources. Organization-managed Claude Code settings can override local model restrictions.

Sonnet works but GPT fails later

Authentication and basic routing are working. The failing operation likely depends on Claude-specific behavior that does not translate to that GPT endpoint. Keep Sonnet as the default route.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment