Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

feat: support Anthropic Messages API format in the Custom post-processing provider (#2257)

diligentpig14ae9c6b42d7
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index a41d62c5..29905f9d 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -681,6 +681,7 @@ pub fn run(cli_args: CliArgs) {
shortcut::change_post_process_enabled_setting,
shortcut::change_experimental_enabled_setting,
shortcut::change_post_process_base_url_setting,
+ shortcut::change_post_process_api_format_setting,
shortcut::change_post_process_api_key_setting,
shortcut::change_post_process_model_setting,
shortcut::set_post_process_provider,
diff --git a/src-tauri/src/llm_client.rs b/src-tauri/src/llm_client.rs
index f5695b51..3ab51339 100644
--- a/src-tauri/src/llm_client.rs
+++ b/src-tauri/src/llm_client.rs
@@ -1,4 +1,4 @@
-use crate::settings::PostProcessProvider;
+use crate::settings::{PostProcessApiFormat, PostProcessProvider};
use log::{debug, error, info};
use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION, CONTENT_TYPE, REFERER, USER_AGENT};
use serde::{Deserialize, Serialize};
@@ -128,6 +128,7 @@ struct ChatCompletionResponse {
#[derive(Debug, Deserialize)]
struct ChatChoice {
message: ChatMessageResponse,
+ finish_reason: Option<String>,
}
#[derive(Debug, Deserialize)]
@@ -135,6 +136,48 @@ struct ChatMessageResponse {
content: Option<String>,
}
+/// Output budget for Anthropic Messages requests, where `max_tokens` is
+/// required. Ample for a cleaned-up dictation.
+const ANTHROPIC_MAX_TOKENS: u32 = 4096;
+
+#[derive(Debug, Serialize)]
+struct AnthropicMessagesRequest {
+ model: String,
+ max_tokens: u32,
+ messages: Vec<ChatMessage>,
+}
+
+#[derive(Debug, Deserialize)]
+struct AnthropicMessagesResponse {
+ content: Vec<AnthropicContentBlock>,
+ stop_reason: Option<String>,
+}
+
+#[derive(Debug, Deserialize)]
+#[serde(tag = "type", rename_all = "lowercase")]
+enum AnthropicContentBlock {
+ Text {
+ text: String,
+ },
+ /// Thinking and any other non-text blocks
+ #[serde(other)]
+ Other,
+}
+
+impl AnthropicMessagesResponse {
+ fn into_text(self) -> Option<String> {
+ let text: String = self
+ .content
+ .into_iter()
+ .filter_map(|block| match block {
+ AnthropicContentBlock::Text { text } => Some(text),
+ AnthropicContentBlock::Other => None,
+ })
+ .collect();
+ (!text.is_empty()).then_some(text)
+ }
+}
+
/// Build headers for API requests based on provider type
fn build_headers(provider: &PostProcessProvider, api_key: &str) -> Result<HeaderMap, String> {
let mut headers = HeaderMap::new();
@@ -153,7 +196,7 @@ fn build_headers(provider: &PostProcessProvider, api_key: &str) -> Result<Header
// Provider-specific auth headers
if !api_key.is_empty() {
- if provider.id == "anthropic" {
+ if provider.api_format == PostProcessApiFormat::Anthropic {
headers.insert(
"x-api-key",
HeaderValue::from_str(api_key)
@@ -304,6 +347,10 @@ pub async fn send_chat_completion(
prompt: String,
disable_reasoning: bool,
) -> Result<Option<String>, String> {
+ if provider.api_format == PostProcessApiFormat::Anthropic {
+ return send_anthropic_message(provider, api_key, model, prompt).await;
+ }
+
send_chat_completion_with_schema(
provider,
api_key,
@@ -455,10 +502,87 @@ pub async fn send_chat_completion_with_schema(
.await
.map_err(|e| report_reqwest_error("Failed to parse API response", &e))?;
- Ok(completion
- .choices
- .first()
- .and_then(|choice| choice.message.content.clone()))
+ let Some(choice) = completion.choices.into_iter().next() else {
+ return Ok(None);
+ };
+
+ // A response cut off at the provider's output limit is incomplete; pasting
+ // it would silently drop the end of the dictation (or, for structured
+ // output, paste unparseable JSON).
+ if choice.finish_reason.as_deref() == Some("length") {
+ return Err("Response was truncated at the provider's output token limit".to_string());
+ }
+
+ Ok(choice.message.content)
+}
+
+/// Send a single-prompt request to an Anthropic Messages API (`/messages`).
+/// Used by every provider with the Anthropic format (the built-in Anthropic
+/// provider and a custom provider set to it). None of them use structured
+/// output, and thinking is off unless requested, so no reasoning fields are
+/// needed.
+async fn send_anthropic_message(
+ provider: &PostProcessProvider,
+ api_key: String,
+ model: &str,
+ prompt: String,
+) -> Result<Option<String>, String> {
+ let url = format!("{}/messages", provider.base_url.trim_end_matches('/'));
+
+ debug!(
+ "Sending Anthropic Messages request to: {}",
+ sanitized_url_for_log(&url)
+ );
+
+ let request_body = AnthropicMessagesRequest {
+ model: model.to_string(),
+ max_tokens: ANTHROPIC_MAX_TOKENS,
+ messages: vec![ChatMessage {
+ role: "user".to_string(),
+ content: prompt,
+ }],
+ };
+
+ let response = create_client(provider, &api_key)?
+ .post(&url)
+ .json(&request_body)
+ .send()
+ .await
+ .map_err(|e| report_reqwest_error("HTTP request failed", &e))?;
+ let status = response.status();
+ debug!(
+ "Anthropic Messages response received with status {} over {:?} from {}",
+ status,
+ response.version(),
+ sanitized_url(response.url())
+ );
+
+ if !status.is_success() {
+ let error_text = response
+ .text()
+ .await
+ .unwrap_or_else(|e| report_reqwest_error("Failed to read API error response", &e));
+ return Err(format!(
+ "API request failed with status {}: {}",
+ status, error_text
+ ));
+ }
+
+ let message: AnthropicMessagesResponse = response
+ .json()
+ .await
+ .map_err(|e| report_reqwest_error("Failed to parse API response", &e))?;
+
+ // A response cut off at the token budget is incomplete; pasting it would
+ // silently drop the end of the dictation.
+ if message.stop_reason.as_deref() == Some("max_tokens") {
+ return Err(format!(
+ "Response was truncated at the {} token limit",
+ ANTHROPIC_MAX_TOKENS
+ ));
+ }
+
+ Ok(message.into_text())
}
/// Fetch available models from an OpenAI-compatible API
@@ -561,6 +685,14 @@ mod tests {
allow_base_url_edit: true,
models_endpoint: None,
supports_structured_output: false,
+ api_format: PostProcessApiFormat::OpenAi,
+ }
+ }
+
+ fn anthropic_format_provider(base_url: &str) -> PostProcessProvider {
+ PostProcessProvider {
+ api_format: PostProcessApiFormat::Anthropic,
+ ..provider("custom", base_url)
}
}
@@ -731,4 +863,104 @@ mod tests {
// A different model on the same endpoint is tracked separately
assert!(!is_known_rejected(&endpoint_key(&deepseek, "other-model")));
}
+
+ #[test]
+ fn anthropic_format_uses_api_key_headers() {
+ let headers = build_headers(
+ &anthropic_format_provider("https://example.com/anthropic/v1"),
+ "key",
+ )
+ .unwrap();
+ assert_eq!(headers["x-api-key"], "key");
+ assert_eq!(headers["anthropic-version"], "2023-06-01");
+ assert!(headers.get(AUTHORIZATION).is_none());
+
+ let headers =
+ build_headers(&provider("custom", "http://localhost:11434/v1"), "key").unwrap();
+ assert_eq!(headers[AUTHORIZATION], "Bearer key");
+ assert!(headers.get("x-api-key").is_none());
+ }
+
+ #[test]
+ fn anthropic_request_carries_required_max_tokens() {
+ let request = AnthropicMessagesRequest {
+ model: "claude-haiku".to_string(),
+ max_tokens: ANTHROPIC_MAX_TOKENS,
+ messages: vec![ChatMessage {
+ role: "user".to_string(),
+ content: "hi".to_string(),
+ }],
+ };
+ let json = serde_json::to_value(&request).unwrap();
+ assert_eq!(json["max_tokens"], ANTHROPIC_MAX_TOKENS);
+ assert_eq!(json["messages"][0]["role"], "user");
+ assert!(json.get("stream").is_none());
+ assert!(json.get("reasoning_effort").is_none());
+ }
+
+ #[test]
+ fn anthropic_response_keeps_only_text_blocks() {
+ let response: AnthropicMessagesResponse = serde_json::from_str(
+ r#"{"content":[{"type":"thinking","thinking":"hmm"},{"type":"text","text":"Hello"},{"type":"text","text":" world"}]}"#,
+ )
+ .unwrap();
+ assert_eq!(response.into_text().as_deref(), Some("Hello world"));
+
+ let empty: AnthropicMessagesResponse = serde_json::from_str(r#"{"content":[]}"#).unwrap();
+ assert_eq!(empty.into_text(), None);
+ }
+
+ #[tokio::test]
+ async fn anthropic_format_parses_messages_response() {
+ let base_url = serve_one_response(
+ "200 OK",
+ r#"{"type":"message","role":"assistant","content":[{"type":"text","text":"Cleaned text"}]}"#,
+ )
+ .await;
+ let result = send_chat_completion(
+ &anthropic_format_provider(&base_url),
+ "key".to_string(),
+ "claude-haiku",
+ "raw text".to_string(),
+ true,
+ )
+ .await;
+ assert_eq!(result, Ok(Some("Cleaned text".to_string())));
+ }
+
+ #[tokio::test]
+ async fn chat_completion_rejects_truncated_response() {
+ let base_url = serve_one_response(
+ "200 OK",
+ r#"{"choices":[{"message":{"content":"Cut off"},"finish_reason":"length"}]}"#,
+ )
+ .await;
+ let result = send_chat_completion(
+ &provider("custom", &base_url),
+ "key".to_string(),
+ "test-model",
+ "raw text".to_string(),
+ false,
+ )
+ .await;
+ assert!(result.unwrap_err().contains("truncated"));
+ }
+
+ #[tokio::test]
+ async fn anthropic_format_rejects_truncated_response() {
+ let base_url = serve_one_response(
+ "200 OK",
+ r#"{"type":"message","stop_reason":"max_tokens","content":[{"type":"text","text":"Cut off"}]}"#,
+ )
+ .await;
+ let result = send_chat_completion(
+ &anthropic_format_provider(&base_url),
+ "key".to_string(),
+ "claude-haiku",
+ "raw text".to_string(),
+ true,
+ )
+ .await;
+ assert!(result.unwrap_err().contains("truncated"));
+ }
}
diff --git a/src-tauri/src/settings.rs b/src-tauri/src/settings.rs
index bd4ecbd9..26aa8246 100644
--- a/src-tauri/src/settings.rs
+++ b/src-tauri/src/settings.rs
@@ -94,6 +94,18 @@ pub struct LLMPrompt {
pub prompt: String,
}
+/// Request format a post-processing endpoint speaks. Built-in providers have a
+/// fixed format; only the custom provider lets the user change it.
+#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default, PartialEq, Eq, Type)]
+#[serde(rename_all = "lowercase")]
+pub enum PostProcessApiFormat {
+ /// OpenAI-compatible Chat Completions (`/chat/completions`)
+ #[default]
+ OpenAi,
+ /// Anthropic Messages (`/messages`)
+ Anthropic,
+}
+
#[derive(Serialize, Deserialize, Debug, Clone, Type)]
pub struct PostProcessProvider {
pub id: String,
@@ -105,6 +117,8 @@ pub struct PostProcessProvider {
pub models_endpoint: Option<String>,
#[serde(default)]
pub supports_structured_output: bool,
+ #[serde(default)]
+ pub api_format: PostProcessApiFormat,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Type)]
@@ -678,6 +692,7 @@ fn default_post_process_providers() -> Vec<PostProcessProvider> {
allow_base_url_edit: false,
models_endpoint: Some("/models".to_string()),
supports_structured_output: true,
+ api_format: PostProcessApiFormat::OpenAi,
},
PostProcessProvider {
id: "zai".to_string(),
@@ -686,6 +701,7 @@ fn default_post_process_providers() -> Vec<PostProcessProvider> {
allow_base_url_edit: false,
models_endpoint: Some("/models".to_string()),
supports_structured_output: true,
+ api_format: PostProcessApiFormat::OpenAi,
},
PostProcessProvider {
id: "openrouter".to_string(),
@@ -694,6 +710,7 @@ fn default_post_process_providers() -> Vec<PostProcessProvider> {
allow_base_url_edit: false,
models_endpoint: Some("/models".to_string()),
supports_structured_output: true,
+ api_format: PostProcessApiFormat::OpenAi,
},
PostProcessProvider {
id: "anthropic".to_string(),
@@ -702,6 +719,7 @@ fn default_post_process_providers() -> Vec<PostProcessProvider> {
allow_base_url_edit: false,
models_endpoint: Some("/models".to_string()),
supports_structured_output: false,
+ api_format: PostProcessApiFormat::Anthropic,
},
PostProcessProvider {
id: "groq".to_string(),
@@ -710,6 +728,7 @@ fn default_post_process_providers() -> Vec<PostProcessProvider> {
allow_base_url_edit: false,
models_endpoint: Some("/models".to_string()),
supports_structured_output: false,
+ api_format: PostProcessApiFormat::OpenAi,
},
PostProcessProvider {
id: "cerebras".to_string(),
@@ -718,6 +737,7 @@ fn default_post_process_providers() -> Vec<PostProcessProvider> {
allow_base_url_edit: false,
models_endpoint: Some("/models".to_string()),
supports_structured_output: true,
+ api_format: PostProcessApiFormat::OpenAi,
},
];
@@ -734,6 +754,7 @@ fn default_post_process_providers() -> Vec<PostProcessProvider> {
allow_base_url_edit: false,
models_endpoint: None,
supports_structured_output: true,
+ api_format: PostProcessApiFormat::OpenAi,
});
}
@@ -745,6 +766,7 @@ fn default_post_process_providers() -> Vec<PostProcessProvider> {
allow_base_url_edit: false,
models_endpoint: Some("/models".to_string()),
supports_structured_output: true,
+ api_format: PostProcessApiFormat::OpenAi,
});
// Custom provider always comes last
@@ -755,6 +777,7 @@ fn default_post_process_providers() -> Vec<PostProcessProvider> {
allow_base_url_edit: true,
models_endpoint: Some("/models".to_string()),
supports_structured_output: false,
+ api_format: PostProcessApiFormat::OpenAi,
});
providers
@@ -840,6 +863,17 @@ fn ensure_post_process_defaults(settings: &mut AppSettings) -> bool {
existing.supports_structured_output = provider.supports_structured_output;
changed = true;
}
+
+ // Built-in providers have a fixed API format (migration); the
+ // custom provider's format is a user choice and is left alone.
+ if provider.id != "custom" && existing.api_format != provider.api_format {
+ debug!(
+ "Updating api_format for provider '{}' from {:?} to {:?}",
+ provider.id, existing.api_format, provider.api_format
+ );
+ existing.api_format = provider.api_format;
+ changed = true;
+ }
}
None => {
// Provider doesn't exist, add it
@@ -1761,6 +1795,25 @@ mod tests {
);
}
+ #[test]
+ fn post_process_defaults_sync_builtin_api_format_but_keep_custom() {
+ let mut settings = get_default_settings();
+ for provider in settings.post_process_providers.iter_mut() {
+ match provider.id.as_str() {
+ // Settings saved before the built-in provider moved to Messages
+ "anthropic" => provider.api_format = PostProcessApiFormat::OpenAi,
+ "custom" => provider.api_format = PostProcessApiFormat::Anthropic,
+ _ => {}
+ }
+ }
+
+ assert!(ensure_post_process_defaults(&mut settings));
+
+ let format_of = |id: &str| settings.post_process_provider(id).unwrap().api_format;
+ assert_eq!(format_of("anthropic"), PostProcessApiFormat::Anthropic);
+ assert_eq!(format_of("custom"), PostProcessApiFormat::Anthropic);
+ }
+
#[test]
fn debug_output_redacts_api_keys() {
let mut settings = get_default_settings();
diff --git a/src-tauri/src/shortcut/mod.rs b/src-tauri/src/shortcut/mod.rs
index 3dbc5e3a..ce661907 100644
--- a/src-tauri/src/shortcut/mod.rs
+++ b/src-tauri/src/shortcut/mod.rs
@@ -1110,6 +1110,30 @@ pub fn change_post_process_base_url_setting(
Ok(())
}
+#[tauri::command]
+#[specta::specta]
+pub fn change_post_process_api_format_setting(
+ app: AppHandle,
+ provider_id: String,
+ api_format: settings::PostProcessApiFormat,
+) -> Result<(), String> {
+ let mut settings = settings::get_settings(&app);
+ let provider = settings
+ .post_process_provider_mut(&provider_id)
+ .ok_or_else(|| format!("Provider '{}' not found", provider_id))?;
+
+ if provider.id != "custom" {
+ return Err(format!(
+ "Provider '{}' does not allow changing the API format",
+ provider.label
+ ));
+ }
+
+ provider.api_format = api_format;
+ settings::write_settings(&app, settings);
+ Ok(())
+}
+
/// Generic helper to validate provider exists
fn validate_provider_exists(
settings: &settings::AppSettings,
diff --git a/src/bindings.ts b/src/bindings.ts
index 1d8fc9a3..c4fcebca 100644
--- a/src/bindings.ts
+++ b/src/bindings.ts
@@ -240,6 +240,14 @@ async changePostProcessBaseUrlSetting(providerId: string, baseUrl: string) : Pro
else return { status: "error", error: e as any };
}
},
+async changePostProcessApiFormatSetting(providerId: string, apiFormat: PostProcessApiFormat) : Promise<Result<null, string>> {
+ try {
+ return { status: "ok", data: await TAURI_INVOKE("change_post_process_api_format_setting", { providerId, apiFormat }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
async changePostProcessApiKeySetting(providerId: string, apiKey: string) : Promise<Result<null, string>> {
try {
return { status: "ok", data: await TAURI_INVOKE("change_post_process_api_key_setting", { providerId, apiKey }) };
@@ -1098,7 +1106,20 @@ export type OverlayStyle = "none" | "minimal" | "live"
export type PaginatedHistory = { entries: HistoryEntry[]; has_more: boolean }
export type PasteMethod = "ctrl_v" | "direct" | "none" | "shift_insert" | "ctrl_shift_v" | "external_script"
export type PermissionAccess = "allowed" | "denied" | "unknown"
-export type PostProcessProvider = { id: string; label: string; base_url: string; allow_base_url_edit?: boolean; models_endpoint?: string | null; supports_structured_output?: boolean }
+/**
+ * Request format a post-processing endpoint speaks. Built-in providers have a
+ * fixed format; only the custom provider lets the user change it.
+ */
+export type PostProcessApiFormat =
+/**
+ * OpenAI-compatible Chat Completions (`/chat/completions`)
+ */
+"openai" |
+/**
+ * Anthropic Messages (`/messages`)
+ */
+"anthropic"
+export type PostProcessProvider = { id: string; label: string; base_url: string; allow_base_url_edit?: boolean; models_endpoint?: string | null; supports_structured_output?: boolean; api_format?: PostProcessApiFormat }
export type RecordingRetentionPeriod = "never" | "preserve_limit" | "days_3" | "weeks_2" | "months_3"
export type SecretMap = Partial<{ [key in string]: string }>
export type SecureInputStatus = {
diff --git a/src/components/settings/PostProcessingSettingsApi/usePostProcessProviderState.ts b/src/components/settings/PostProcessingSettingsApi/usePostProcessProviderState.ts
index 676fba00..94a61e69 100644
--- a/src/components/settings/PostProcessingSettingsApi/usePostProcessProviderState.ts
+++ b/src/components/settings/PostProcessingSettingsApi/usePostProcessProviderState.ts
@@ -1,6 +1,10 @@
import { useCallback, useMemo, useState } from "react";
import { useSettings } from "../../../hooks/useSettings";
-import { commands, type PostProcessProvider } from "@/bindings";
+import {
+ commands,
+ type PostProcessApiFormat,
+ type PostProcessProvider,
+} from "@/bindings";
import type { ModelOption } from "./types";
import type { DropdownOption } from "../../ui/Dropdown";
@@ -14,6 +18,9 @@ type PostProcessProviderState = {
baseUrl: string;
handleBaseUrlChange: (value: string) => void;
isBaseUrlUpdating: boolean;
+ apiFormat: PostProcessApiFormat;
+ handleApiFormatChange: (value: PostProcessApiFormat) => void;
+ isApiFormatUpdating: boolean;
apiKey: string;
handleApiKeyChange: (value: string) => void;
isApiKeyUpdating: boolean;
@@ -36,6 +43,7 @@ export const usePostProcessProviderState = (): PostProcessProviderState => {
isUpdating,
setPostProcessProvider,
updatePostProcessBaseUrl,
+ updatePostProcessApiFormat,
updatePostProcessApiKey,
updatePostProcessModel,
fetchPostProcessModels,
@@ -62,6 +70,7 @@ export const usePostProcessProviderState = (): PostProcessProviderState => {
// Use settings directly as single source of truth
const baseUrl = selectedProvider?.base_url ?? "";
+ const apiFormat = selectedProvider?.api_format ?? "openai";
const apiKey = settings?.post_process_api_keys?.[selectedProviderId] ?? "";
const model = settings?.post_process_models?.[selectedProviderId] ?? "";
@@ -129,6 +138,15 @@ export const usePostProcessProviderState = (): PostProcessProviderState => {
[selectedProvider, baseUrl, updatePostProcessBaseUrl],
);
+ const handleApiFormatChange = useCallback(
+ (value: PostProcessApiFormat) => {
+ if (value !== apiFormat) {
+ void updatePostProcessApiFormat(selectedProviderId, value);
+ }
+ },
+ [apiFormat, selectedProviderId, updatePostProcessApiFormat],
+ );
+
const handleApiKeyChange = useCallback(
(value: string) => {
const trimmed = value.trim();
@@ -195,6 +213,9 @@ export const usePostProcessProviderState = (): PostProcessProviderState => {
const isBaseUrlUpdating = isUpdating(
`post_process_base_url:${selectedProviderId}`,
);
+ const isApiFormatUpdating = isUpdating(
+ `post_process_api_format:${selectedProviderId}`,
+ );
const isApiKeyUpdating = isUpdating(
`post_process_api_key:${selectedProviderId}`,
);
@@ -219,6 +240,9 @@ export const usePostProcessProviderState = (): PostProcessProviderState => {
baseUrl,
handleBaseUrlChange,
isBaseUrlUpdating,
+ apiFormat,
+ handleApiFormatChange,
+ isApiFormatUpdating,
apiKey,
handleApiKeyChange,
isApiKeyUpdating,
diff --git a/src/components/settings/post-processing/PostProcessingSettings.tsx b/src/components/settings/post-processing/PostProcessingSettings.tsx
index 371a8443..8809b76a 100644
--- a/src/components/settings/post-processing/PostProcessingSettings.tsx
+++ b/src/components/settings/post-processing/PostProcessingSettings.tsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { RefreshCcw } from "lucide-react";
-import { commands } from "@/bindings";
+import { commands, type PostProcessApiFormat } from "@/bindings";
import { Alert } from "../../ui/Alert";
import {
@@ -52,6 +52,40 @@ const PostProcessingSettingsApiComponent: React.FC = () => {
) : null
) : (
<>
+ {state.isCustomProvider && (
+ <SettingContainer
+ title={t("settings.postProcessing.api.apiFormat.title")}
+ description={t(
+ "settings.postProcessing.api.apiFormat.description",
+ )}
+ descriptionMode="tooltip"
+ layout="horizontal"
+ grouped={true}
+ >
+ <Dropdown
+ options={[
+ {
+ value: "openai",
+ label: t(
+ "settings.postProcessing.api.apiFormat.options.openai",
+ ),
+ },
+ {
+ value: "anthropic",
+ label: t(
+ "settings.postProcessing.api.apiFormat.options.anthropic",
+ ),
+ },
+ ]}
+ selectedValue={state.apiFormat}
+ onSelect={(value) =>
+ state.handleApiFormatChange(value as PostProcessApiFormat)
+ }
+ disabled={state.isApiFormatUpdating}
+ />
+ </SettingContainer>
+ )}
+
{state.selectedProvider?.id === "custom" && (
<SettingContainer
title={t("settings.postProcessing.api.baseUrl.title")}
@@ -64,9 +98,13 @@ const PostProcessingSettingsApiComponent: React.FC = () => {
<BaseUrlField
value={state.baseUrl}
onBlur={state.handleBaseUrlChange}
- placeholder={t(
- "settings.postProcessing.api.baseUrl.placeholder",
- )}
+ placeholder={
+ state.apiFormat === "anthropic"
+ ? t(
+ "settings.postProcessing.api.baseUrl.placeholderAnthropic",
+ )
+ : t("settings.postProcessing.api.baseUrl.placeholder")
+ }
disabled={state.isBaseUrlUpdating}
className="min-w-[380px]"
/>
diff --git a/src/hooks/useSettings.ts b/src/hooks/useSettings.ts
index 33c17d3d..8c4c858b 100644
--- a/src/hooks/useSettings.ts
+++ b/src/hooks/useSettings.ts
@@ -1,6 +1,10 @@
import { useEffect } from "react";
import { useSettingsStore } from "../stores/settingsStore";
-import type { AppSettings as Settings, AudioDevice } from "@/bindings";
+import type {
+ AppSettings as Settings,
+ AudioDevice,
+ PostProcessApiFormat,
+} from "@/bindings";
interface UseSettingsReturn {
// State
@@ -36,6 +40,10 @@ interface UseSettingsReturn {
providerId: string,
baseUrl: string,
) => Promise<void>;
+ updatePostProcessApiFormat: (
+ providerId: string,
+ apiFormat: PostProcessApiFormat,
+ ) => Promise<void>;
updatePostProcessApiKey: (
providerId: string,
apiKey: string,
@@ -73,6 +81,7 @@ export const useSettings = (): UseSettingsReturn => {
getSetting: store.getSetting,
setPostProcessProvider: store.setPostProcessProvider,
updatePostProcessBaseUrl: store.updatePostProcessBaseUrl,
+ updatePostProcessApiFormat: store.updatePostProcessApiFormat,
updatePostProcessApiKey: store.updatePostProcessApiKey,
updatePostProcessModel: store.updatePostProcessModel,
fetchPostProcessModels: store.fetchPostProcessModels,
diff --git a/src/i18n/locales/ar/translation.json b/src/i18n/locales/ar/translation.json
index 20a3e283..407eb517 100644
--- a/src/i18n/locales/ar/translation.json
+++ b/src/i18n/locales/ar/translation.json
@@ -391,10 +391,18 @@
"title": "مفتاح الاختصار"
},
"api": {
- "title": "API (متوافق مع OpenAI)",
+ "title": "API",
"provider": {
"title": "المزود",
- "description": "اختر مزوداً متوافقاً مع OpenAI."
+ "description": "اختر مزوداً متوافقاً مع OpenAI أو Anthropic."
+ },
+ "apiFormat": {
+ "title": "تنسيق API",
+ "description": "تنسيق الطلب الذي تتوقعه نقطة النهاية المخصصة الخاصة بك.",
+ "options": {
+ "openai": "متوافق مع OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence غير متاح على هذا الجهاز. يتطلب جهاز Mac بمعالج Apple Silicon يعمل بنظام macOS Tahoe (26.0) أو أحدث مع تمكين Apple Intelligence في إعدادات النظام."
@@ -402,7 +410,8 @@
"baseUrl": {
"title": "URL الأساسي",
"description": "URL الأساسي لـ API للمزود المختار. يمكن تعديل المزود المخصص فقط.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "مفتاح API",
diff --git a/src/i18n/locales/bg/translation.json b/src/i18n/locales/bg/translation.json
index 74838b16..640713bf 100644
--- a/src/i18n/locales/bg/translation.json
+++ b/src/i18n/locales/bg/translation.json
@@ -414,10 +414,18 @@
"title": "Бърз клавиш"
},
"api": {
- "title": "API (съвместим с OpenAI)",
+ "title": "API",
"provider": {
"title": "Доставчик",
- "description": "Изберете доставчик, съвместим с OpenAI."
+ "description": "Изберете доставчик, съвместим с OpenAI или Anthropic."
+ },
+ "apiFormat": {
+ "title": "Формат на API",
+ "description": "Формат на заявката, очакван от вашия персонализиран краен адрес.",
+ "options": {
+ "openai": "Съвместим с OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence не е налична на това устройство. Необходим е Mac с Apple Silicon и macOS Tahoe (26.0) или по-нова с включена Apple Intelligence в Системните настройки."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Базов URL",
"description": "Базов API URL за избрания доставчик. Редактируем е само при персонализиран доставчик.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API ключ",
diff --git a/src/i18n/locales/ca/translation.json b/src/i18n/locales/ca/translation.json
index 885fb8e1..d6ac0ea1 100644
--- a/src/i18n/locales/ca/translation.json
+++ b/src/i18n/locales/ca/translation.json
@@ -414,10 +414,18 @@
"title": "Drecera de teclat"
},
"api": {
- "title": "API (compatible amb OpenAI)",
+ "title": "API",
"provider": {
"title": "Proveïdor",
- "description": "Seleccioneu un proveïdor compatible amb OpenAI."
+ "description": "Seleccioneu un proveïdor compatible amb OpenAI o Anthropic."
+ },
+ "apiFormat": {
+ "title": "Format de l'API",
+ "description": "Format de sol·licitud que espera el punt de connexió personalitzat.",
+ "options": {
+ "openai": "Compatible amb OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "L'Apple Intelligence no està disponible en aquest dispositiu. Cal un Mac amb Apple Silicon i macOS Tahoe (26.0) o posterior, amb l'Apple Intelligence activada a la configuració del sistema."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "URL de base",
"description": "URL de base de l'API del proveïdor seleccionat. Només es pot editar la del proveïdor personalitzat.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "Clau de l'API",
diff --git a/src/i18n/locales/cs/translation.json b/src/i18n/locales/cs/translation.json
index f7f7003e..8571719f 100644
--- a/src/i18n/locales/cs/translation.json
+++ b/src/i18n/locales/cs/translation.json
@@ -414,10 +414,18 @@
"title": "Klávesová zkratka"
},
"api": {
- "title": "API (kompatibilní s OpenAI)",
+ "title": "API",
"provider": {
"title": "Poskytovatel",
- "description": "Vyberte poskytovatele kompatibilního s OpenAI."
+ "description": "Vyberte poskytovatele kompatibilního s OpenAI nebo Anthropic."
+ },
+ "apiFormat": {
+ "title": "Formát API",
+ "description": "Formát požadavku očekávaný vaším vlastním endpointem.",
+ "options": {
+ "openai": "Kompatibilní s OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence není na tomto zařízení k dispozici. Vyžaduje Mac s Apple Silicon a macOS Tahoe (26.0) nebo novější a povolené Apple Intelligence v Nastavení systému."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Základní URL",
"description": "Základní URL API pro vybraného poskytovatele. Upravitelné je pouze u vlastního poskytovatele.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API klíč",
diff --git a/src/i18n/locales/da/translation.json b/src/i18n/locales/da/translation.json
index be3f519d..b72a0753 100644
--- a/src/i18n/locales/da/translation.json
+++ b/src/i18n/locales/da/translation.json
@@ -414,10 +414,18 @@
"title": "Genvejstast"
},
"api": {
- "title": "API (OpenAI-kompatibel)",
+ "title": "API",
"provider": {
"title": "Udbyder",
- "description": "Vælg en OpenAI-kompatibel udbyder."
+ "description": "Vælg en OpenAI- eller Anthropic-kompatibel udbyder."
+ },
+ "apiFormat": {
+ "title": "API-format",
+ "description": "Det anmodningsformat, som det brugerdefinerede endpoint forventer.",
+ "options": {
+ "openai": "OpenAI-kompatibel (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence er ikke tilgængelig på denne enhed. Kræver en Apple Silicon Mac med macOS Tahoe (26.0) eller nyere med Apple Intelligence aktiveret i Systemindstillinger."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Basis-URL",
"description": "API-basis-URL for den valgte udbyder. Kun den brugerdefinerede udbyder kan redigeres.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API-nøgle",
diff --git a/src/i18n/locales/de/translation.json b/src/i18n/locales/de/translation.json
index 7b192d2c..418d6ef7 100644
--- a/src/i18n/locales/de/translation.json
+++ b/src/i18n/locales/de/translation.json
@@ -414,10 +414,18 @@
"title": "Tastenkürzel"
},
"api": {
- "title": "API (OpenAI-kompatibel)",
+ "title": "API",
"provider": {
"title": "Anbieter",
- "description": "Wähle einen OpenAI-kompatiblen Anbieter."
+ "description": "Wähle einen OpenAI- oder Anthropic-kompatiblen Anbieter."
+ },
+ "apiFormat": {
+ "title": "API-Format",
+ "description": "Anfrageformat, das von deinem benutzerdefinierten Endpunkt erwartet wird.",
+ "options": {
+ "openai": "OpenAI-kompatibel (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence ist auf diesem Gerät nicht verfügbar. Erfordert einen Apple Silicon Mac mit macOS Tahoe (26.0) oder neuer und aktiviertem Apple Intelligence in den Systemeinstellungen."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Basis-URL",
"description": "API-Basis-URL für den ausgewählten Anbieter. Nur der benutzerdefinierte Anbieter kann bearbeitet werden.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API-Schlüssel",
diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json
index 088a11c2..98441d43 100644
--- a/src/i18n/locales/en/translation.json
+++ b/src/i18n/locales/en/translation.json
@@ -414,10 +414,18 @@
"title": "Hotkey"
},
"api": {
- "title": "API (OpenAI Compatible)",
+ "title": "API",
"provider": {
"title": "Provider",
- "description": "Select an OpenAI-compatible provider."
+ "description": "Select an OpenAI-compatible or Anthropic-compatible provider."
+ },
+ "apiFormat": {
+ "title": "API Format",
+ "description": "Request format expected by your custom endpoint.",
+ "options": {
+ "openai": "OpenAI Compatible (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence is not available on this device. Requires an Apple Silicon Mac running macOS Tahoe (26.0) or later with Apple Intelligence enabled in System Settings."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Base URL",
"description": "API base URL for the selected provider. Only the custom provider can be edited.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API Key",
diff --git a/src/i18n/locales/es/translation.json b/src/i18n/locales/es/translation.json
index 8af84005..3c084cf1 100644
--- a/src/i18n/locales/es/translation.json
+++ b/src/i18n/locales/es/translation.json
@@ -414,10 +414,18 @@
"title": "Tecla de acceso rápido"
},
"api": {
- "title": "API (compatible con OpenAI)",
+ "title": "API",
"provider": {
"title": "Proveedor",
- "description": "Selecciona un proveedor compatible con OpenAI."
+ "description": "Selecciona un proveedor compatible con OpenAI o Anthropic."
+ },
+ "apiFormat": {
+ "title": "Formato de API",
+ "description": "Formato de solicitud esperado por tu endpoint personalizado.",
+ "options": {
+ "openai": "Compatible con OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence no está disponible en este dispositivo. Requiere un Mac con Apple Silicon ejecutando macOS Tahoe (26.0) o posterior con Apple Intelligence habilitado en Ajustes del Sistema."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "URL base",
"description": "URL base de la API para el proveedor seleccionado. Solo se puede editar el proveedor personalizado.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "Clave API",
diff --git a/src/i18n/locales/fr/translation.json b/src/i18n/locales/fr/translation.json
index 6349029a..74e4659e 100644
--- a/src/i18n/locales/fr/translation.json
+++ b/src/i18n/locales/fr/translation.json
@@ -414,10 +414,18 @@
"title": "Raccourci clavier"
},
"api": {
- "title": "API (Compatible OpenAI)",
+ "title": "API",
"provider": {
"title": "Fournisseur",
- "description": "Sélectionnez un fournisseur compatible OpenAI."
+ "description": "Sélectionnez un fournisseur compatible OpenAI ou Anthropic."
+ },
+ "apiFormat": {
+ "title": "Format d'API",
+ "description": "Format de requête attendu par votre point de terminaison personnalisé.",
+ "options": {
+ "openai": "Compatible OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence n'est pas disponible sur cet appareil. Nécessite un Mac Apple Silicon exécutant macOS Tahoe (26.0) ou une version ultérieure avec Apple Intelligence activé dans les Préférences Système."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "URL de base",
"description": "URL de base de l'API pour le fournisseur sélectionné. Seul le fournisseur personnalisé peut être modifié.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "Clé API",
diff --git a/src/i18n/locales/he/translation.json b/src/i18n/locales/he/translation.json
index d05ec5c0..5da5040c 100644
--- a/src/i18n/locales/he/translation.json
+++ b/src/i18n/locales/he/translation.json
@@ -414,10 +414,18 @@
"title": "קיצור מקשים"
},
"api": {
- "title": "API (תואם OpenAI)",
+ "title": "API",
"provider": {
"title": "ספק",
- "description": "בחר ספק שתואם ל-OpenAI."
+ "description": "בחר ספק שתואם ל-OpenAI או ל-Anthropic."
+ },
+ "apiFormat": {
+ "title": "פורמט API",
+ "description": "פורמט הבקשה שה-endpoint המותאם שלך מצפה לו.",
+ "options": {
+ "openai": "תואם OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence לא זמין במכשיר הזה. נדרש Mac עם Apple Silicon שמריץ macOS Tahoe (26.0) ומעלה, עם Apple Intelligence מופעל בהגדרות המערכת."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "כתובת URL בסיסית",
"description": "כתובת ה-API הבסיסית עבור הספק הנבחר. רק ספק מותאם אישית ניתן לעריכה.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "מפתח API",
diff --git a/src/i18n/locales/hi/translation.json b/src/i18n/locales/hi/translation.json
index 1397efef..fb5bcc25 100644
--- a/src/i18n/locales/hi/translation.json
+++ b/src/i18n/locales/hi/translation.json
@@ -414,10 +414,18 @@
"title": "हॉटकी"
},
"api": {
- "title": "API (OpenAI संगत)",
+ "title": "API",
"provider": {
"title": "प्रोवाइडर",
- "description": "कोई OpenAI-संगत प्रोवाइडर चुनें."
+ "description": "कोई OpenAI-संगत या Anthropic-संगत प्रोवाइडर चुनें."
+ },
+ "apiFormat": {
+ "title": "API फ़ॉर्मेट",
+ "description": "वह अनुरोध फ़ॉर्मेट जो आपके कस्टम एंडपॉइंट को चाहिए.",
+ "options": {
+ "openai": "OpenAI संगत (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence इस डिवाइस पर उपलब्ध नहीं है. इसके लिए macOS Tahoe (26.0) या उसके बाद का वर्शन चलाने वाला Apple Silicon Mac चाहिए, जिसमें System Settings में Apple Intelligence चालू हो."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "बेस URL",
"description": "चुने गए प्रोवाइडर के लिए API बेस URL. केवल कस्टम प्रोवाइडर में बदलाव किया जा सकता है.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API कुंजी",
diff --git a/src/i18n/locales/id/translation.json b/src/i18n/locales/id/translation.json
index 04793263..eb0c072f 100644
--- a/src/i18n/locales/id/translation.json
+++ b/src/i18n/locales/id/translation.json
@@ -414,10 +414,18 @@
"title": "Pintasan"
},
"api": {
- "title": "API (Kompatibel dengan OpenAI)",
+ "title": "API",
"provider": {
"title": "Penyedia",
- "description": "Pilih penyedia yang kompatibel dengan OpenAI."
+ "description": "Pilih penyedia yang kompatibel dengan OpenAI atau Anthropic."
+ },
+ "apiFormat": {
+ "title": "Format API",
+ "description": "Format permintaan yang diharapkan oleh endpoint kustom Anda.",
+ "options": {
+ "openai": "Kompatibel dengan OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence tidak tersedia di perangkat ini. Memerlukan Mac Apple Silicon yang menjalankan macOS Tahoe (26.0) atau yang lebih baru dengan Apple Intelligence diaktifkan di Pengaturan Sistem."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "URL Dasar",
"description": "URL dasar API untuk penyedia yang dipilih. Hanya penyedia kustom yang dapat diedit.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "Kunci API",
diff --git a/src/i18n/locales/it/translation.json b/src/i18n/locales/it/translation.json
index 7ee19417..7a2d20f4 100644
--- a/src/i18n/locales/it/translation.json
+++ b/src/i18n/locales/it/translation.json
@@ -414,10 +414,18 @@
"title": "Tasto di scelta rapida"
},
"api": {
- "title": "API (Compatibile con OpenAI)",
+ "title": "API",
"provider": {
"title": "Provider",
- "description": "Seleziona un provider compatibile con OpenAI."
+ "description": "Seleziona un provider compatibile con OpenAI o Anthropic."
+ },
+ "apiFormat": {
+ "title": "Formato API",
+ "description": "Formato della richiesta previsto dal tuo endpoint personalizzato.",
+ "options": {
+ "openai": "Compatibile con OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence non è disponibile su questo dispositivo. Necessita di un Mac con Apple Silicon e macOS Tahoe (26.0) o successivi con Apple Intelligence abilitata nelle Impostazioni di Sistema."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "URL Base",
"description": "URL di base per l'API del provider selezionato. Solo per i provider personalizzati.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "Chiave API",
diff --git a/src/i18n/locales/ja/translation.json b/src/i18n/locales/ja/translation.json
index ee580764..6e535782 100644
--- a/src/i18n/locales/ja/translation.json
+++ b/src/i18n/locales/ja/translation.json
@@ -414,10 +414,18 @@
"title": "ショートカット"
},
"api": {
- "title": "API (OpenAI 互換)",
+ "title": "API",
"provider": {
"title": "プロバイダー",
- "description": "OpenAI 互換のプロバイダーを選択。"
+ "description": "OpenAI 互換または Anthropic 互換のプロバイダーを選択。"
+ },
+ "apiFormat": {
+ "title": "API 形式",
+ "description": "カスタムエンドポイントが期待するリクエスト形式。",
+ "options": {
+ "openai": "OpenAI 互換 (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "このデバイスでは Apple Intelligence を利用できません。macOS Tahoe (26.0) 以降を実行し、システム設定で Apple Intelligence が有効になっている Apple Silicon Mac が必要です。"
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "ベース URL",
"description": "選択したプロバイダーの API ベース URL。カスタムプロバイダーのみ編集可能。",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API キー",
diff --git a/src/i18n/locales/ko/translation.json b/src/i18n/locales/ko/translation.json
index 9f9b3fd3..e9ac52ce 100644
--- a/src/i18n/locales/ko/translation.json
+++ b/src/i18n/locales/ko/translation.json
@@ -414,10 +414,18 @@
"title": "단축키"
},
"api": {
- "title": "API (OpenAI 호환)",
+ "title": "API",
"provider": {
"title": "제공자",
- "description": "OpenAI 호환 제공자를 선택하세요."
+ "description": "OpenAI 또는 Anthropic 호환 제공자를 선택하세요."
+ },
+ "apiFormat": {
+ "title": "API 형식",
+ "description": "사용자 정의 엔드포인트에서 예상하는 요청 형식입니다.",
+ "options": {
+ "openai": "OpenAI 호환 (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "이 기기에서는 Apple Intelligence를 사용할 수 없습니다. macOS Tahoe (26.0) 이상을 실행하고 시스템 설정에서 Apple Intelligence가 활성화된 Apple Silicon Mac이 필요합니다."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "기본 URL",
"description": "선택한 제공자의 API 기본 URL입니다. 사용자 정의 제공자만 편집할 수 있습니다.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API 키",
diff --git a/src/i18n/locales/ne/translation.json b/src/i18n/locales/ne/translation.json
index 8654dbc1..4bed97bf 100644
--- a/src/i18n/locales/ne/translation.json
+++ b/src/i18n/locales/ne/translation.json
@@ -414,10 +414,18 @@
"title": "हटकी"
},
"api": {
- "title": "API (OpenAI अनुकूल)",
+ "title": "API",
"provider": {
"title": "प्रदायक",
- "description": "OpenAI-अनुकूल प्रदायक चयन गर्नुहोस्।"
+ "description": "OpenAI-अनुकूल वा Anthropic-अनुकूल प्रदायक चयन गर्नुहोस्।"
+ },
+ "apiFormat": {
+ "title": "API ढाँचा",
+ "description": "तपाईंको कस्टम इन्डपोइन्टले अपेक्षा गर्ने अनुरोध ढाँचा।",
+ "options": {
+ "openai": "OpenAI अनुकूल (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "यो डिभाइसमा Apple Intelligence उपलब्ध छैन। macOS Tahoe (26.0) वा पछिको संस्करण चलिरहेको र System Settings मा Apple Intelligence सक्षम गरिएको Apple Silicon Mac आवश्यक छ।"
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "आधार URL",
"description": "चयन गरिएको प्रदायकका लागि API आधार URL। कस्टम प्रदायक मात्र सम्पादन गर्न सकिन्छ।",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API कुञ्जी",
diff --git a/src/i18n/locales/nl/translation.json b/src/i18n/locales/nl/translation.json
index efe20a69..c993fd3a 100644
--- a/src/i18n/locales/nl/translation.json
+++ b/src/i18n/locales/nl/translation.json
@@ -414,10 +414,18 @@
"title": "Sneltoets"
},
"api": {
- "title": "API (OpenAI-compatibel)",
+ "title": "API",
"provider": {
"title": "Provider",
- "description": "Selecteer een OpenAI-compatibele provider."
+ "description": "Selecteer een OpenAI- of Anthropic-compatibele provider."
+ },
+ "apiFormat": {
+ "title": "API-indeling",
+ "description": "Verzoekindeling die door je aangepaste eindpunt wordt verwacht.",
+ "options": {
+ "openai": "OpenAI-compatibel (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence is niet beschikbaar op dit apparaat. Vereist een Apple Silicon Mac met macOS Tahoe (26.0) of nieuwer waarop Apple Intelligence is ingeschakeld via de Systeeminstellingen."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Basis-URL",
"description": "API-basis-URL voor de geselecteerde provider. Alleen de aangepaste provider kan worden bewerkt.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API-sleutel",
diff --git a/src/i18n/locales/pl/translation.json b/src/i18n/locales/pl/translation.json
index f9a40d33..c1dce5c1 100644
--- a/src/i18n/locales/pl/translation.json
+++ b/src/i18n/locales/pl/translation.json
@@ -414,10 +414,18 @@
"title": "Skrót klawiszowy"
},
"api": {
- "title": "API (zgodne z OpenAI)",
+ "title": "API",
"provider": {
"title": "Dostawca",
- "description": "Wybierz dostawcę zgodnego z OpenAI."
+ "description": "Wybierz dostawcę zgodnego z OpenAI lub Anthropic."
+ },
+ "apiFormat": {
+ "title": "Format API",
+ "description": "Format żądania wymagany przez Twój niestandardowy endpoint.",
+ "options": {
+ "openai": "Zgodne z OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence nie jest dostępne na tym urządzeniu. Wymaga komputera Mac z Apple Silicon i systemem macOS Tahoe (26.0) lub nowszym z włączonym Apple Intelligence w Ustawieniach systemowych."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Adres bazowy",
"description": "Bazowy adres API dla wybranego dostawcy. Tylko dostawca niestandardowy może być edytowany.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "Klucz API",
diff --git a/src/i18n/locales/pt/translation.json b/src/i18n/locales/pt/translation.json
index 97916a8e..f9203a22 100644
--- a/src/i18n/locales/pt/translation.json
+++ b/src/i18n/locales/pt/translation.json
@@ -414,10 +414,18 @@
"title": "Tecla de atalho"
},
"api": {
- "title": "API (Compatível com OpenAI)",
+ "title": "API",
"provider": {
"title": "Provedor",
- "description": "Selecione um provedor compatível com OpenAI."
+ "description": "Selecione um provedor compatível com OpenAI ou Anthropic."
+ },
+ "apiFormat": {
+ "title": "Formato da API",
+ "description": "Formato de requisição esperado pelo seu endpoint personalizado.",
+ "options": {
+ "openai": "Compatível com OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence não está disponível neste dispositivo. Requer um Mac Apple Silicon executando macOS Tahoe (26.0) ou posterior com Apple Intelligence habilitado nas Configurações do Sistema."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "URL Base",
"description": "URL base da API para o provedor selecionado. Apenas o provedor personalizado pode ser editado.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "Chave da API",
diff --git a/src/i18n/locales/ru/translation.json b/src/i18n/locales/ru/translation.json
index bf5b3c43..99831a80 100644
--- a/src/i18n/locales/ru/translation.json
+++ b/src/i18n/locales/ru/translation.json
@@ -414,10 +414,18 @@
"title": "Горячая клавиша"
},
"api": {
- "title": "API (совместимый с OpenAI)",
+ "title": "API",
"provider": {
"title": "Поставщик",
- "description": "Выберите поставщика, совместимого с OpenAI."
+ "description": "Выберите поставщика, совместимого с OpenAI или Anthropic."
+ },
+ "apiFormat": {
+ "title": "Формат API",
+ "description": "Формат запроса, ожидаемый вашей пользовательской конечной точкой.",
+ "options": {
+ "openai": "Совместимый с OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence недоступен на этом устройстве. Требуется Apple Silicon Mac под управлением macOS Tahoe (26.0) или более поздней версии с включенным Apple Intelligence в настройках системы."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Базовый URL",
"description": "Базовый URL-адрес API для выбранного провайдера. Редактировать можно только настраиваемого поставщика.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API-ключ",
diff --git a/src/i18n/locales/sv/translation.json b/src/i18n/locales/sv/translation.json
index 68f39f53..01c9fb3c 100644
--- a/src/i18n/locales/sv/translation.json
+++ b/src/i18n/locales/sv/translation.json
@@ -414,10 +414,18 @@
"title": "Snabbkommando"
},
"api": {
- "title": "API (OpenAI-kompatibelt)",
+ "title": "API",
"provider": {
"title": "Leverantör",
- "description": "Välj en OpenAI-kompatibel leverantör."
+ "description": "Välj en OpenAI- eller Anthropic-kompatibel leverantör."
+ },
+ "apiFormat": {
+ "title": "API-format",
+ "description": "Det förfrågningsformat som din anpassade slutpunkt förväntar sig.",
+ "options": {
+ "openai": "OpenAI-kompatibelt (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence är inte tillgängligt på den här enheten. Kräver en Apple Silicon Mac som kör macOS Tahoe (26.0) eller senare med Apple Intelligence aktiverat i systeminställningarna."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Bas-URL",
"description": "API-bas-URL för den valda leverantören. Endast den anpassade leverantören kan redigeras.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API-nyckel",
diff --git a/src/i18n/locales/tr/translation.json b/src/i18n/locales/tr/translation.json
index d8375de9..9b752e24 100644
--- a/src/i18n/locales/tr/translation.json
+++ b/src/i18n/locales/tr/translation.json
@@ -414,10 +414,18 @@
"title": "Kısayol Tuşu"
},
"api": {
- "title": "API (OpenAI Uyumlu)",
+ "title": "API",
"provider": {
"title": "Sağlayıcı",
- "description": "OpenAI uyumlu bir sağlayıcı seçin."
+ "description": "OpenAI veya Anthropic uyumlu bir sağlayıcı seçin."
+ },
+ "apiFormat": {
+ "title": "API Biçimi",
+ "description": "Özel uç noktanızın beklediği istek biçimi.",
+ "options": {
+ "openai": "OpenAI Uyumlu (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence bu cihazda kullanılamıyor. macOS Tahoe (26.0) veya üzeri ve Sistem Ayarları'nda Apple Intelligence etkin olan bir Apple Silicon Mac gerektirir."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Temel URL",
"description": "Seçili sağlayıcı için API temel URL'si. Yalnızca özel sağlayıcı düzenlenebilir.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API Anahtarı",
diff --git a/src/i18n/locales/uk/translation.json b/src/i18n/locales/uk/translation.json
index 7ba5ea91..a6b80fba 100644
--- a/src/i18n/locales/uk/translation.json
+++ b/src/i18n/locales/uk/translation.json
@@ -414,10 +414,18 @@
"title": "Гаряча клавіша"
},
"api": {
- "title": "API (сумісний з OpenAI)",
+ "title": "API",
"provider": {
"title": "Провайдер",
- "description": "Оберіть OpenAI-сумісного провайдера"
+ "description": "Оберіть OpenAI- або Anthropic-сумісного провайдера"
+ },
+ "apiFormat": {
+ "title": "Формат API",
+ "description": "Формат запиту, який очікує ваш ендпоінт.",
+ "options": {
+ "openai": "Сумісний з OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence недоступний на цьому пристрої. Потрібен Mac з Apple Silicon під управлінням macOS Tahoe (26.0) або новіше з увімкненим Apple Intelligence в Системних налаштуваннях."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "Базова URL-адреса",
"description": "Базова URL-адреса API для обраного провайдера. Лише власний провайдер можна редагувати.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API-ключ",
diff --git a/src/i18n/locales/vi/translation.json b/src/i18n/locales/vi/translation.json
index 01acfadc..a1041006 100644
--- a/src/i18n/locales/vi/translation.json
+++ b/src/i18n/locales/vi/translation.json
@@ -414,10 +414,18 @@
"title": "Phím tắt"
},
"api": {
- "title": "API (Tương thích OpenAI)",
+ "title": "API",
"provider": {
"title": "Nhà cung cấp",
- "description": "Chọn một nhà cung cấp tương thích OpenAI."
+ "description": "Chọn một nhà cung cấp tương thích OpenAI hoặc Anthropic."
+ },
+ "apiFormat": {
+ "title": "Định dạng API",
+ "description": "Định dạng yêu cầu mà điểm cuối tùy chỉnh của bạn cần.",
+ "options": {
+ "openai": "Tương thích OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence không khả dụng trên thiết bị này. Yêu cầu Mac Apple Silicon chạy macOS Tahoe (26.0) trở lên với Apple Intelligence được bật trong Cài đặt Hệ thống."
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "URL cơ sở",
"description": "URL cơ sở API cho nhà cung cấp đã chọn. Chỉ có thể chỉnh sửa nhà cung cấp tùy chỉnh.",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "Khóa API",
diff --git a/src/i18n/locales/zh-TW/translation.json b/src/i18n/locales/zh-TW/translation.json
index 0401459b..979d31ac 100644
--- a/src/i18n/locales/zh-TW/translation.json
+++ b/src/i18n/locales/zh-TW/translation.json
@@ -414,10 +414,18 @@
"title": "快捷鍵"
},
"api": {
- "title": "API(相容 OpenAI)",
+ "title": "API",
"provider": {
"title": "供應商",
- "description": "選擇一個相容 OpenAI 的供應商"
+ "description": "選擇一個相容 OpenAI 或 Anthropic 的供應商"
+ },
+ "apiFormat": {
+ "title": "API 格式",
+ "description": "自訂端點所需的請求格式",
+ "options": {
+ "openai": "相容 OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence 在此裝置上不可用。需要執行 macOS Tahoe(26.0)或更高版本的 Apple Silicon Mac,並在系統設定中啟用 Apple Intelligence"
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "基礎網址",
"description": "所選供應商的 API 基礎網址,僅自訂供應商可編輯",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API 金鑰",
diff --git a/src/i18n/locales/zh/translation.json b/src/i18n/locales/zh/translation.json
index 0422d633..3bba5ae5 100644
--- a/src/i18n/locales/zh/translation.json
+++ b/src/i18n/locales/zh/translation.json
@@ -414,10 +414,18 @@
"title": "快捷键"
},
"api": {
- "title": "API(兼容 OpenAI)",
+ "title": "API",
"provider": {
"title": "提供商",
- "description": "选择一个兼容 OpenAI 的提供商。"
+ "description": "选择一个兼容 OpenAI 或 Anthropic 的提供商。"
+ },
+ "apiFormat": {
+ "title": "API 格式",
+ "description": "自定义端点期望的请求格式。",
+ "options": {
+ "openai": "兼容 OpenAI (Chat Completions)",
+ "anthropic": "Anthropic Messages"
+ }
},
"appleIntelligence": {
"unavailable": "Apple Intelligence 在此设备上不可用。需要运行 macOS Tahoe(26.0)或更高版本的 Apple Silicon Mac,并在系统设置中启用 Apple Intelligence。"
@@ -425,7 +433,8 @@
"baseUrl": {
"title": "基础 URL",
"description": "所选提供商的 API 基础 URL。仅自定义提供商可编辑。",
- "placeholder": "https://api.openai.com/v1"
+ "placeholder": "https://api.openai.com/v1",
+ "placeholderAnthropic": "https://api.anthropic.com/v1"
},
"apiKey": {
"title": "API 密钥",
diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.ts
index b3a6de61..ccefe12d 100644
--- a/src/stores/settingsStore.ts
+++ b/src/stores/settingsStore.ts
@@ -4,6 +4,7 @@ import { listen } from "@tauri-apps/api/event";
import type {
AppSettings as Settings,
AudioDevice,
+ PostProcessApiFormat,
ChineseScript,
TranscribeAcceleratorSetting,
OrtAcceleratorSetting,
@@ -53,6 +54,10 @@ interface SettingsStore {
providerId: string,
baseUrl: string,
) => Promise<void>;
+ updatePostProcessApiFormat: (
+ providerId: string,
+ apiFormat: PostProcessApiFormat,
+ ) => Promise<void>;
updatePostProcessApiKey: (
providerId: string,
apiKey: string,
@@ -553,6 +558,37 @@ export const useSettingsStore = create<SettingsStore>()(
}
},
+ updatePostProcessApiFormat: async (providerId, apiFormat) => {
+ const { setUpdating, refreshSettings } = get();
+ const updateKey = `post_process_api_format:${providerId}`;
+
+ // The format decides the auth headers, so models listed under the old
+ // format may not reflect this one - user should click refresh after
+ set((state) => ({
+ postProcessModelOptions: {
+ ...state.postProcessModelOptions,
+ [providerId]: [],
+ },
+ }));
+ setUpdating(updateKey, true);
+
+ try {
+ const result = await commands.changePostProcessApiFormatSetting(
+ providerId,
+ apiFormat,
+ );
+ if (result.status === "error") {
+ console.error("Failed to update API format:", result.error);
+ return;
+ }
+ await refreshSettings();
+ } catch (error) {
+ console.error("Failed to update post-process API format:", error);
+ } finally {
+ setUpdating(updateKey, false);
+ }
+ },
+
updatePostProcessApiKey: async (providerId, apiKey) => {
// Clear cached models when API key changes - user should click refresh after
set((state) => ({