Skip to content

Commit d1f66a7

Browse files
author
janligudzinski
committed
use string response body type, add hangup endpoint, add notes on reject
call endpoint (tldr: useless)
1 parent 611f402 commit d1f66a7

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/v1/api.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -802,13 +802,30 @@ impl OpenAIClient {
802802
call_id: &str,
803803
accept: AcceptCallRequest,
804804
) -> Result<(), APIError> {
805-
self.post::<()>(&format!("realtime/calls/{call_id}/accept"), &accept)
805+
// /realtime/calls endpoints return empty strings on success
806+
self.post::<String>(&format!("realtime/calls/{call_id}/accept"), &accept)
806807
.await?;
807808
Ok(())
808809
}
809810

811+
pub async fn hangup_call(&mut self, call_id: &str) -> Result<(), APIError> {
812+
// /realtime/calls endpoints return empty strings on success
813+
self.post::<String>(&format!("realtime/calls/{call_id}/hangup"), &())
814+
.await?;
815+
Ok(())
816+
}
817+
818+
/// Note that `reject_call` is very poorly documented and seems to be non-functional even in the GA release as of 2025-09-11:
819+
///
820+
/// - it returns a 404 if there is no session associated with the call (ie. it hasn't been `accept`ed yet)
821+
/// - it returns a 500 if there *is* one
822+
/// - in neither case does the call actually end
823+
///
824+
/// Per https://community.openai.com/t/how-can-i-programatically-end-a-gpt-realtime-sip-call/1355362 a `hangup` method exists, not documented elsewhere;
825+
/// a sensible workaround is to `accept` the call and immediately `hangup`. See `hangup_call`.
810826
pub async fn reject_call(&mut self, call_id: &str) -> Result<(), APIError> {
811-
self.post::<()>(&format!("realtime/calls/{call_id}/reject"), &())
827+
// ditto WRT successful body
828+
self.post::<String>(&format!("realtime/calls/{call_id}/reject"), &())
812829
.await?;
813830
Ok(())
814831
}
@@ -818,7 +835,8 @@ impl OpenAIClient {
818835
call_id: &str,
819836
refer: ReferCallRequest,
820837
) -> Result<(), APIError> {
821-
self.post::<()>(&format!("realtime/calls/{call_id}/refer"), &refer)
838+
// ditto WRT successful body
839+
self.post::<String>(&format!("realtime/calls/{call_id}/refer"), &refer)
822840
.await?;
823841
Ok(())
824842
}

0 commit comments

Comments
 (0)