fix: Add header to anthropic get models api

This commit is contained in:
Vanalite 2025-10-03 20:54:54 +07:00
parent 404f40cc23
commit 86c7122f90
4 changed files with 24 additions and 2 deletions

View File

@ -82,7 +82,7 @@
"remark-math": "6.0.0",
"sonner": "2.0.5",
"tailwindcss": "4.1.4",
"token.js": "npm:token.js-fork@0.7.27",
"token.js": "npm:token.js-fork@0.7.29",
"tw-animate-css": "1.2.8",
"ulidx": "2.4.1",
"unified": "11.0.5",

View File

@ -96,7 +96,7 @@ export const predefinedProviders = [
{
active: true,
api_key: '',
base_url: 'https://api.anthropic.com',
base_url: 'https://api.anthropic.com/v1',
provider: 'anthropic',
explore_models_url:
'https://docs.anthropic.com/en/docs/about-claude/models',
@ -127,6 +127,16 @@ export const predefinedProviders = [
},
],
models: [],
custom_header: [
{
header: 'anthropic-version',
value: '2023-06-01'
},
{
header: 'anthropic-dangerous-direct-browser-access',
value: 'true'
}
]
},
{
active: true,

View File

@ -151,6 +151,12 @@ export class TauriProvidersService extends DefaultProvidersService {
headers['Authorization'] = `Bearer ${provider.api_key}`
}
if (provider.custom_header) {
provider.custom_header.forEach((header) => {
headers[header.header] = header.value
})
}
// Always use Tauri's fetch to avoid CORS issues
const response = await fetchTauri(`${provider.base_url}/models`, {
method: 'GET',

View File

@ -48,6 +48,7 @@ type ProviderObject = {
settings: ProviderSetting[]
models: Model[]
persist?: boolean
custom_header: ProviderCustomHeader[] | null
}
/**
@ -71,3 +72,8 @@ type ProxyOptions = {
verifyHostSSL: boolean
noProxy: string
}
type ProviderCustomHeader = {
header: string
value: string
}