import type { Model, CreateModelInput, UpdateModelInput } from '@/types'
import { request } from './client'

export async function listModels(providerId?: string): Promise<Model[]> {
  const path = providerId ? `/api/models?provider_id=${encodeURIComponent(providerId)}` : '/api/models'
  return request<Model[]>('GET', path)
}

export async function createModel(input: CreateModelInput): Promise<Model> {
  return request<Model>('POST', '/api/models', input)
}

export async function updateModel(id: string, input: UpdateModelInput): Promise<Model> {
  return request<Model>('PUT', `/api/models/${id}`, input)
}

export async function deleteModel(id: string): Promise<void> {
  return request<void>('DELETE', `/api/models/${id}`)
}
