Skip to main content

raqeem_core/
endpoint.rs

1//! The one adapter. Cohere-hosted and self-hosted vLLM differ only in URL,
2//! auth header, and model id — so a single `Endpoint` struct + two constructors
3//! covers both, and any future OpenAI-compatible backend.
4
5use crate::provider::Provider;
6
7/// Cohere's hosted transcription endpoint.
8pub const COHERE_URL: &str = "https://api.cohere.com/v2/audio/transcriptions";
9/// Default model id for the Arabic transcriber. Cohere requires a **dated** model
10/// id — undated aliases (`cohere-transcribe-arabic`) return HTTP 404 "model not
11/// found". Bump this when Cohere ships a newer dated Arabic transcription model.
12pub const DEFAULT_COHERE_MODEL: &str = "cohere-transcribe-arabic-07-2026";
13
14/// Where and how to reach a transcription server.
15#[derive(Debug, Clone)]
16pub struct Endpoint {
17    /// Full URL to POST the multipart form to.
18    pub url: String,
19    /// Bearer token, if the backend requires auth.
20    pub api_key: Option<String>,
21    /// Model id sent as the `model` form field.
22    pub model: String,
23    /// Provenance tag recorded on the transcript.
24    pub provider: Provider,
25}
26
27impl Endpoint {
28    /// Cohere's hosted API. `model` defaults to [`DEFAULT_COHERE_MODEL`].
29    pub fn cohere(api_key: impl Into<String>, model: Option<String>) -> Self {
30        Endpoint {
31            url: COHERE_URL.to_string(),
32            api_key: Some(api_key.into()),
33            model: model.unwrap_or_else(|| DEFAULT_COHERE_MODEL.to_string()),
34            provider: Provider::Cohere,
35        }
36    }
37
38    /// A self-hosted OpenAI-compatible endpoint — pass the full route URL
39    /// (e.g. `http://localhost:8000/v1/audio/transcriptions`).
40    pub fn openai_compatible(
41        url: impl Into<String>,
42        model: impl Into<String>,
43        api_key: Option<String>,
44    ) -> Self {
45        Endpoint {
46            url: url.into(),
47            api_key,
48            model: model.into(),
49            provider: Provider::OpenAiCompatible,
50        }
51    }
52}