# `Gemini.Types.Live.ServerMessage`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.15.0/lib/gemini/types/live/server_message.ex#L1)

Server message wrapper for Live API responses.

Response message for the BidiGenerateContent call. Contains exactly one
message type field plus optional usage metadata.

## Message Types

- `setup_complete` - Session setup confirmation
- `server_content` - Content generated by the model
- `tool_call` - Request to execute function calls
- `tool_call_cancellation` - Notification to cancel tool calls
- `go_away` - Notice that server will disconnect soon
- `session_resumption_update` - Session resumption state update
- `voice_activity` - Voice activity detection signal

## Example

    # Server content message
    %ServerMessage{
      server_content: %ServerContent{
        model_turn: %{role: "model", parts: [%{text: "Hello!"}]},
        turn_complete: true
      },
      usage_metadata: %UsageMetadata{total_token_count: 100}
    }

# `t`

```elixir
@type t() :: %Gemini.Types.Live.ServerMessage{
  go_away: Gemini.Types.Live.GoAway.t() | nil,
  server_content: Gemini.Types.Live.ServerContent.t() | nil,
  session_resumption_update:
    Gemini.Types.Live.SessionResumptionUpdate.t() | nil,
  setup_complete: Gemini.Types.Live.SetupComplete.t() | nil,
  tool_call: Gemini.Types.Live.ToolCall.t() | nil,
  tool_call_cancellation: Gemini.Types.Live.ToolCallCancellation.t() | nil,
  usage_metadata: Gemini.Types.Live.UsageMetadata.t() | nil,
  voice_activity: Gemini.Types.Live.VoiceActivity.t() | nil
}
```

# `extract_text`

```elixir
@spec extract_text(t()) :: String.t() | nil
```

Extracts text from server content if present.

# `from_api`

```elixir
@spec from_api(map() | nil) :: t() | nil
```

Parses from API response.

# `interrupted?`

```elixir
@spec interrupted?(t()) :: boolean()
```

Checks if this is an interrupted message.

# `message_type`

```elixir
@spec message_type(t()) :: atom() | nil
```

Returns the message type as an atom.

# `new`

```elixir
@spec new(keyword()) :: t()
```

Creates a new ServerMessage.

# `setup_complete?`

```elixir
@spec setup_complete?(t()) :: boolean()
```

Checks if this is a setup complete message.

# `to_api`

```elixir
@spec to_api(t() | nil) :: map() | nil
```

Converts to API format (camelCase).

# `turn_complete?`

```elixir
@spec turn_complete?(t()) :: boolean()
```

Checks if this is a turn complete message.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
