Skip to content

Lyria API

This page documents the Exchange Token gateway entry for the Lyria series.

1. Overview

Exchange Token provides the Lyria series in a Gemini Interactions API compatible format.

Current scope:

  • Supported models: lyria-3-clip-preview, lyria-3-pro-preview
  • Supports non-streaming and SSE streaming
  • Method: POST
  • URL: https://api.exchangetoken.ai/v1beta/interactions

2. Authentication

Recommended header:

http
x-goog-api-key: YOUR_GATEWAY_API_KEY

3. Request

The downstream request body should stay close to the Interactions create schema.

FieldTypeRequiredDescription
modelstringYesModel name used to generate the interaction, for example lyria-3-clip-preview
inputstring, content object, or content arrayYesPrimary interaction input, which can be plain text or structured multimodal content
streambooleanNoWhether to return the output as a server-sent event stream
system_instructionstringNoHigh-level instruction that guides model behavior for the interaction

Non-streaming request example:

bash
curl "https://api.exchangetoken.ai/v1beta/interactions" \
  -H "x-goog-api-key: $YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{
    "model": "lyria-3-pro-preview",
    "input": "Create a cinematic electronic track with warm analog synths and a slow emotional build."
  }'

Streaming request example:

bash
curl "https://api.exchangetoken.ai/v1beta/interactions" \
  -H "x-goog-api-key: $YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -N \
  -X POST \
  -d '{
    "model": "lyria-3-clip-preview",
    "input": "Generate a 30-second upbeat house intro with vocal chops.",
    "stream": true
  }'

4. Response

4.1 Non-streaming response body

When stream=false, the API returns an Interaction object.

Common fields:

FieldTypeDescription
idstringUnique identifier of the interaction
objectstringResource type identifier, typically interaction
statusstringCurrent interaction status, such as in_progress, completed, or failed
rolestringRole associated with the response payload, typically model
createdstringInteraction creation time in ISO 8601 format
updatedstringLast interaction update time in ISO 8601 format
modelstringName of the model used for the interaction
stepsarrayOrdered step objects returned by the interaction
usageobjectToken usage summary for the interaction when provided by upstream

Common steps fields:

FieldTypeDescription
typestringStep type, for example model_output
contentarrayContent items carried by the step

Example:

json
{
  "id": "14sWasiVAZGq88EP4dq2iAE",
  "status": "completed",
  "role": "model",
  "created": "2026-05-27T06:15:03Z",
  "updated": "2026-05-27T06:15:03Z",
  "steps": [
    {
      "content": [
        {
          "text": "",
          "type": "text"
        }
      ],
      "type": "model_output"
    },
    {
      "content": [
        {
          "text": "Caption: This track is a quintessential piece of melancholic Jazz Fusion...\nMosic: 4.5\nBPM: 100.0",
          "type": "text"
        }
      ],
      "type": "model_output"
    },
    {
      "content": [
        {
          "mime_type": "audio/mpeg",
          "data": "...",
          "type": "audio"
        }
      ],
      "type": "model_output"
    }
  ],
  "object": "interaction",
  "model": "lyria-3-clip-preview"
}

4.2 Streaming response body

When stream=true, the API returns server-sent events. Common event_type values include:

  • interaction.created
  • interaction.status_update
  • step.start
  • step.delta
  • step.stop
  • interaction.completed
  • error

After the stream finishes, the server sends the terminal marker data: [DONE].

Example:

text
event: interaction.created
data: {"interaction":{"id":"","status":"in_progress","object":"interaction","model":"lyria-3-clip-preview"},"event_type":"interaction.created"}

event: interaction.status_update
data: {"interaction_id":"","status":"in_progress","event_type":"interaction.status_update"}

event: step.start
data: {"index":0,"step":{"type":"model_output"},"event_type":"step.start"}

event: step.delta
data: {"index":0,"delta":{"text":"Caption: A melancholic and sophisticated Jazz Fusion instrumental track...\nMosic: 4.5\nBPM: 100.0","type":"text"},"event_type":"step.delta"}

event: step.delta
data: {"index":0,"delta":{"mime_type":"audio/mpeg","data":"...","type":"audio"},"event_type":"step.delta"}

event: step.stop
data: {"index":0,"event_type":"step.stop"}

event: interaction.completed
data: {"interaction":{"id":"","status":"completed","object":"interaction","model":"lyria-3-clip-preview"},"event_type":"interaction.completed"}

event: done
data: [DONE]

5. Data Models

5.1 Content

The same content structure is used by request input and response steps[].content.

Possible Types

Polymorphic discriminator: type

TextContent

A text content block.

FieldTypeDescription
typestringAlways set to "text".
textstringThe text content.

ImageContent

An image content block.

FieldTypeDescription
typestringAlways set to "image".
datastringOptional inline image content, typically base64 encoded.
uristringOptional URI of the image.
mime_typestringOptional MIME type of the image. Common values include image/png, image/jpeg, and image/webp.

AudioContent

An audio content block.

FieldTypeDescription
typestringAlways set to "audio".
datastringOptional inline audio content, typically base64 encoded.
uristringOptional URI of the audio.
mime_typestringOptional MIME type of the audio. Common values include audio/wav, audio/mp3, audio/aac, audio/ogg, audio/flac, audio/mpeg, and audio/m4a.
channelsintegerOptional number of audio channels.
sample_rateintegerOptional sample rate of the audio.

Examples

Text

json
{
  "type": "text",
  "text": "Write a warm ambient piano theme."
}

Image

json
{
  "type": "image",
  "data": "BASE64_ENCODED_IMAGE",
  "mime_type": "image/png"
}

Audio

json
{
  "type": "audio",
  "data": "BASE64_ENCODED_AUDIO",
  "mime_type": "audio/wav"
}

5.2 Stream Event

The same stream event structure is used by streaming responses when stream=true.

Possible Types

Polymorphic discriminator: event_type

InteractionCreatedEvent

Sent when the interaction is created.

FieldTypeDescription
event_typestringAlways set to "interaction.created".
interactionobjectInteraction snapshot for the newly created interaction.
event_idstringOptional resume token for continuing the stream from the next event.

InteractionStatusUpdate

Sent when the interaction status changes.

FieldTypeDescription
event_typestringAlways set to "interaction.status_update".
interaction_idstringIdentifier of the interaction whose status changed.
statusstringUpdated interaction status, such as in_progress, completed, or failed.
event_idstringOptional resume token for continuing the stream from the next event.

StepStart

Sent when a step starts streaming.

FieldTypeDescription
event_typestringAlways set to "step.start".
indexintegerZero-based index of the step in the interaction stream.
stepobjectMetadata for the step that is starting.
event_idstringOptional resume token for continuing the stream from the next event.

StepDelta

Sent for incremental streamed output.

FieldTypeDescription
event_typestringAlways set to "step.delta".
indexintegerZero-based index of the step in the interaction stream.
deltaobjectIncremental output fragment, such as a text delta or audio delta.
event_idstringOptional resume token for continuing the stream from the next event.

StepStop

Sent when a streamed step finishes.

FieldTypeDescription
event_typestringAlways set to "step.stop".
indexintegerZero-based index of the step in the interaction stream.
event_idstringOptional resume token for continuing the stream from the next event.

InteractionCompletedEvent

Sent when the interaction finishes.

FieldTypeDescription
event_typestringAlways set to "interaction.completed".
interactionobjectFinal interaction snapshot.
event_idstringOptional resume token for continuing the stream from the next event.

ErrorEvent

Sent when the stream fails.

FieldTypeDescription
event_typestringAlways set to "error".
errorobjectError object describing the failure, typically including code and message.
event_idstringOptional resume token for continuing the stream from the next event.

Examples

Interaction Created

json
{
  "event_type": "interaction.created",
  "interaction": {
    "id": "14sWasiVAZGq88EP4dq2iAE",
    "status": "in_progress",
    "object": "interaction",
    "model": "lyria-3-clip-preview"
  }
}

Interaction Status Update

json
{
  "event_type": "interaction.status_update",
  "interaction_id": "14sWasiVAZGq88EP4dq2iAE",
  "status": "in_progress"
}

Step Start

json
{
  "event_type": "step.start",
  "index": 0,
  "step": {
    "type": "model_output"
  }
}

Step Delta

json
{
  "event_type": "step.delta",
  "index": 0,
  "delta": {
    "type": "text",
    "text": "Caption: A melancholic and sophisticated Jazz Fusion instrumental track..."
  }
}

Step Stop

json
{
  "event_type": "step.stop",
  "index": 0
}

Interaction Completed

json
{
  "event_type": "interaction.completed",
  "interaction": {
    "id": "14sWasiVAZGq88EP4dq2iAE",
    "status": "completed",
    "object": "interaction",
    "model": "lyria-3-clip-preview"
  }
}

Error Event

json
{
  "event_type": "error",
  "error": {
    "code": "internal_error",
    "message": "Upstream stream closed unexpectedly."
  }
}

Done Marker

This terminates the stream and is not an event_type value.

text
data: [DONE]