mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
24 lines
863 B
TypeScript
24 lines
863 B
TypeScript
import { Hono } from 'hono'
|
|
import type { WebAppEnv } from '../middleware/auth'
|
|
import { getSettingsFile, readSettings } from '../../config/settings'
|
|
|
|
/**
|
|
* Custom Claude model names configured in settings.json
|
|
* (`customClaudeModels`). Claude Code has no model catalog API like Codex,
|
|
* so users routing Claude through a custom ANTHROPIC_BASE_URL list their
|
|
* endpoint's model names here to surface them in the New Session picker.
|
|
*/
|
|
export function createClaudeModelsRoutes(dataDir: string): Hono<WebAppEnv> {
|
|
const app = new Hono<WebAppEnv>()
|
|
|
|
app.get('/claude/custom-models', async (c) => {
|
|
const settings = await readSettings(getSettingsFile(dataDir))
|
|
const models = Array.isArray(settings?.customClaudeModels)
|
|
? settings.customClaudeModels
|
|
: []
|
|
return c.json({ models })
|
|
})
|
|
|
|
return app
|
|
}
|