Make SubFox production-ready with parallel translation and UI controls
This commit is contained in:
parent
c40b8bed2b
commit
2b1d05f02c
6046 changed files with 798327 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from .calls import (
|
||||
Calls,
|
||||
AsyncCalls,
|
||||
CallsWithRawResponse,
|
||||
AsyncCallsWithRawResponse,
|
||||
CallsWithStreamingResponse,
|
||||
AsyncCallsWithStreamingResponse,
|
||||
)
|
||||
from .realtime import (
|
||||
Realtime,
|
||||
AsyncRealtime,
|
||||
RealtimeWithRawResponse,
|
||||
AsyncRealtimeWithRawResponse,
|
||||
RealtimeWithStreamingResponse,
|
||||
AsyncRealtimeWithStreamingResponse,
|
||||
)
|
||||
from .client_secrets import (
|
||||
ClientSecrets,
|
||||
AsyncClientSecrets,
|
||||
ClientSecretsWithRawResponse,
|
||||
AsyncClientSecretsWithRawResponse,
|
||||
ClientSecretsWithStreamingResponse,
|
||||
AsyncClientSecretsWithStreamingResponse,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"ClientSecrets",
|
||||
"AsyncClientSecrets",
|
||||
"ClientSecretsWithRawResponse",
|
||||
"AsyncClientSecretsWithRawResponse",
|
||||
"ClientSecretsWithStreamingResponse",
|
||||
"AsyncClientSecretsWithStreamingResponse",
|
||||
"Calls",
|
||||
"AsyncCalls",
|
||||
"CallsWithRawResponse",
|
||||
"AsyncCallsWithRawResponse",
|
||||
"CallsWithStreamingResponse",
|
||||
"AsyncCallsWithStreamingResponse",
|
||||
"Realtime",
|
||||
"AsyncRealtime",
|
||||
"RealtimeWithRawResponse",
|
||||
"AsyncRealtimeWithRawResponse",
|
||||
"RealtimeWithStreamingResponse",
|
||||
"AsyncRealtimeWithStreamingResponse",
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,137 @@
|
|||
# Realtime
|
||||
|
||||
Types:
|
||||
|
||||
```python
|
||||
from openai.types.realtime import (
|
||||
AudioTranscription,
|
||||
ConversationCreatedEvent,
|
||||
ConversationItem,
|
||||
ConversationItemAdded,
|
||||
ConversationItemCreateEvent,
|
||||
ConversationItemCreatedEvent,
|
||||
ConversationItemDeleteEvent,
|
||||
ConversationItemDeletedEvent,
|
||||
ConversationItemDone,
|
||||
ConversationItemInputAudioTranscriptionCompletedEvent,
|
||||
ConversationItemInputAudioTranscriptionDeltaEvent,
|
||||
ConversationItemInputAudioTranscriptionFailedEvent,
|
||||
ConversationItemInputAudioTranscriptionSegment,
|
||||
ConversationItemRetrieveEvent,
|
||||
ConversationItemTruncateEvent,
|
||||
ConversationItemTruncatedEvent,
|
||||
ConversationItemWithReference,
|
||||
InputAudioBufferAppendEvent,
|
||||
InputAudioBufferClearEvent,
|
||||
InputAudioBufferClearedEvent,
|
||||
InputAudioBufferCommitEvent,
|
||||
InputAudioBufferCommittedEvent,
|
||||
InputAudioBufferDtmfEventReceivedEvent,
|
||||
InputAudioBufferSpeechStartedEvent,
|
||||
InputAudioBufferSpeechStoppedEvent,
|
||||
InputAudioBufferTimeoutTriggered,
|
||||
LogProbProperties,
|
||||
McpListToolsCompleted,
|
||||
McpListToolsFailed,
|
||||
McpListToolsInProgress,
|
||||
NoiseReductionType,
|
||||
OutputAudioBufferClearEvent,
|
||||
RateLimitsUpdatedEvent,
|
||||
RealtimeAudioConfig,
|
||||
RealtimeAudioConfigInput,
|
||||
RealtimeAudioConfigOutput,
|
||||
RealtimeAudioFormats,
|
||||
RealtimeAudioInputTurnDetection,
|
||||
RealtimeClientEvent,
|
||||
RealtimeConversationItemAssistantMessage,
|
||||
RealtimeConversationItemFunctionCall,
|
||||
RealtimeConversationItemFunctionCallOutput,
|
||||
RealtimeConversationItemSystemMessage,
|
||||
RealtimeConversationItemUserMessage,
|
||||
RealtimeError,
|
||||
RealtimeErrorEvent,
|
||||
RealtimeFunctionTool,
|
||||
RealtimeMcpApprovalRequest,
|
||||
RealtimeMcpApprovalResponse,
|
||||
RealtimeMcpListTools,
|
||||
RealtimeMcpProtocolError,
|
||||
RealtimeMcpToolCall,
|
||||
RealtimeMcpToolExecutionError,
|
||||
RealtimeMcphttpError,
|
||||
RealtimeResponse,
|
||||
RealtimeResponseCreateAudioOutput,
|
||||
RealtimeResponseCreateMcpTool,
|
||||
RealtimeResponseCreateParams,
|
||||
RealtimeResponseStatus,
|
||||
RealtimeResponseUsage,
|
||||
RealtimeResponseUsageInputTokenDetails,
|
||||
RealtimeResponseUsageOutputTokenDetails,
|
||||
RealtimeServerEvent,
|
||||
RealtimeSession,
|
||||
RealtimeSessionCreateRequest,
|
||||
RealtimeToolChoiceConfig,
|
||||
RealtimeToolsConfig,
|
||||
RealtimeToolsConfigUnion,
|
||||
RealtimeTracingConfig,
|
||||
RealtimeTranscriptionSessionAudio,
|
||||
RealtimeTranscriptionSessionAudioInput,
|
||||
RealtimeTranscriptionSessionAudioInputTurnDetection,
|
||||
RealtimeTranscriptionSessionCreateRequest,
|
||||
RealtimeTruncation,
|
||||
RealtimeTruncationRetentionRatio,
|
||||
ResponseAudioDeltaEvent,
|
||||
ResponseAudioDoneEvent,
|
||||
ResponseAudioTranscriptDeltaEvent,
|
||||
ResponseAudioTranscriptDoneEvent,
|
||||
ResponseCancelEvent,
|
||||
ResponseContentPartAddedEvent,
|
||||
ResponseContentPartDoneEvent,
|
||||
ResponseCreateEvent,
|
||||
ResponseCreatedEvent,
|
||||
ResponseDoneEvent,
|
||||
ResponseFunctionCallArgumentsDeltaEvent,
|
||||
ResponseFunctionCallArgumentsDoneEvent,
|
||||
ResponseMcpCallArgumentsDelta,
|
||||
ResponseMcpCallArgumentsDone,
|
||||
ResponseMcpCallCompleted,
|
||||
ResponseMcpCallFailed,
|
||||
ResponseMcpCallInProgress,
|
||||
ResponseOutputItemAddedEvent,
|
||||
ResponseOutputItemDoneEvent,
|
||||
ResponseTextDeltaEvent,
|
||||
ResponseTextDoneEvent,
|
||||
SessionCreatedEvent,
|
||||
SessionUpdateEvent,
|
||||
SessionUpdatedEvent,
|
||||
TranscriptionSessionUpdate,
|
||||
TranscriptionSessionUpdatedEvent,
|
||||
)
|
||||
```
|
||||
|
||||
## ClientSecrets
|
||||
|
||||
Types:
|
||||
|
||||
```python
|
||||
from openai.types.realtime import (
|
||||
RealtimeSessionClientSecret,
|
||||
RealtimeSessionCreateResponse,
|
||||
RealtimeTranscriptionSessionCreateResponse,
|
||||
RealtimeTranscriptionSessionTurnDetection,
|
||||
ClientSecretCreateResponse,
|
||||
)
|
||||
```
|
||||
|
||||
Methods:
|
||||
|
||||
- <code title="post /realtime/client_secrets">client.realtime.client_secrets.<a href="./src/openai/resources/realtime/client_secrets.py">create</a>(\*\*<a href="src/openai/types/realtime/client_secret_create_params.py">params</a>) -> <a href="./src/openai/types/realtime/client_secret_create_response.py">ClientSecretCreateResponse</a></code>
|
||||
|
||||
## Calls
|
||||
|
||||
Methods:
|
||||
|
||||
- <code title="post /realtime/calls">client.realtime.calls.<a href="./src/openai/resources/realtime/calls.py">create</a>(\*\*<a href="src/openai/types/realtime/call_create_params.py">params</a>) -> HttpxBinaryResponseContent</code>
|
||||
- <code title="post /realtime/calls/{call_id}/accept">client.realtime.calls.<a href="./src/openai/resources/realtime/calls.py">accept</a>(call_id, \*\*<a href="src/openai/types/realtime/call_accept_params.py">params</a>) -> None</code>
|
||||
- <code title="post /realtime/calls/{call_id}/hangup">client.realtime.calls.<a href="./src/openai/resources/realtime/calls.py">hangup</a>(call_id) -> None</code>
|
||||
- <code title="post /realtime/calls/{call_id}/refer">client.realtime.calls.<a href="./src/openai/resources/realtime/calls.py">refer</a>(call_id, \*\*<a href="src/openai/types/realtime/call_refer_params.py">params</a>) -> None</code>
|
||||
- <code title="post /realtime/calls/{call_id}/reject">client.realtime.calls.<a href="./src/openai/resources/realtime/calls.py">reject</a>(call_id, \*\*<a href="src/openai/types/realtime/call_reject_params.py">params</a>) -> None</code>
|
||||
|
|
@ -0,0 +1,782 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List, Union, Optional
|
||||
from typing_extensions import Literal
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import _legacy_response
|
||||
from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given
|
||||
from ..._utils import maybe_transform, async_maybe_transform
|
||||
from ..._compat import cached_property
|
||||
from ..._resource import SyncAPIResource, AsyncAPIResource
|
||||
from ..._response import (
|
||||
StreamedBinaryAPIResponse,
|
||||
AsyncStreamedBinaryAPIResponse,
|
||||
to_streamed_response_wrapper,
|
||||
async_to_streamed_response_wrapper,
|
||||
to_custom_streamed_response_wrapper,
|
||||
async_to_custom_streamed_response_wrapper,
|
||||
)
|
||||
from ..._base_client import make_request_options
|
||||
from ...types.realtime import (
|
||||
call_refer_params,
|
||||
call_accept_params,
|
||||
call_create_params,
|
||||
call_reject_params,
|
||||
)
|
||||
from ...types.responses.response_prompt_param import ResponsePromptParam
|
||||
from ...types.realtime.realtime_truncation_param import RealtimeTruncationParam
|
||||
from ...types.realtime.realtime_audio_config_param import RealtimeAudioConfigParam
|
||||
from ...types.realtime.realtime_tools_config_param import RealtimeToolsConfigParam
|
||||
from ...types.realtime.realtime_tracing_config_param import RealtimeTracingConfigParam
|
||||
from ...types.realtime.realtime_tool_choice_config_param import RealtimeToolChoiceConfigParam
|
||||
from ...types.realtime.realtime_session_create_request_param import RealtimeSessionCreateRequestParam
|
||||
|
||||
__all__ = ["Calls", "AsyncCalls"]
|
||||
|
||||
|
||||
class Calls(SyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> CallsWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return CallsWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> CallsWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
||||
"""
|
||||
return CallsWithStreamingResponse(self)
|
||||
|
||||
def create(
|
||||
self,
|
||||
*,
|
||||
sdp: str,
|
||||
session: RealtimeSessionCreateRequestParam | Omit = omit,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> _legacy_response.HttpxBinaryResponseContent:
|
||||
"""
|
||||
Create a new Realtime API call over WebRTC and receive the SDP answer needed to
|
||||
complete the peer connection.
|
||||
|
||||
Args:
|
||||
sdp: WebRTC Session Description Protocol (SDP) offer generated by the caller.
|
||||
|
||||
session: Realtime session object configuration.
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
extra_headers = {"Accept": "application/sdp", **(extra_headers or {})}
|
||||
return self._post(
|
||||
"/realtime/calls",
|
||||
body=maybe_transform(
|
||||
{
|
||||
"sdp": sdp,
|
||||
"session": session,
|
||||
},
|
||||
call_create_params.CallCreateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=_legacy_response.HttpxBinaryResponseContent,
|
||||
)
|
||||
|
||||
def accept(
|
||||
self,
|
||||
call_id: str,
|
||||
*,
|
||||
type: Literal["realtime"],
|
||||
audio: RealtimeAudioConfigParam | Omit = omit,
|
||||
include: List[Literal["item.input_audio_transcription.logprobs"]] | Omit = omit,
|
||||
instructions: str | Omit = omit,
|
||||
max_output_tokens: Union[int, Literal["inf"]] | Omit = omit,
|
||||
model: Union[
|
||||
str,
|
||||
Literal[
|
||||
"gpt-realtime",
|
||||
"gpt-realtime-1.5",
|
||||
"gpt-realtime-2025-08-28",
|
||||
"gpt-4o-realtime-preview",
|
||||
"gpt-4o-realtime-preview-2024-10-01",
|
||||
"gpt-4o-realtime-preview-2024-12-17",
|
||||
"gpt-4o-realtime-preview-2025-06-03",
|
||||
"gpt-4o-mini-realtime-preview",
|
||||
"gpt-4o-mini-realtime-preview-2024-12-17",
|
||||
"gpt-realtime-mini",
|
||||
"gpt-realtime-mini-2025-10-06",
|
||||
"gpt-realtime-mini-2025-12-15",
|
||||
"gpt-audio-1.5",
|
||||
"gpt-audio-mini",
|
||||
"gpt-audio-mini-2025-10-06",
|
||||
"gpt-audio-mini-2025-12-15",
|
||||
],
|
||||
]
|
||||
| Omit = omit,
|
||||
output_modalities: List[Literal["text", "audio"]] | Omit = omit,
|
||||
prompt: Optional[ResponsePromptParam] | Omit = omit,
|
||||
tool_choice: RealtimeToolChoiceConfigParam | Omit = omit,
|
||||
tools: RealtimeToolsConfigParam | Omit = omit,
|
||||
tracing: Optional[RealtimeTracingConfigParam] | Omit = omit,
|
||||
truncation: RealtimeTruncationParam | Omit = omit,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> None:
|
||||
"""
|
||||
Accept an incoming SIP call and configure the realtime session that will handle
|
||||
it.
|
||||
|
||||
Args:
|
||||
type: The type of session to create. Always `realtime` for the Realtime API.
|
||||
|
||||
audio: Configuration for input and output audio.
|
||||
|
||||
include: Additional fields to include in server outputs.
|
||||
|
||||
`item.input_audio_transcription.logprobs`: Include logprobs for input audio
|
||||
transcription.
|
||||
|
||||
instructions: The default system instructions (i.e. system message) prepended to model calls.
|
||||
This field allows the client to guide the model on desired responses. The model
|
||||
can be instructed on response content and format, (e.g. "be extremely succinct",
|
||||
"act friendly", "here are examples of good responses") and on audio behavior
|
||||
(e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
||||
instructions are not guaranteed to be followed by the model, but they provide
|
||||
guidance to the model on the desired behavior.
|
||||
|
||||
Note that the server sets default instructions which will be used if this field
|
||||
is not set and are visible in the `session.created` event at the start of the
|
||||
session.
|
||||
|
||||
max_output_tokens: Maximum number of output tokens for a single assistant response, inclusive of
|
||||
tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
||||
`inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
||||
|
||||
model: The Realtime model used for this session.
|
||||
|
||||
output_modalities: The set of modalities the model can respond with. It defaults to `["audio"]`,
|
||||
indicating that the model will respond with audio plus a transcript. `["text"]`
|
||||
can be used to make the model respond with text only. It is not possible to
|
||||
request both `text` and `audio` at the same time.
|
||||
|
||||
prompt: Reference to a prompt template and its variables.
|
||||
[Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
|
||||
|
||||
tool_choice: How the model chooses tools. Provide one of the string modes or force a specific
|
||||
function/MCP tool.
|
||||
|
||||
tools: Tools available to the model.
|
||||
|
||||
tracing: Realtime API can write session traces to the
|
||||
[Traces Dashboard](/logs?api=traces). Set to null to disable tracing. Once
|
||||
tracing is enabled for a session, the configuration cannot be modified.
|
||||
|
||||
`auto` will create a trace for the session with default values for the workflow
|
||||
name, group id, and metadata.
|
||||
|
||||
truncation: When the number of tokens in a conversation exceeds the model's input token
|
||||
limit, the conversation be truncated, meaning messages (starting from the
|
||||
oldest) will not be included in the model's context. A 32k context model with
|
||||
4,096 max output tokens can only include 28,224 tokens in the context before
|
||||
truncation occurs.
|
||||
|
||||
Clients can configure truncation behavior to truncate with a lower max token
|
||||
limit, which is an effective way to control token usage and cost.
|
||||
|
||||
Truncation will reduce the number of cached tokens on the next turn (busting the
|
||||
cache), since messages are dropped from the beginning of the context. However,
|
||||
clients can also configure truncation to retain messages up to a fraction of the
|
||||
maximum context size, which will reduce the need for future truncations and thus
|
||||
improve the cache rate.
|
||||
|
||||
Truncation can be disabled entirely, which means the server will never truncate
|
||||
but would instead return an error if the conversation exceeds the model's input
|
||||
token limit.
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
if not call_id:
|
||||
raise ValueError(f"Expected a non-empty value for `call_id` but received {call_id!r}")
|
||||
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
||||
return self._post(
|
||||
f"/realtime/calls/{call_id}/accept",
|
||||
body=maybe_transform(
|
||||
{
|
||||
"type": type,
|
||||
"audio": audio,
|
||||
"include": include,
|
||||
"instructions": instructions,
|
||||
"max_output_tokens": max_output_tokens,
|
||||
"model": model,
|
||||
"output_modalities": output_modalities,
|
||||
"prompt": prompt,
|
||||
"tool_choice": tool_choice,
|
||||
"tools": tools,
|
||||
"tracing": tracing,
|
||||
"truncation": truncation,
|
||||
},
|
||||
call_accept_params.CallAcceptParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=NoneType,
|
||||
)
|
||||
|
||||
def hangup(
|
||||
self,
|
||||
call_id: str,
|
||||
*,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> None:
|
||||
"""
|
||||
End an active Realtime API call, whether it was initiated over SIP or WebRTC.
|
||||
|
||||
Args:
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
if not call_id:
|
||||
raise ValueError(f"Expected a non-empty value for `call_id` but received {call_id!r}")
|
||||
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
||||
return self._post(
|
||||
f"/realtime/calls/{call_id}/hangup",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=NoneType,
|
||||
)
|
||||
|
||||
def refer(
|
||||
self,
|
||||
call_id: str,
|
||||
*,
|
||||
target_uri: str,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> None:
|
||||
"""
|
||||
Transfer an active SIP call to a new destination using the SIP REFER verb.
|
||||
|
||||
Args:
|
||||
target_uri: URI that should appear in the SIP Refer-To header. Supports values like
|
||||
`tel:+14155550123` or `sip:agent@example.com`.
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
if not call_id:
|
||||
raise ValueError(f"Expected a non-empty value for `call_id` but received {call_id!r}")
|
||||
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
||||
return self._post(
|
||||
f"/realtime/calls/{call_id}/refer",
|
||||
body=maybe_transform({"target_uri": target_uri}, call_refer_params.CallReferParams),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=NoneType,
|
||||
)
|
||||
|
||||
def reject(
|
||||
self,
|
||||
call_id: str,
|
||||
*,
|
||||
status_code: int | Omit = omit,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> None:
|
||||
"""
|
||||
Decline an incoming SIP call by returning a SIP status code to the caller.
|
||||
|
||||
Args:
|
||||
status_code: SIP response code to send back to the caller. Defaults to `603` (Decline) when
|
||||
omitted.
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
if not call_id:
|
||||
raise ValueError(f"Expected a non-empty value for `call_id` but received {call_id!r}")
|
||||
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
||||
return self._post(
|
||||
f"/realtime/calls/{call_id}/reject",
|
||||
body=maybe_transform({"status_code": status_code}, call_reject_params.CallRejectParams),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=NoneType,
|
||||
)
|
||||
|
||||
|
||||
class AsyncCalls(AsyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> AsyncCallsWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return AsyncCallsWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> AsyncCallsWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
||||
"""
|
||||
return AsyncCallsWithStreamingResponse(self)
|
||||
|
||||
async def create(
|
||||
self,
|
||||
*,
|
||||
sdp: str,
|
||||
session: RealtimeSessionCreateRequestParam | Omit = omit,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> _legacy_response.HttpxBinaryResponseContent:
|
||||
"""
|
||||
Create a new Realtime API call over WebRTC and receive the SDP answer needed to
|
||||
complete the peer connection.
|
||||
|
||||
Args:
|
||||
sdp: WebRTC Session Description Protocol (SDP) offer generated by the caller.
|
||||
|
||||
session: Realtime session object configuration.
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
extra_headers = {"Accept": "application/sdp", **(extra_headers or {})}
|
||||
return await self._post(
|
||||
"/realtime/calls",
|
||||
body=await async_maybe_transform(
|
||||
{
|
||||
"sdp": sdp,
|
||||
"session": session,
|
||||
},
|
||||
call_create_params.CallCreateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=_legacy_response.HttpxBinaryResponseContent,
|
||||
)
|
||||
|
||||
async def accept(
|
||||
self,
|
||||
call_id: str,
|
||||
*,
|
||||
type: Literal["realtime"],
|
||||
audio: RealtimeAudioConfigParam | Omit = omit,
|
||||
include: List[Literal["item.input_audio_transcription.logprobs"]] | Omit = omit,
|
||||
instructions: str | Omit = omit,
|
||||
max_output_tokens: Union[int, Literal["inf"]] | Omit = omit,
|
||||
model: Union[
|
||||
str,
|
||||
Literal[
|
||||
"gpt-realtime",
|
||||
"gpt-realtime-1.5",
|
||||
"gpt-realtime-2025-08-28",
|
||||
"gpt-4o-realtime-preview",
|
||||
"gpt-4o-realtime-preview-2024-10-01",
|
||||
"gpt-4o-realtime-preview-2024-12-17",
|
||||
"gpt-4o-realtime-preview-2025-06-03",
|
||||
"gpt-4o-mini-realtime-preview",
|
||||
"gpt-4o-mini-realtime-preview-2024-12-17",
|
||||
"gpt-realtime-mini",
|
||||
"gpt-realtime-mini-2025-10-06",
|
||||
"gpt-realtime-mini-2025-12-15",
|
||||
"gpt-audio-1.5",
|
||||
"gpt-audio-mini",
|
||||
"gpt-audio-mini-2025-10-06",
|
||||
"gpt-audio-mini-2025-12-15",
|
||||
],
|
||||
]
|
||||
| Omit = omit,
|
||||
output_modalities: List[Literal["text", "audio"]] | Omit = omit,
|
||||
prompt: Optional[ResponsePromptParam] | Omit = omit,
|
||||
tool_choice: RealtimeToolChoiceConfigParam | Omit = omit,
|
||||
tools: RealtimeToolsConfigParam | Omit = omit,
|
||||
tracing: Optional[RealtimeTracingConfigParam] | Omit = omit,
|
||||
truncation: RealtimeTruncationParam | Omit = omit,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> None:
|
||||
"""
|
||||
Accept an incoming SIP call and configure the realtime session that will handle
|
||||
it.
|
||||
|
||||
Args:
|
||||
type: The type of session to create. Always `realtime` for the Realtime API.
|
||||
|
||||
audio: Configuration for input and output audio.
|
||||
|
||||
include: Additional fields to include in server outputs.
|
||||
|
||||
`item.input_audio_transcription.logprobs`: Include logprobs for input audio
|
||||
transcription.
|
||||
|
||||
instructions: The default system instructions (i.e. system message) prepended to model calls.
|
||||
This field allows the client to guide the model on desired responses. The model
|
||||
can be instructed on response content and format, (e.g. "be extremely succinct",
|
||||
"act friendly", "here are examples of good responses") and on audio behavior
|
||||
(e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
||||
instructions are not guaranteed to be followed by the model, but they provide
|
||||
guidance to the model on the desired behavior.
|
||||
|
||||
Note that the server sets default instructions which will be used if this field
|
||||
is not set and are visible in the `session.created` event at the start of the
|
||||
session.
|
||||
|
||||
max_output_tokens: Maximum number of output tokens for a single assistant response, inclusive of
|
||||
tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
||||
`inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
||||
|
||||
model: The Realtime model used for this session.
|
||||
|
||||
output_modalities: The set of modalities the model can respond with. It defaults to `["audio"]`,
|
||||
indicating that the model will respond with audio plus a transcript. `["text"]`
|
||||
can be used to make the model respond with text only. It is not possible to
|
||||
request both `text` and `audio` at the same time.
|
||||
|
||||
prompt: Reference to a prompt template and its variables.
|
||||
[Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
|
||||
|
||||
tool_choice: How the model chooses tools. Provide one of the string modes or force a specific
|
||||
function/MCP tool.
|
||||
|
||||
tools: Tools available to the model.
|
||||
|
||||
tracing: Realtime API can write session traces to the
|
||||
[Traces Dashboard](/logs?api=traces). Set to null to disable tracing. Once
|
||||
tracing is enabled for a session, the configuration cannot be modified.
|
||||
|
||||
`auto` will create a trace for the session with default values for the workflow
|
||||
name, group id, and metadata.
|
||||
|
||||
truncation: When the number of tokens in a conversation exceeds the model's input token
|
||||
limit, the conversation be truncated, meaning messages (starting from the
|
||||
oldest) will not be included in the model's context. A 32k context model with
|
||||
4,096 max output tokens can only include 28,224 tokens in the context before
|
||||
truncation occurs.
|
||||
|
||||
Clients can configure truncation behavior to truncate with a lower max token
|
||||
limit, which is an effective way to control token usage and cost.
|
||||
|
||||
Truncation will reduce the number of cached tokens on the next turn (busting the
|
||||
cache), since messages are dropped from the beginning of the context. However,
|
||||
clients can also configure truncation to retain messages up to a fraction of the
|
||||
maximum context size, which will reduce the need for future truncations and thus
|
||||
improve the cache rate.
|
||||
|
||||
Truncation can be disabled entirely, which means the server will never truncate
|
||||
but would instead return an error if the conversation exceeds the model's input
|
||||
token limit.
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
if not call_id:
|
||||
raise ValueError(f"Expected a non-empty value for `call_id` but received {call_id!r}")
|
||||
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
||||
return await self._post(
|
||||
f"/realtime/calls/{call_id}/accept",
|
||||
body=await async_maybe_transform(
|
||||
{
|
||||
"type": type,
|
||||
"audio": audio,
|
||||
"include": include,
|
||||
"instructions": instructions,
|
||||
"max_output_tokens": max_output_tokens,
|
||||
"model": model,
|
||||
"output_modalities": output_modalities,
|
||||
"prompt": prompt,
|
||||
"tool_choice": tool_choice,
|
||||
"tools": tools,
|
||||
"tracing": tracing,
|
||||
"truncation": truncation,
|
||||
},
|
||||
call_accept_params.CallAcceptParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=NoneType,
|
||||
)
|
||||
|
||||
async def hangup(
|
||||
self,
|
||||
call_id: str,
|
||||
*,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> None:
|
||||
"""
|
||||
End an active Realtime API call, whether it was initiated over SIP or WebRTC.
|
||||
|
||||
Args:
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
if not call_id:
|
||||
raise ValueError(f"Expected a non-empty value for `call_id` but received {call_id!r}")
|
||||
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
||||
return await self._post(
|
||||
f"/realtime/calls/{call_id}/hangup",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=NoneType,
|
||||
)
|
||||
|
||||
async def refer(
|
||||
self,
|
||||
call_id: str,
|
||||
*,
|
||||
target_uri: str,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> None:
|
||||
"""
|
||||
Transfer an active SIP call to a new destination using the SIP REFER verb.
|
||||
|
||||
Args:
|
||||
target_uri: URI that should appear in the SIP Refer-To header. Supports values like
|
||||
`tel:+14155550123` or `sip:agent@example.com`.
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
if not call_id:
|
||||
raise ValueError(f"Expected a non-empty value for `call_id` but received {call_id!r}")
|
||||
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
||||
return await self._post(
|
||||
f"/realtime/calls/{call_id}/refer",
|
||||
body=await async_maybe_transform({"target_uri": target_uri}, call_refer_params.CallReferParams),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=NoneType,
|
||||
)
|
||||
|
||||
async def reject(
|
||||
self,
|
||||
call_id: str,
|
||||
*,
|
||||
status_code: int | Omit = omit,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> None:
|
||||
"""
|
||||
Decline an incoming SIP call by returning a SIP status code to the caller.
|
||||
|
||||
Args:
|
||||
status_code: SIP response code to send back to the caller. Defaults to `603` (Decline) when
|
||||
omitted.
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
if not call_id:
|
||||
raise ValueError(f"Expected a non-empty value for `call_id` but received {call_id!r}")
|
||||
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
||||
return await self._post(
|
||||
f"/realtime/calls/{call_id}/reject",
|
||||
body=await async_maybe_transform({"status_code": status_code}, call_reject_params.CallRejectParams),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=NoneType,
|
||||
)
|
||||
|
||||
|
||||
class CallsWithRawResponse:
|
||||
def __init__(self, calls: Calls) -> None:
|
||||
self._calls = calls
|
||||
|
||||
self.create = _legacy_response.to_raw_response_wrapper(
|
||||
calls.create,
|
||||
)
|
||||
self.accept = _legacy_response.to_raw_response_wrapper(
|
||||
calls.accept,
|
||||
)
|
||||
self.hangup = _legacy_response.to_raw_response_wrapper(
|
||||
calls.hangup,
|
||||
)
|
||||
self.refer = _legacy_response.to_raw_response_wrapper(
|
||||
calls.refer,
|
||||
)
|
||||
self.reject = _legacy_response.to_raw_response_wrapper(
|
||||
calls.reject,
|
||||
)
|
||||
|
||||
|
||||
class AsyncCallsWithRawResponse:
|
||||
def __init__(self, calls: AsyncCalls) -> None:
|
||||
self._calls = calls
|
||||
|
||||
self.create = _legacy_response.async_to_raw_response_wrapper(
|
||||
calls.create,
|
||||
)
|
||||
self.accept = _legacy_response.async_to_raw_response_wrapper(
|
||||
calls.accept,
|
||||
)
|
||||
self.hangup = _legacy_response.async_to_raw_response_wrapper(
|
||||
calls.hangup,
|
||||
)
|
||||
self.refer = _legacy_response.async_to_raw_response_wrapper(
|
||||
calls.refer,
|
||||
)
|
||||
self.reject = _legacy_response.async_to_raw_response_wrapper(
|
||||
calls.reject,
|
||||
)
|
||||
|
||||
|
||||
class CallsWithStreamingResponse:
|
||||
def __init__(self, calls: Calls) -> None:
|
||||
self._calls = calls
|
||||
|
||||
self.create = to_custom_streamed_response_wrapper(
|
||||
calls.create,
|
||||
StreamedBinaryAPIResponse,
|
||||
)
|
||||
self.accept = to_streamed_response_wrapper(
|
||||
calls.accept,
|
||||
)
|
||||
self.hangup = to_streamed_response_wrapper(
|
||||
calls.hangup,
|
||||
)
|
||||
self.refer = to_streamed_response_wrapper(
|
||||
calls.refer,
|
||||
)
|
||||
self.reject = to_streamed_response_wrapper(
|
||||
calls.reject,
|
||||
)
|
||||
|
||||
|
||||
class AsyncCallsWithStreamingResponse:
|
||||
def __init__(self, calls: AsyncCalls) -> None:
|
||||
self._calls = calls
|
||||
|
||||
self.create = async_to_custom_streamed_response_wrapper(
|
||||
calls.create,
|
||||
AsyncStreamedBinaryAPIResponse,
|
||||
)
|
||||
self.accept = async_to_streamed_response_wrapper(
|
||||
calls.accept,
|
||||
)
|
||||
self.hangup = async_to_streamed_response_wrapper(
|
||||
calls.hangup,
|
||||
)
|
||||
self.refer = async_to_streamed_response_wrapper(
|
||||
calls.refer,
|
||||
)
|
||||
self.reject = async_to_streamed_response_wrapper(
|
||||
calls.reject,
|
||||
)
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import _legacy_response
|
||||
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
||||
from ..._utils import maybe_transform, async_maybe_transform
|
||||
from ..._compat import cached_property
|
||||
from ..._resource import SyncAPIResource, AsyncAPIResource
|
||||
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
|
||||
from ..._base_client import make_request_options
|
||||
from ...types.realtime import client_secret_create_params
|
||||
from ...types.realtime.client_secret_create_response import ClientSecretCreateResponse
|
||||
|
||||
__all__ = ["ClientSecrets", "AsyncClientSecrets"]
|
||||
|
||||
|
||||
class ClientSecrets(SyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> ClientSecretsWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return ClientSecretsWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> ClientSecretsWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
||||
"""
|
||||
return ClientSecretsWithStreamingResponse(self)
|
||||
|
||||
def create(
|
||||
self,
|
||||
*,
|
||||
expires_after: client_secret_create_params.ExpiresAfter | Omit = omit,
|
||||
session: client_secret_create_params.Session | Omit = omit,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> ClientSecretCreateResponse:
|
||||
"""
|
||||
Create a Realtime client secret with an associated session configuration.
|
||||
|
||||
Client secrets are short-lived tokens that can be passed to a client app, such
|
||||
as a web frontend or mobile client, which grants access to the Realtime API
|
||||
without leaking your main API key. You can configure a custom TTL for each
|
||||
client secret.
|
||||
|
||||
You can also attach session configuration options to the client secret, which
|
||||
will be applied to any sessions created using that client secret, but these can
|
||||
also be overridden by the client connection.
|
||||
|
||||
[Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).
|
||||
|
||||
Returns the created client secret and the effective session object. The client
|
||||
secret is a string that looks like `ek_1234`.
|
||||
|
||||
Args:
|
||||
expires_after: Configuration for the client secret expiration. Expiration refers to the time
|
||||
after which a client secret will no longer be valid for creating sessions. The
|
||||
session itself may continue after that time once started. A secret can be used
|
||||
to create multiple sessions until it expires.
|
||||
|
||||
session: Session configuration to use for the client secret. Choose either a realtime
|
||||
session or a transcription session.
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
return self._post(
|
||||
"/realtime/client_secrets",
|
||||
body=maybe_transform(
|
||||
{
|
||||
"expires_after": expires_after,
|
||||
"session": session,
|
||||
},
|
||||
client_secret_create_params.ClientSecretCreateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=ClientSecretCreateResponse,
|
||||
)
|
||||
|
||||
|
||||
class AsyncClientSecrets(AsyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> AsyncClientSecretsWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return AsyncClientSecretsWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> AsyncClientSecretsWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
|
||||
"""
|
||||
return AsyncClientSecretsWithStreamingResponse(self)
|
||||
|
||||
async def create(
|
||||
self,
|
||||
*,
|
||||
expires_after: client_secret_create_params.ExpiresAfter | Omit = omit,
|
||||
session: client_secret_create_params.Session | Omit = omit,
|
||||
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
||||
# The extra values given here take precedence over values defined on the client or passed to this method.
|
||||
extra_headers: Headers | None = None,
|
||||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
||||
) -> ClientSecretCreateResponse:
|
||||
"""
|
||||
Create a Realtime client secret with an associated session configuration.
|
||||
|
||||
Client secrets are short-lived tokens that can be passed to a client app, such
|
||||
as a web frontend or mobile client, which grants access to the Realtime API
|
||||
without leaking your main API key. You can configure a custom TTL for each
|
||||
client secret.
|
||||
|
||||
You can also attach session configuration options to the client secret, which
|
||||
will be applied to any sessions created using that client secret, but these can
|
||||
also be overridden by the client connection.
|
||||
|
||||
[Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).
|
||||
|
||||
Returns the created client secret and the effective session object. The client
|
||||
secret is a string that looks like `ek_1234`.
|
||||
|
||||
Args:
|
||||
expires_after: Configuration for the client secret expiration. Expiration refers to the time
|
||||
after which a client secret will no longer be valid for creating sessions. The
|
||||
session itself may continue after that time once started. A secret can be used
|
||||
to create multiple sessions until it expires.
|
||||
|
||||
session: Session configuration to use for the client secret. Choose either a realtime
|
||||
session or a transcription session.
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
extra_query: Add additional query parameters to the request
|
||||
|
||||
extra_body: Add additional JSON properties to the request
|
||||
|
||||
timeout: Override the client-level default timeout for this request, in seconds
|
||||
"""
|
||||
return await self._post(
|
||||
"/realtime/client_secrets",
|
||||
body=await async_maybe_transform(
|
||||
{
|
||||
"expires_after": expires_after,
|
||||
"session": session,
|
||||
},
|
||||
client_secret_create_params.ClientSecretCreateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=ClientSecretCreateResponse,
|
||||
)
|
||||
|
||||
|
||||
class ClientSecretsWithRawResponse:
|
||||
def __init__(self, client_secrets: ClientSecrets) -> None:
|
||||
self._client_secrets = client_secrets
|
||||
|
||||
self.create = _legacy_response.to_raw_response_wrapper(
|
||||
client_secrets.create,
|
||||
)
|
||||
|
||||
|
||||
class AsyncClientSecretsWithRawResponse:
|
||||
def __init__(self, client_secrets: AsyncClientSecrets) -> None:
|
||||
self._client_secrets = client_secrets
|
||||
|
||||
self.create = _legacy_response.async_to_raw_response_wrapper(
|
||||
client_secrets.create,
|
||||
)
|
||||
|
||||
|
||||
class ClientSecretsWithStreamingResponse:
|
||||
def __init__(self, client_secrets: ClientSecrets) -> None:
|
||||
self._client_secrets = client_secrets
|
||||
|
||||
self.create = to_streamed_response_wrapper(
|
||||
client_secrets.create,
|
||||
)
|
||||
|
||||
|
||||
class AsyncClientSecretsWithStreamingResponse:
|
||||
def __init__(self, client_secrets: AsyncClientSecrets) -> None:
|
||||
self._client_secrets = client_secrets
|
||||
|
||||
self.create = async_to_streamed_response_wrapper(
|
||||
client_secrets.create,
|
||||
)
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue