Files
storkit/server/src/http/anthropic.rs

19 lines
628 B
Rust
Raw Normal View History

2026-02-16 16:24:21 +00:00
use crate::http::context::{AppContext, OpenApiResult, bad_request};
use crate::http::payloads::ApiKeyPayload;
use crate::llm;
use poem_openapi::payload::Json;
pub async fn get_anthropic_api_key_exists(ctx: &AppContext) -> OpenApiResult<Json<bool>> {
let exists =
llm::chat::get_anthropic_api_key_exists(ctx.store.as_ref()).map_err(bad_request)?;
Ok(Json(exists))
}
pub async fn set_anthropic_api_key(
payload: Json<ApiKeyPayload>,
ctx: &AppContext,
) -> OpenApiResult<Json<bool>> {
llm::chat::set_anthropic_api_key(ctx.store.as_ref(), payload.0.api_key).map_err(bad_request)?;
Ok(Json(true))
}