Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .castiron.stats.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
schema_version: 1
generation_id: cf94c82f-0604-4dfc-aff0-cec482e84953
openapi_spec_hash: ce912f79d7f8cb19a7a515513c214b8a
openapi_transformed_spec_hash: 352b5a7a028f990b6475b6593e381eee
config_hash: dde98d9c41cd6f4163320f92c70f83e6
codegen_sha: 326831af0c0fdf859335a189df2b6716e4b605d4
codegen_hash: 00e7f6a53e1a6a1adf02385bc368fce999fdd775d1f1c28615f790c7a4109ad0
public_codegen_sha: c2abe7c282c83c8fb9a7330254235c20b67a2b10
generation_id: 8e5ebfdb-d6fd-41d4-9173-a575e6ba13fc
openapi_spec_hash: 8c73dea75f8570b7ea967542dafa0b0f
openapi_transformed_spec_hash: 19d647b4e088bfa2499083e65eacd54e
config_hash: ad0fbf2fbcf7981fe7a9910664285991
codegen_sha: 9244e44f047f4d2a30e58bf5423011673623ce81
codegen_hash: 391329cd5b43dc65c96676993a33fa22103908dd8b8e2f3cf461a837b31df84b
public_codegen_sha: 1252578bddc8b8637004578d7a16f3c8ee7ee22e
206 changes: 173 additions & 33 deletions api_reference/openapi.transformed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,64 @@ paths:
schema:
type: string
format: binary
audio/mpeg:
schema:
type: string
format: binary
audio/aac:
schema:
type: string
format: binary
audio/opus:
schema:
type: string
format: binary
audio/flac:
schema:
type: string
format: binary
audio/pcm:
schema:
type: string
format: binary
audio/wav:
schema:
type: string
format: binary
text/event-stream:
schema:
$ref: '#/components/schemas/CreateSpeechResponseStreamEvent'
'400':
description: Invalid speech request, input, output format, or voice.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
text/plain:
schema:
type: string
description: JSON-encoded error text containing an error object and the HTTP status.
'403':
description: Access to a personal API organization is blocked by the organization policy.
content:
text/plain:
schema:
type: string
description: JSON-encoded error text containing an error object and the HTTP status.
'429':
$ref: '#/components/responses/InferenceRateLimited'
'500':
description: The voice or speech audio could not be processed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'503':
$ref: '#/components/responses/InferenceServiceUnavailable'
x-oaiMeta:
Expand Down Expand Up @@ -694,7 +747,8 @@ paths:
Transcribes audio into the input language.

Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
format, or a stream of transcript events.
format, plain text in `text`, `srt`, or `vtt` format, or a stream of transcript
events. Supported formats depend on the model.
requestBody:
required: true
content:
Expand All @@ -710,16 +764,58 @@ paths:
anyOf:
- $ref: '#/components/schemas/CreateTranscriptionResponseJson'
- $ref: '#/components/schemas/CreateTranscriptionResponseDiarizedJson'
x-stainless-skip:
- go
- $ref: '#/components/schemas/CreateTranscriptionResponseVerboseJson'
discriminator:
propertyName: task
text/plain:
schema:
type: string
text/event-stream:
schema:
$ref: '#/components/schemas/CreateTranscriptionResponseStreamEvent'
'400':
description: Invalid audio input or request parameters.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
text/plain:
schema:
type: string
description: JSON-encoded error text containing an error object and the HTTP status.
'403':
description: Access to a personal API organization is blocked by the organization policy.
content:
text/plain:
schema:
type: string
description: JSON-encoded error text containing an error object and the HTTP status.
'413':
description: The audio request exceeds the supported size limit.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'429':
$ref: '#/components/responses/InferenceRateLimited'
'500':
description: The audio could not be processed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'502':
description: The upstream audio service connection failed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'503':
$ref: '#/components/responses/InferenceServiceUnavailable'
x-oaiMeta:
Expand Down Expand Up @@ -1271,8 +1367,52 @@ paths:
- $ref: '#/components/schemas/CreateTranslationResponseVerboseJson'
x-stainless-skip:
- go
text/plain:
schema:
type: string
'400':
description: Invalid audio input or request parameters.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
text/plain:
schema:
type: string
description: JSON-encoded error text containing an error object and the HTTP status.
'403':
description: Access to a personal API organization is blocked by the organization policy.
content:
text/plain:
schema:
type: string
description: JSON-encoded error text containing an error object and the HTTP status.
'413':
description: The audio request exceeds the supported size limit.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'429':
$ref: '#/components/responses/InferenceRateLimited'
'500':
description: The audio could not be processed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'502':
description: The upstream audio service connection failed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'503':
$ref: '#/components/responses/InferenceServiceUnavailable'
x-oaiMeta:
Expand Down Expand Up @@ -66730,6 +66870,36 @@ components:
"type": "safety.warning_issued",
"data": {"id": "C-abc123"}
}
_MisalignmentErrorType:
anyOf:
- type: string
- type: string
enum:
- potentially_unintended_data_transfer
- potentially_unintended_data_access
- potentially_unintended_destructive_activity
- other
_MisalignmentSteer:
properties:
message:
type: string
description: The public continuation instruction.
type: object
required:
- message
MisalignmentErrorDetailsResource:
properties:
error_type:
$ref: '#/components/schemas/_MisalignmentErrorType'
description: An optional classification; clients must accept additional values.
detailed_explanation:
type: string
description: The public explanation for this block.
steer:
$ref: '#/components/schemas/_MisalignmentSteer'
description: An optional public continuation instruction.
type: object
required: []
ModerationInputType:
type: string
enum:
Expand Down Expand Up @@ -70206,36 +70376,6 @@ components:
- object
- metadata
- created_at
_MisalignmentErrorType:
anyOf:
- type: string
- type: string
enum:
- potentially_unintended_data_transfer
- potentially_unintended_data_access
- potentially_unintended_destructive_activity
- other
_MisalignmentSteer:
properties:
message:
type: string
description: The public continuation instruction.
type: object
required:
- message
MisalignmentErrorDetailsResource:
properties:
error_type:
$ref: '#/components/schemas/_MisalignmentErrorType'
description: An optional classification; clients must accept additional values.
detailed_explanation:
type: string
description: The public explanation for this block.
steer:
$ref: '#/components/schemas/_MisalignmentSteer'
description: An optional public continuation instruction.
type: object
required: []
ImageGenOutputTokensDetails:
properties:
image_tokens:
Expand Down
2 changes: 1 addition & 1 deletion examples/audio/record_and_play.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
client = OpenAI::Client.new
clip = OpenAI::LocalAudio.record(duration: 5, timeout: 10)
transcription = client.audio.transcriptions.create(model: TRANSCRIPTION_MODEL, file: clip)
puts(transcription.text)
puts(transcription.is_a?(StringIO) ? transcription.read : transcription.text)
speech = client.audio.speech.create(model: SPEECH_MODEL, voice: VOICE, input: "Recording complete.")
OpenAI::LocalAudio.play(speech, timeout: 30)
8 changes: 4 additions & 4 deletions lib/openai/resources/admin/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ module OpenAI
module Resources
class Admin
class Organization
# @return [OpenAI::Resources::Admin::Organization::ExternalStorage]
attr_reader :external_storage

# List user actions and configuration changes within this organization.
# @return [OpenAI::Resources::Admin::Organization::AuditLogs]
attr_reader :audit_logs
Expand All @@ -32,6 +29,9 @@ class Organization
# @return [OpenAI::Resources::Admin::Organization::DataRetention]
attr_reader :data_retention

# @return [OpenAI::Resources::Admin::Organization::ExternalStorage]
attr_reader :external_storage

# @return [OpenAI::Resources::Admin::Organization::SpendLimit]
attr_reader :spend_limit

Expand All @@ -49,7 +49,6 @@ class Organization
# @param client [OpenAI::Client]
def initialize(client:)
@client = client
@external_storage = OpenAI::Resources::Admin::Organization::ExternalStorage.new(client: client)
@audit_logs = OpenAI::Resources::Admin::Organization::AuditLogs.new(client: client)
@admin_api_keys = OpenAI::Resources::Admin::Organization::AdminAPIKeys.new(client: client)
@usage = OpenAI::Resources::Admin::Organization::Usage.new(client: client)
Expand All @@ -58,6 +57,7 @@ def initialize(client:)
@groups = OpenAI::Resources::Admin::Organization::Groups.new(client: client)
@roles = OpenAI::Resources::Admin::Organization::Roles.new(client: client)
@data_retention = OpenAI::Resources::Admin::Organization::DataRetention.new(client: client)
@external_storage = OpenAI::Resources::Admin::Organization::ExternalStorage.new(client: client)
@spend_limit = OpenAI::Resources::Admin::Organization::SpendLimit.new(client: client)
@spend_alerts = OpenAI::Resources::Admin::Organization::SpendAlerts.new(client: client)
@certificates = OpenAI::Resources::Admin::Organization::Certificates.new(client: client)
Expand Down
20 changes: 16 additions & 4 deletions lib/openai/resources/audio/transcriptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class Transcriptions
# Transcribes audio into the input language.
#
# Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
# format, or a stream of transcript events.
# format, plain text in `text`, `srt`, or `vtt` format, or a stream of transcript
# events. Supported formats depend on the model.
#
# `String`, `StringIO`, and pathless `IO` inputs are sent with generic upload
# metadata. Use `OpenAI::FilePart` when you need to override the filename or
Expand Down Expand Up @@ -108,7 +109,7 @@ class Transcriptions
#
# @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
#
# @return [OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionDiarized, OpenAI::Models::Audio::TranscriptionVerbose]
# @return [OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionDiarized, OpenAI::Models::Audio::TranscriptionVerbose, StringIO]
#
# @see OpenAI::Models::Audio::TranscriptionCreateParams
def create(params)
Expand All @@ -118,12 +119,22 @@ def create(params)
raise ArgumentError.new(message)
end

body = OpenAI::Internal::Transport::RequestBodyMerge.merge(parsed, options[:extra_body])
model = case body.fetch(:response_format) { body["response_format"] }
in :verbose_json | "verbose_json"
OpenAI::UnionOf[OpenAI::Audio::TranscriptionVerbose, OpenAI::Audio::TranscriptionCreateResponse]
in :diarized_json | "diarized_json"
OpenAI::UnionOf[OpenAI::Audio::TranscriptionDiarized, OpenAI::Audio::TranscriptionCreateResponse]
else
OpenAI::Audio::TranscriptionCreateResponse
end

@client.request(
method: :post,
path: "audio/transcriptions",
headers: {"content-type" => "multipart/form-data"},
body: parsed,
model: OpenAI::Models::Audio::TranscriptionCreateResponse,
model: model,
security: {bearer_auth: true},
options: options
)
Expand All @@ -135,7 +146,8 @@ def create(params)
# Transcribes audio into the input language.
#
# Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
# format, or a stream of transcript events.
# format, plain text in `text`, `srt`, or `vtt` format, or a stream of transcript
# events. Supported formats depend on the model.
#
# `String`, `StringIO`, and pathless `IO` inputs are sent with generic upload
# metadata. Use `OpenAI::FilePart` when you need to override the filename or
Expand Down
Loading
Loading