Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(voice): handle missing cloud adapter in realtime voice

Steven Enamakel0f8fce122333
diff --git a/crates/openhuman-core/src/inference/embedding_host/cloud_adapter.rs b/crates/openhuman-core/src/inference/embedding_host/cloud_adapter.rs
index 933b90b560..9ebe6fe4ce 100644
--- a/crates/openhuman-core/src/inference/embedding_host/cloud_adapter.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/cloud_adapter.rs
@@ -28,21 +28,46 @@ impl OpenHumanCloudEmbeddingModel {
dimensions: usize,
) -> Self {
let state_dir = openhuman_dir.unwrap_or_else(default_state_dir);
+ let base_url = format!(
+ "{}/openai/v1",
+ effective_api_url(&api_url).trim_end_matches('/')
+ );
+ let key_endpoint = base_url.clone();
let bearer: BearerResolver = Arc::new(move || {
+ // A stored TinyHumans API key is the bearer outright, exactly as
+ // for managed inference (`OpenHumanBackendModel::resolve_bearer`):
+ // `/openai/v1/embeddings` accepts it as `Bearer <key>`. Same
+ // plaintext guard too — never put the key on a non-HTTPS,
+ // non-loopback wire.
+ if let Some(key) =
+ crate::security::credentials::api_key::get_api_key_in(&state_dir, secrets_encrypt)
+ .map_err(|error| {
+ tinyinference_embeddings::Error::Embedding(error.to_string())
+ })?
+ {
+ if !crate::inference::provider::openhuman_backend_model::is_safe_endpoint_for_managed_bearer(
+ &key_endpoint,
+ ) {
+ return Err(tinyinference_embeddings::Error::Validation(format!(
+ "refusing to send the TinyHumans API key over a non-HTTPS, non-loopback \
+ endpoint: {key_endpoint}"
+ )));
+ }
+ log::debug!("[embeddings::cloud] authenticating with api-key");
+ return Ok(key);
+ }
let auth = AuthService::new(&state_dir, secrets_encrypt);
auth.get_provider_bearer_token(APP_SESSION_PROVIDER, None)
.map_err(|error| tinyinference_embeddings::Error::Embedding(error.to_string()))?
.filter(|token| !token.trim().is_empty())
.ok_or_else(|| {
tinyinference_embeddings::Error::Validation(
- "No backend session for cloud embeddings: log in to OpenHuman".into(),
+ "No backend session for cloud embeddings: log in to OpenHuman or set a \
+ TinyHumans API key"
+ .into(),
)
})
});
- let base_url = format!(
- "{}/openai/v1",
- effective_api_url(&api_url).trim_end_matches('/')
- );
let guard: EmbeddingEgressGuard = Arc::new(|model, _input_count| {
let egress = crate::security::egress::EgressDescriptor::embedding("cloud", model);
crate::security::egress::enforce_egress(&egress)
diff --git a/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
index 8af2195a4f..f979761d49 100644
--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
@@ -51,7 +51,7 @@ pub const PROVIDER_LABEL: &str = "OpenHuman";
/// Deliberately narrow to the managed-key bearer path: `normalize_api_base_url`
/// itself must stay permissive, because a library host's BYOK/local `api_url`
/// can legitimately be plain HTTP.
-fn is_safe_endpoint_for_managed_bearer(endpoint: &str) -> bool {
+pub(crate) fn is_safe_endpoint_for_managed_bearer(endpoint: &str) -> bool {
let Ok(url) = url::Url::parse(endpoint) else {
return false;
};
diff --git a/crates/openhuman-core/src/voice/realtime.rs b/crates/openhuman-core/src/voice/realtime.rs
index a629219a69..e0d14414ba 100644
--- a/crates/openhuman-core/src/voice/realtime.rs
+++ b/crates/openhuman-core/src/voice/realtime.rs
@@ -14,7 +14,6 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::api::config::effective_backend_api_url;
-use crate::api::jwt::get_session_token;
use crate::api::BackendOAuthClient;
use crate::config::Config;
use crate::rpc::RpcOutcome;
diff --git a/crates/openhuman-core/src/voice/reply_speech.rs b/crates/openhuman-core/src/voice/reply_speech.rs
index 0a5e7b6985..a2c7ca194a 100644
--- a/crates/openhuman-core/src/voice/reply_speech.rs
+++ b/crates/openhuman-core/src/voice/reply_speech.rs
@@ -21,7 +21,6 @@ use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use crate::api::config::effective_backend_api_url;
-use crate::api::jwt::get_session_token;
use crate::api::BackendOAuthClient;
use crate::config::Config;
use crate::rpc::RpcOutcome;