# Carbon Footprint Chat API Reference

## Endpoint

```
POST http://47.96.16.84:81/v1/chat-messages
```

## Authentication

```
Authorization: Bearer app-sKnwL0sR8CNDf66YOQ0pj4TG
```

## Request Body

| Field             | Type   | Required | Description                                      |
|-------------------|--------|----------|--------------------------------------------------|
| inputs            | object | Yes      | Reserved, pass `{}`                              |
| query             | string | Yes      | User question about carbon footprint             |
| response_mode     | string | Yes      | `streaming` (SSE). Note: this Agent App only supports streaming mode. |
| conversation_id   | string | No       | Empty for new conversation; reuse for multi-turn |
| user              | string | Yes      | User identifier, e.g. `manus-agent`             |

## Response (streaming mode)

SSE stream with events:
- `event: message` — partial answer chunk in `answer` field
- `event: message_end` — final metadata with `conversation_id` and `message_id`

**Important Interface Characteristics:**
- **Streaming Response**: The API uses Server-Sent Events (SSE) for real-time streaming responses
- **Maximum Wait Time**: Set timeout to 200 seconds maximum for complete response
- **Partial Content Handling**: Responses may arrive in chunks; accumulate all chunks until `[DONE]` or `message_end` event
- **Error Recovery**: Implement retry logic with exponential backoff for connection errors

## Backend Agent Capabilities

The API connects to a specialized carbon footprint AI agent with:

1. **Carbon emission factor lookup** — queries a dedicated tool for emission factor data (flow_name, yinzi, flow_category, unit, evaluation_method)
2. **Knowledge base** — covers technical standards, quantification methods, carbon footprint reports, production reports
3. **Policy analysis** — responds from multiple policy perspectives (project development, manufacturing & supply chain, emission accounting & management)
4. **Report generation** — structured drafts with system boundaries, data collection methods, emission factor selection, uncertainty analysis
5. **Technical optimization** — proposes improvement plans with feasibility, reduction potential, and cost analysis
6. **Anomaly handling** — cross-validation, standard review, and sensitivity analysis

## Knowledge Priority

When sources conflict:
```
Technical Standards > Quantification Methods > Carbon Footprint Reports > Production Reports
```
- Newer versions take precedence within the same document type
- Regional keywords trigger appropriate standard selection (e.g., EU → IEC standards)