Add custom API URL and model to AI settings

- Settings → AI: optional base URL and model name fields
- Defaults to Anthropic/OpenAI public APIs when left blank
- Custom URL enables Open WebUI, LM Studio, Ollama, and any OpenAI-compatible endpoint
- Parse endpoint uses custom base URL and model if configured
- Migration 0004: ai_base_url + ai_model columns on users
- OpenAI provider label updated to "OpenAI-compatible"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-04-22 19:01:00 +00:00
parent b1c160f607
commit d6118bac54
6 changed files with 124 additions and 29 deletions

View file

@ -3,6 +3,15 @@ import { api } from "./client";
export interface AiSettings {
provider: string | null;
has_api_key: boolean;
base_url: string | null;
model: string | null;
}
export interface AiSettingsSave {
provider: string;
api_key?: string;
base_url?: string;
model?: string;
}
export interface ParsedReceipt {
@ -19,8 +28,8 @@ export async function getAiSettings(): Promise<AiSettings> {
return data;
}
export async function saveAiSettings(provider: string, api_key: string): Promise<AiSettings> {
const { data } = await api.put("/settings/ai", { provider, api_key });
export async function saveAiSettings(body: AiSettingsSave): Promise<AiSettings> {
const { data } = await api.put("/settings/ai", body);
return data;
}