> ## AI Agent Context > Get the complete documentation index at: https://aistudio.google.com/llms.txt > Use this file to discover all available pages. > For the full documentation in a single file, fetch: https://aistudio.google.com/llms-full.txt # Live Music API - WebSockets API reference {% callout type="note" %} **Preview:** The Live Music API is in preview. {% /callout %} Lyria RealTime music generation uses a persistent, bidirectional, low-latency streaming connection using [WebSockets](https://en.wikipedia.org/wiki/WebSocket). In this section, you'll find additional details regarding the WebSockets API. ## Methods {% id="methods" %} {% table %} * Method * Endpoint --- * [Starting a Live Music session](/api-reference/live-music/bidi-generate-music) * {% mark class="http-wss" %}{% icon name="sync_alt" /%}`WSS`{% /mark %} `/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateMusic` Opens a WebSocket session that streams music generated in real time from your prompts and playback controls. {% /table %} ## Data Models {% id="data-models" %} ### AudioChunk {% id="AudioChunk" %} Representation of an audio chunk. Union field `content`. `content` can be only one of the following: {% table %} * Field * Type * Description --- * `data` * `bytes` * Raw bytes of the audio chunk. --- * `mimeType` * `string` * The MIME type of the content of the audio chunk, such as "audio/wav". --- * `sourceMetadata` * [`SourceMetadata`](/api-reference/live-music#AudioChunk.SourceMetadata) * Output only. Prompts and config used for generating this audio chunk. {% /table %} ### SourceMetadata {% id="AudioChunk.SourceMetadata" %} Metadata about the input source used for generating this audio chunk. {% table %} * Field * Type * Description --- * `clientContent` * [`BidiGenerateMusicClientContent`](/api-reference/live-music#BidiGenerateMusicClientContent) * Weighted prompts for generating this audio chunk. --- * `musicGenerationConfig` * [`BidiGenerateMusicGenerationConfig`](/api-reference/live-music#BidiGenerateMusicGenerationConfig) * Music generation config for generating this audio chunk. {% /table %} ### BidiGenerateMusicClientContent {% id="BidiGenerateMusicClientContent" %} User input to start or steer the music. {% table %} * Field * Type * Description --- * `weightedPrompts[]` * [`WeightedPrompt`](/api-reference/live-music#WeightedPrompt) * Required. Weighted prompts as the model input. {% /table %} ### BidiGenerateMusicClientMessage {% id="BidiGenerateMusicClientMessage" %} Messages sent by the client in the BidiGenerateMusic call. Union field `messageType`. `messageType` can be only one of the following: {% table %} * Field * Type * Description --- * `setup` * [`BidiGenerateMusicSetup`](/api-reference/live-music#BidiGenerateMusicSetup) * Optional. Session configuration sent in the first and only first client message. --- * `clientContent` * [`BidiGenerateMusicClientContent`](/api-reference/live-music#BidiGenerateMusicClientContent) * Optional. Weighted prompts and music generation configs as the input of music generation. --- * `musicGenerationConfig` * [`BidiGenerateMusicGenerationConfig`](/api-reference/live-music#BidiGenerateMusicGenerationConfig) * Optional. Configuration for music generation. --- * `playbackControl` * [`BidiGenerateMusicPlaybackControl`](/api-reference/live-music#BidiGenerateMusicPlaybackControl) * Optional. Playback control signal for the music generation. {% /table %} ### BidiGenerateMusicFilteredPrompt {% id="BidiGenerateMusicFilteredPrompt" %} Filtered prompt with reason. {% table %} * Field * Type * Description --- * `filteredReason` * `string` * Output only. The reason why the prompt was filtered. {% /table %} Union field `prompt`. The prompt that was filtered. `prompt` can be only one of the following: {% table %} * Field * Type * Description --- * `text` * `string` * Optional. Text prompt. {% /table %} ### BidiGenerateMusicGenerationConfig {% id="BidiGenerateMusicGenerationConfig" %} Configuration for music generation. {% table %} * Field * Type * Description --- * `temperature` * `float` * Optional. Controls the variance in audio generation. Higher values produce higher variance. Range is [0.0, 3.0]. Default is 1.1. --- * `topK` * `int32` * Optional. Controls how the model selects tokens for output. Samples the topK tokens with the highest probabilities. Range is [1, 1000]. Default is 40. --- * `seed` * `int32` * Optional. Seeds audio generation. If not set, the request uses a randomly generated seed. --- * `guidance` * `float` * Optional. Controls how closely the model follows prompts. Higher guidance follows more closely, but will make transitions more abrupt. Range is [0.0, 6.0]. Default is 4.0. --- * `bpm` * `int32` * Optional. Beats per minute. Range is [60, 200]. --- * `density` * `float` * Optional. Density of sounds. Range is [0.0, 1.0]. --- * `brightness` * `float` * Optional. Higher value produces brighter audio. Range is [0.0, 1.0]. --- * `scale` * [`Scale`](/api-reference/live-music#BidiGenerateMusicGenerationConfig.Scale) * Optional. Scale of the generated music. --- * `muteBass` * `bool` * Optional. The audio output should not contain bass. --- * `muteDrums` * `bool` * Optional. The audio output should not contain drums. --- * `onlyBassAndDrums` * `bool` * Optional. The audio output should only contain bass and drums. --- * `musicGenerationMode` * [`MusicGenerationMode`](/api-reference/live-music#BidiGenerateMusicGenerationConfig.MusicGenerationMode) * Optional. The mode of music generation. Default is QUALITY. {% /table %} ### MusicGenerationMode {% id="BidiGenerateMusicGenerationConfig.MusicGenerationMode" %} {% table %} * Value * Description --- * `MUSIC_GENERATION_MODE_UNSPECIFIED` * This value is unused. --- * `QUALITY` * This mode steers text prompts to regions of latent space with higher quality music. --- * `DIVERSITY` * This mode steers text prompts to regions of latent space with a larger diversity of music. --- * `VOCALIZATION` * This mode steers text prompts to regions of latent space more likely to generate vocal music. {% /table %} ### Scale {% id="BidiGenerateMusicGenerationConfig.Scale" %} Scale of the generated music. {% table %} * Value * Description --- * `SCALE_UNSPECIFIED` * Default value. This value is unused. --- * `C_MAJOR_A_MINOR` * C major or A minor --- * `D_FLAT_MAJOR_B_FLAT_MINOR` * D flat major or B flat minor --- * `D_MAJOR_B_MINOR` * D major or B minor --- * `E_FLAT_MAJOR_C_MINOR` * E flat major or C minor --- * `E_MAJOR_D_FLAT_MINOR` * E major or D flat minor --- * `F_MAJOR_D_MINOR` * F major or D minor --- * `G_FLAT_MAJOR_E_FLAT_MINOR` * G flat major or E flat minor --- * `G_MAJOR_E_MINOR` * G major or E minor --- * `A_FLAT_MAJOR_F_MINOR` * A flat major or F minor --- * `A_MAJOR_G_FLAT_MINOR` * A major or G flat minor --- * `B_FLAT_MAJOR_G_MINOR` * B flat major or G minor --- * `B_MAJOR_A_FLAT_MINOR` * B major or A flat minor {% /table %} ### BidiGenerateMusicPlaybackControl {% id="BidiGenerateMusicPlaybackControl" %} Playback control for the music generation. {% table %} * Value * Description --- * `PLAYBACK_CONTROL_UNSPECIFIED` * This value is unused. --- * `PLAY` * Start generating the music. --- * `PAUSE` * Hold the music generation. Use PLAY to resume from the current position. --- * `STOP` * Stop the music generation and reset the context (prompts retained). Use PLAY to restart the music generation. --- * `RESET_CONTEXT` * Reset the context (prompts retained) without stopping the music generation. {% /table %} ### BidiGenerateMusicServerContent {% id="BidiGenerateMusicServerContent" %} Incremental server update generated by the model in response to client messages. Content is generated as quickly as possible, and not in real time. Clients may choose to buffer and play it out in real time. {% table %} * Field * Type * Description --- * `audioChunks[]` * [`AudioChunk`](/api-reference/live-music#AudioChunk) * Output only. Audio chunks that the model has generated. {% /table %} ### BidiGenerateMusicServerMessage {% id="BidiGenerateMusicServerMessage" %} Response message for the BidiGenerateMusic call. Union field `messageType`. The type of the message. `messageType` can be only one of the following: {% table %} * Field * Type * Description --- * `setupComplete` * [`BidiGenerateMusicSetupComplete`](/api-reference/live-music#BidiGenerateMusicSetupComplete) * Output only. Sent in response to a `BidiGenerateMusicSetup` message from the client when setup is complete. --- * `serverContent` * [`BidiGenerateMusicServerContent`](/api-reference/live-music#BidiGenerateMusicServerContent) * Output only. Content generated by the model in response to client messages. --- * `filteredPrompt` * [`BidiGenerateMusicFilteredPrompt`](/api-reference/live-music#BidiGenerateMusicFilteredPrompt) * Output only. Filtered prompt with reason. --- * `warning` * `string` * Output only. The warning message from the server. Warnings won't terminate the stream. {% /table %} ### BidiGenerateMusicSetup {% id="BidiGenerateMusicSetup" %} Message to be sent in the first (and only in the first) `BidiGenerateMusicClientMessage`. Clients should wait for a `BidiGenerateMusicSetupComplete` message before sending any additional messages. {% table %} * Field * Type * Description --- * `model` * `string` * Required. The model's resource name. This serves as an ID for the model to use. Format: `models/{model}` {% /table %} ### BidiGenerateMusicSetupComplete {% id="BidiGenerateMusicSetupComplete" %} Sent in response to a `BidiGenerateMusicSetup` message from the client. This type has no fields. ### WeightedPrompt {% id="WeightedPrompt" %} Weighted prompt as the model input. {% table %} * Field * Type * Description --- * `weight` * `float` * Required. Weight of the prompt. The weight is used to control the relative importance of the prompt. Higher weights are more important than lower weights. Weights of all weighted_prompts in this BidiGenerateMusicClientContent must not be all 0. Weights of all weighted_prompts in this BidiGenerateMusicClientContent message will be normalized. {% /table %} Union field `prompt`. `prompt` can be only one of the following: {% table %} * Field * Type * Description --- * `text` * `string` * Text prompt. {% /table %} ## More information on types {% id="more-info" %} For more information on the types used by the API, see the [Python SDK](https://github.com/googleapis/python-genai/blob/main/google/genai/types.py).