Skip to content

Commit 2331b6b

Browse files
authored
feat: upstream spec sync (#502)
* voice and voice_consent apis * types for voice and voice consents; multipart form creation * response compaction api and types * input_audio_buffer.dtmf_event_received realtime server event * memory limit in container types * reasoning effort xhigh * ImageGenUsage output_token_details * fix: remove Function before ShellCall and ShellCallOutput in Item enum in responses.rs * fix impls * update AuditLogEvent enum * doc: the GPT image models * ImageModel gpt-image-1.5 * ImageModel gpt-image-1.5 * update doc comments; update CreateVideoRequest * update video apis to match spec * more display traits for new vidoe types * updated examples/video * update EvalItemContent and types nested under it * updated spec openapi.documented.yml
1 parent c2af0c6 commit 2331b6b

File tree

24 files changed

+2769
-800
lines changed

24 files changed

+2769
-800
lines changed

async-openai/src/audio/audio_.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::{config::Config, Client, RequestOptions, Speech, Transcriptions, Translations};
1+
use crate::{config::Config, Client, RequestOptions};
2+
3+
use super::{Speech, Transcriptions, Translations, VoiceConsents, Voices};
24

35
/// Turn audio into text or text into audio.
46
/// Related guide: [Speech to text](https://platform.openai.com/docs/guides/speech-to-text)
@@ -29,4 +31,14 @@ impl<'c, C: Config> Audio<'c, C> {
2931
pub fn translation(&self) -> Translations<'_, C> {
3032
Translations::new(self.client)
3133
}
34+
35+
/// APIs in Voice Consents group.
36+
pub fn voice_consents(&self) -> VoiceConsents<'_, C> {
37+
VoiceConsents::new(self.client)
38+
}
39+
40+
/// APIs in Voices group.
41+
pub fn voices(&self) -> Voices<'_, C> {
42+
Voices::new(self.client)
43+
}
3244
}

async-openai/src/audio/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ mod audio_;
22
mod speech;
33
mod transcriptions;
44
mod translations;
5+
mod voice_consents;
6+
mod voices;
57

68
pub use audio_::*;
79
pub use speech::*;
810
pub use transcriptions::*;
911
pub use translations::*;
12+
pub use voice_consents::*;
13+
pub use voices::*;
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
use crate::{
2+
config::Config,
3+
error::OpenAIError,
4+
types::audio::{
5+
CreateVoiceConsentRequest, UpdateVoiceConsentRequest, VoiceConsentDeletedResource,
6+
VoiceConsentListResource, VoiceConsentResource,
7+
},
8+
Client, RequestOptions,
9+
};
10+
11+
/// Voice consent API group
12+
pub struct VoiceConsents<'c, C: Config> {
13+
client: &'c Client<C>,
14+
pub(crate) request_options: RequestOptions,
15+
}
16+
17+
impl<'c, C: Config> VoiceConsents<'c, C> {
18+
pub fn new(client: &'c Client<C>) -> Self {
19+
Self {
20+
client,
21+
request_options: RequestOptions::new(),
22+
}
23+
}
24+
25+
/// Upload a voice consent recording.
26+
#[crate::byot(
27+
T0 = Clone,
28+
R = serde::de::DeserializeOwned,
29+
where_clause = "reqwest::multipart::Form: crate::traits::AsyncTryFrom<T0, Error = OpenAIError>",
30+
)]
31+
pub async fn create(
32+
&self,
33+
request: CreateVoiceConsentRequest,
34+
) -> Result<VoiceConsentResource, OpenAIError> {
35+
self.client
36+
.post_form("/audio/voice_consents", request, &self.request_options)
37+
.await
38+
}
39+
40+
/// Returns a list of voice consent recordings.
41+
#[crate::byot(R = serde::de::DeserializeOwned)]
42+
pub async fn list(&self) -> Result<VoiceConsentListResource, OpenAIError> {
43+
self.client
44+
.get("/audio/voice_consents", &self.request_options)
45+
.await
46+
}
47+
48+
/// Retrieves a voice consent recording.
49+
#[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
50+
pub async fn retrieve(&self, consent_id: &str) -> Result<VoiceConsentResource, OpenAIError> {
51+
self.client
52+
.get(
53+
&format!("/audio/voice_consents/{}", consent_id),
54+
&self.request_options,
55+
)
56+
.await
57+
}
58+
59+
/// Updates a voice consent recording (metadata only).
60+
#[crate::byot(
61+
T0 = std::fmt::Display,
62+
T1 = serde::Serialize,
63+
R = serde::de::DeserializeOwned
64+
)]
65+
pub async fn update(
66+
&self,
67+
consent_id: &str,
68+
request: UpdateVoiceConsentRequest,
69+
) -> Result<VoiceConsentResource, OpenAIError> {
70+
self.client
71+
.post(
72+
&format!("/audio/voice_consents/{}", consent_id),
73+
request,
74+
&self.request_options,
75+
)
76+
.await
77+
}
78+
79+
/// Deletes a voice consent recording.
80+
#[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
81+
pub async fn delete(
82+
&self,
83+
consent_id: &str,
84+
) -> Result<VoiceConsentDeletedResource, OpenAIError> {
85+
self.client
86+
.delete(
87+
&format!("/audio/voice_consents/{}", consent_id),
88+
&self.request_options,
89+
)
90+
.await
91+
}
92+
}

async-openai/src/audio/voices.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use crate::{
2+
config::Config,
3+
error::OpenAIError,
4+
types::audio::{CreateVoiceRequest, VoiceResource},
5+
Client, RequestOptions,
6+
};
7+
8+
/// Voice API group
9+
pub struct Voices<'c, C: Config> {
10+
client: &'c Client<C>,
11+
pub(crate) request_options: RequestOptions,
12+
}
13+
14+
impl<'c, C: Config> Voices<'c, C> {
15+
pub fn new(client: &'c Client<C>) -> Self {
16+
Self {
17+
client,
18+
request_options: RequestOptions::new(),
19+
}
20+
}
21+
22+
/// Creates a custom voice.
23+
#[crate::byot(
24+
T0 = Clone,
25+
R = serde::de::DeserializeOwned,
26+
where_clause = "reqwest::multipart::Form: crate::traits::AsyncTryFrom<T0, Error = OpenAIError>",
27+
)]
28+
pub async fn create(&self, request: CreateVoiceRequest) -> Result<VoiceResource, OpenAIError> {
29+
self.client
30+
.post_form("/audio/voices", request, &self.request_options)
31+
.await
32+
}
33+
}

async-openai/src/responses/responses_.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::{
22
config::Config,
33
error::OpenAIError,
44
types::responses::{
5-
CreateResponse, DeleteResponse, Response, ResponseItemList, ResponseStream,
6-
TokenCountsBody, TokenCountsResource,
5+
CompactResource, CompactResponseRequest, CreateResponse, DeleteResponse, Response,
6+
ResponseItemList, ResponseStream, TokenCountsBody, TokenCountsResource,
77
},
88
Client, RequestOptions,
99
};
@@ -149,4 +149,18 @@ impl<'c, C: Config> Responses<'c, C> {
149149
.post("/responses/input_tokens", request, &self.request_options)
150150
.await
151151
}
152+
153+
/// Compact a conversation.
154+
///
155+
/// Learn when and how to compact long-running conversations in the
156+
/// [conversation state guide](https://platform.openai.com/docs/guides/conversation-state#managing-the-context-window).
157+
#[crate::byot(T0 = serde::Serialize, R = serde::de::DeserializeOwned)]
158+
pub async fn compact(
159+
&self,
160+
request: CompactResponseRequest,
161+
) -> Result<CompactResource, OpenAIError> {
162+
self.client
163+
.post("/responses/compact", request, &self.request_options)
164+
.await
165+
}
152166
}

async-openai/src/types/admin/audit_logs/audit_logs_.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,46 @@ pub enum AuditLogEventType {
99
ApiKeyUpdated,
1010
#[serde(rename = "api_key.deleted")]
1111
ApiKeyDeleted,
12+
#[serde(rename = "certificate.created")]
13+
CertificateCreated,
14+
#[serde(rename = "certificate.updated")]
15+
CertificateUpdated,
16+
#[serde(rename = "certificate.deleted")]
17+
CertificateDeleted,
18+
#[serde(rename = "certificates.activated")]
19+
CertificatesActivated,
20+
#[serde(rename = "certificates.deactivated")]
21+
CertificatesDeactivated,
22+
#[serde(rename = "checkpoint.permission.created")]
23+
CheckpointPermissionCreated,
24+
#[serde(rename = "checkpoint.permission.deleted")]
25+
CheckpointPermissionDeleted,
26+
#[serde(rename = "external_key.registered")]
27+
ExternalKeyRegistered,
28+
#[serde(rename = "external_key.removed")]
29+
ExternalKeyRemoved,
30+
#[serde(rename = "group.created")]
31+
GroupCreated,
32+
#[serde(rename = "group.updated")]
33+
GroupUpdated,
34+
#[serde(rename = "group.deleted")]
35+
GroupDeleted,
1236
#[serde(rename = "invite.sent")]
1337
InviteSent,
1438
#[serde(rename = "invite.accepted")]
1539
InviteAccepted,
1640
#[serde(rename = "invite.deleted")]
1741
InviteDeleted,
42+
#[serde(rename = "ip_allowlist.created")]
43+
IpAllowlistCreated,
44+
#[serde(rename = "ip_allowlist.updated")]
45+
IpAllowlistUpdated,
46+
#[serde(rename = "ip_allowlist.deleted")]
47+
IpAllowlistDeleted,
48+
#[serde(rename = "ip_allowlist.config.activated")]
49+
IpAllowlistConfigActivated,
50+
#[serde(rename = "ip_allowlist.config.deactivated")]
51+
IpAllowlistConfigDeactivated,
1852
#[serde(rename = "login.succeeded")]
1953
LoginSucceeded,
2054
#[serde(rename = "login.failed")]
@@ -31,6 +65,34 @@ pub enum AuditLogEventType {
3165
ProjectUpdated,
3266
#[serde(rename = "project.archived")]
3367
ProjectArchived,
68+
#[serde(rename = "project.deleted")]
69+
ProjectDeleted,
70+
#[serde(rename = "rate_limit.updated")]
71+
RateLimitUpdated,
72+
#[serde(rename = "rate_limit.deleted")]
73+
RateLimitDeleted,
74+
#[serde(rename = "resource.deleted")]
75+
ResourceDeleted,
76+
#[serde(rename = "tunnel.created")]
77+
TunnelCreated,
78+
#[serde(rename = "tunnel.updated")]
79+
TunnelUpdated,
80+
#[serde(rename = "tunnel.deleted")]
81+
TunnelDeleted,
82+
#[serde(rename = "role.created")]
83+
RoleCreated,
84+
#[serde(rename = "role.updated")]
85+
RoleUpdated,
86+
#[serde(rename = "role.deleted")]
87+
RoleDeleted,
88+
#[serde(rename = "role.assignment.created")]
89+
RoleAssignmentCreated,
90+
#[serde(rename = "role.assignment.deleted")]
91+
RoleAssignmentDeleted,
92+
#[serde(rename = "scim.enabled")]
93+
ScimEnabled,
94+
#[serde(rename = "scim.disabled")]
95+
ScimDisabled,
3496
#[serde(rename = "service_account.created")]
3597
ServiceAccountCreated,
3698
#[serde(rename = "service_account.updated")]

async-openai/src/types/audio/audio_.rs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,107 @@ pub struct CreateTranslationResponseVerboseJson {
446446
pub struct CreateSpeechResponse {
447447
pub bytes: Bytes,
448448
}
449+
450+
/// A consent recording used to authorize creation of a custom voice.
451+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
452+
pub struct VoiceConsentResource {
453+
/// The object type, which is always `audio.voice_consent`.
454+
pub object: String,
455+
/// The consent recording identifier.
456+
pub id: String,
457+
/// The label provided when the consent recording was uploaded.
458+
pub name: String,
459+
/// The BCP 47 language tag for the consent phrase (for example, `en-US`).
460+
pub language: String,
461+
/// The Unix timestamp (in seconds) for when the consent recording was created.
462+
pub created_at: u64,
463+
}
464+
465+
/// Request to create a voice consent recording.
466+
#[derive(Clone, Default, Debug, Builder, PartialEq)]
467+
#[builder(name = "CreateVoiceConsentRequestArgs")]
468+
#[builder(pattern = "mutable")]
469+
#[builder(setter(into, strip_option), default)]
470+
#[builder(derive(Debug))]
471+
#[builder(build_fn(error = "OpenAIError"))]
472+
pub struct CreateVoiceConsentRequest {
473+
/// The label to use for this consent recording.
474+
pub name: String,
475+
/// The consent audio recording file. Maximum size is 10 MiB.
476+
/// Supported MIME types: `audio/mpeg`, `audio/wav`, `audio/x-wav`, `audio/ogg`,
477+
/// `audio/aac`, `audio/flac`, `audio/webm`, `audio/mp4`.
478+
pub recording: AudioInput,
479+
/// The BCP 47 language tag for the consent phrase (for example, `en-US`).
480+
pub language: String,
481+
}
482+
483+
/// Request to update a voice consent recording (metadata only).
484+
#[derive(Clone, Serialize, Default, Debug, Deserialize, Builder, PartialEq)]
485+
#[builder(name = "UpdateVoiceConsentRequestArgs")]
486+
#[builder(pattern = "mutable")]
487+
#[builder(setter(into, strip_option), default)]
488+
#[builder(derive(Debug))]
489+
#[builder(build_fn(error = "OpenAIError"))]
490+
pub struct UpdateVoiceConsentRequest {
491+
/// The updated label for this consent recording.
492+
pub name: String,
493+
}
494+
495+
/// The voice consent deletion object.
496+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
497+
pub struct VoiceConsentDeletedResource {
498+
/// The consent recording identifier.
499+
pub id: String,
500+
/// The object type, which is always `audio.voice_consent`.
501+
pub object: String,
502+
/// Whether the consent recording was deleted.
503+
pub deleted: bool,
504+
}
505+
506+
/// The voice consent list object.
507+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
508+
pub struct VoiceConsentListResource {
509+
/// The object type, which is always `list`.
510+
pub object: String,
511+
/// The list of voice consent recordings.
512+
pub data: Vec<VoiceConsentResource>,
513+
/// The ID of the first voice consent recording in the list.
514+
#[serde(skip_serializing_if = "Option::is_none")]
515+
pub first_id: Option<String>,
516+
/// The ID of the last voice consent recording in the list.
517+
#[serde(skip_serializing_if = "Option::is_none")]
518+
pub last_id: Option<String>,
519+
/// Whether there are more voice consent recordings available.
520+
pub has_more: bool,
521+
}
522+
523+
/// A custom voice that can be used for audio output.
524+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
525+
pub struct VoiceResource {
526+
/// The object type, which is always `audio.voice`.
527+
pub object: String,
528+
/// The voice identifier, which can be referenced in API endpoints.
529+
pub id: String,
530+
/// The name of the voice.
531+
pub name: String,
532+
/// The Unix timestamp (in seconds) for when the voice was created.
533+
pub created_at: u64,
534+
}
535+
536+
/// Request to create a custom voice.
537+
#[derive(Clone, Default, Debug, Builder, PartialEq)]
538+
#[builder(name = "CreateVoiceRequestArgs")]
539+
#[builder(pattern = "mutable")]
540+
#[builder(setter(into, strip_option), default)]
541+
#[builder(derive(Debug))]
542+
#[builder(build_fn(error = "OpenAIError"))]
543+
pub struct CreateVoiceRequest {
544+
/// The name of the new voice.
545+
pub name: String,
546+
/// The sample audio recording file. Maximum size is 10 MiB.
547+
/// Supported MIME types: `audio/mpeg`, `audio/wav`, `audio/x-wav`, `audio/ogg`,
548+
/// `audio/aac`, `audio/flac`, `audio/webm`, `audio/mp4`.
549+
pub audio_sample: AudioInput,
550+
/// The consent recording ID (for example, `cons_1234`).
551+
pub consent: String,
552+
}

0 commit comments

Comments
 (0)