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

# Response Format

> Understand the streaming response format from your agent

## Streaming Responses

The server streams Server-Sent Events (SSE). Each event is a JSON object containing agent output, logs, and other events.

## Response Format

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

data: {"type":"log","data":{"message":"Processing..."}}

data: {"type":"message","data":{"content":"Done!"}}
```

## Event Types

### Message Events

Agent responses are sent as message events:

```json theme={null}
{
  "type": "message",
  "data": {
    "content": "Response text from the agent"
  }
}
```

### Log Events

Diagnostic information and logs:

```json theme={null}
{
  "type": "log",
  "data": {
    "message": "Processing step completed"
  }
}
```

<Note>
  Each line starts with `data:` followed by a type-discriminated JSON envelope.
</Note>

## Consuming the Stream

### With curl

```bash theme={null}
curl -N \
  -H "Content-Type: application/json" \
  -X POST http://127.0.0.1:8080/query \
  -d '{"parts":[{"type":"text","text":"Hello"}],"kwargs":{}}'
```

The `-N` flag is essential for real-time streaming.

### With JavaScript

```javascript theme={null}
const eventSource = new EventSource('/query');

eventSource.onmessage = (event) => {
  const data = JSON.parse(event.data);

  if (data.type === 'message') {
    console.log('Agent:', data.data.content);
  } else if (data.type === 'log') {
    console.log('Log:', data.data.message);
  }
};
```

### With Python

```python theme={null}
import requests
import json

response = requests.post(
    'http://127.0.0.1:8080/query',
    json={"parts": [{"type": "text", "text": "Hello"}], "kwargs": {}},
    stream=True
)

for line in response.iter_lines():
    if line:
        event = json.loads(line.decode('utf-8').replace('data: ', ''))
        print(f"{event['type']}: {event['data']}")
```

## Next Steps

* Learn about [request format](/v0-docs/api-reference/request-format)
* See [file upload examples](/v0-docs/api-reference/file-uploads)
