-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Expand file tree
/
Copy pathgithub.ts
More file actions
53 lines (52 loc) · 1.84 KB
/
github.ts
File metadata and controls
53 lines (52 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { defineGateway } from '../define.js'
/**
* GitHub Copilot has a special native-Claude path for Claude models.
* When the model string contains "claude-", the runtime routes through
* the native Anthropic path instead of the OpenAI shim to enable prompt
* caching. This exception is handled in openaiShim.ts and providers.ts
* and must be preserved during migration.
*
* @see src/utils/model/providers.ts — isGithubNativeAnthropicMode()
* @see src/services/api/openaiShim.ts — getGithubEndpointType()
*/
export default defineGateway({
id: 'github',
label: 'GitHub Copilot',
vendorId: 'openai',
category: 'hosted',
defaultBaseUrl: 'https://api.githubcopilot.com',
supportsModelRouting: true,
setup: {
requiresAuth: true,
authMode: 'token',
credentialEnvVars: ['GITHUB_TOKEN', 'GH_TOKEN'],
},
transportConfig: {
kind: 'openai-compatible',
openaiShim: {
supportsAuthHeaders: true,
maxTokensField: 'max_tokens',
},
},
validation: {
kind: 'github-token',
routing: {
enablementEnvVar: 'CLAUDE_CODE_USE_GITHUB',
skipWhenUseOpenAI: true,
},
missingCredentialMessage:
'GitHub Copilot authentication required.\nRun /onboard-github in the CLI to sign in with your GitHub account.\nThis will store your OAuth token securely and enable Copilot models.',
expiredCredentialMessage:
'GitHub Copilot token has expired.\nRun /onboard-github to sign in again and get a fresh token.',
invalidCredentialMessage:
'GitHub Copilot token is invalid or corrupted.\nRun /onboard-github to sign in again with your GitHub account.',
},
catalog: {
source: 'dynamic',
discovery: { kind: 'github-models', requiresAuth: true },
discoveryCacheTtl: '1h',
discoveryRefreshMode: 'background-if-stale',
allowManualRefresh: true,
},
usage: { supported: false },
})