feat(config): 为 anthropic、kimi、deepseek 添加 list_models 支持

This commit is contained in:
2026-02-02 06:40:41 +00:00
parent 2e43a5e396
commit 5638315031
6 changed files with 278 additions and 45 deletions

View File

@@ -70,10 +70,16 @@ impl AnthropicClient {
Ok(self)
}
/// List available models
pub async fn list_models(&self) -> Result<Vec<String>> {
// Anthropic doesn't have a models API endpoint, return predefined list
Ok(ANTHROPIC_MODELS.iter().map(|&m| m.to_string()).collect())
}
/// Validate API key
pub async fn validate_key(&self) -> Result<bool> {
let url = "https://api.anthropic.com/v1/messages";
let request = MessagesRequest {
model: self.model.clone(),
max_tokens: 5,
@@ -84,7 +90,7 @@ impl AnthropicClient {
}],
system: None,
};
let response = self.client
.post(url)
.header("x-api-key", &self.api_key)
@@ -93,7 +99,7 @@ impl AnthropicClient {
.json(&request)
.send()
.await;
match response {
Ok(resp) => {
if resp.status().is_success() {