Skip to content

Latest commit

 

History

History
185 lines (123 loc) · 13.3 KB

README.md

File metadata and controls

185 lines (123 loc) · 13.3 KB

Audio.Sessions

Overview

Available Operations

  • create - Create an agent session
  • get - Get session status
  • update - Update a live agent session
  • close - Stop an agent session

create

Create a real-time audio agent session.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:

    res = mistral.audio.sessions.create()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
llm Optional[models.AudioLLMConfig] ➖ N/A
tts Optional[models.AudioTTSConfig] ➖ N/A
stt Optional[models.AudioSTTConfig] ➖ N/A
turn Optional[models.AudioTurnConfig] ➖ N/A
instructions OptionalNullable[str] ➖ N/A
tools List[models.AudioSessionCreateRequestTool] ➖ N/A
welcome_message OptionalNullable[str] ➖ N/A
agent_id OptionalNullable[str] ➖ N/A
agent_version OptionalNullable[int] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.AudioSessionCreateResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

get

Retrieve an audio agent session with the transcript of its conversation.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:

    res = mistral.audio.sessions.get(session_id="4f4cc199-091a-4c84-bbe2-7e1c1dfeb849")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
session_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.AudioSessionResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

update

Update the instructions, tools or turn handling of a live session.

The agent applies the update at its next turn boundary, so it is not yet applied when this returns. The agent's session_updated and session_update_failed webhooks report the outcome to your server.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:

    res = mistral.audio.sessions.update(session_id="e7fa5d49-3528-45a6-942c-da6c39ecb063")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
session_id str ✔️ N/A
instructions OptionalNullable[str] ➖ N/A
tools List[models.AudioSessionUpdateRequestTool] ➖ N/A
turn OptionalNullable[models.AudioSessionTurnUpdate] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.AudioSessionUpdateResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

close

Stop an audio agent session and release its resources.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:

    mistral.audio.sessions.close(session_id="ce48313c-2e04-4918-9c23-e227a406a9e0")

    # Use the SDK ...

Parameters

Parameter Type Required Description
session_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*