> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meibel.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Streaming

> Working with streaming API responses

# Streaming

Some API endpoints support Server-Sent Events (SSE) for real-time streaming responses.

## How It Works

Streaming endpoints return a stream of events rather than a single response. Each event is a JSON object prefixed with `data:`.

## Event Format

```
data: {"type": "message", "content": "Hello"}

data: {"type": "done"}

```

## SDK Examples

<CodeGroup>
  ```python Python theme={null}
  from meibel import MeibelClient

  client = MeibelClient(api_key="your-api-key")

  # Upload a file
  with open("document.pdf", "rb") as f:
      result = client.agents.sessions.send_chat_message_stream("session_id_value", file=f, filename="document.pdf")
      print(result)
  ```

  ```typescript TypeScript theme={null}
  import { MeibelClient } from 'meibel';

  const client = new MeibelClient({ apiKey: 'your-api-key' });

  import fs from 'fs';

  // Upload a file
  const file = fs.createReadStream('document.pdf');
  const result = await client.agents.sessions.sendChatMessageStream('session_id_value', file, 'document.pdf');
  console.log(result);
  ```

  ```go Go theme={null}
  import v2 "github.com/meibel-ai/meibel-go/v2"

  client := v2.NewClient(v2.WithAPIKey("your-api-key"))
  ctx := context.Background()

  // Upload a file
  f, err := os.Open("document.pdf")
  if err != nil {
      log.Fatal(err)
  }
  defer f.Close()

  result, err := client.Agents.Sessions.SendChatMessageStream(ctx, "session_id_value", f, "document.pdf", nil)
  if err != nil {
      log.Fatal(err)
  }
  fmt.Println(result)
  ```
</CodeGroup>
