# Gigabrain API Integration
## Project Context
This project integrates with Gigabrain's Intelligence Collective API for crypto market analysis and trading insights.
## API Reference
### Base URL
```
https://api.gigabrain.gg/v1
```
### Authentication
Include API key in every request:
```bash
Authorization: Bearer gb_sk_<your-key>
```
### Main Endpoint: POST /v1/chat
Query the Intelligence Collective for market analysis.
```javascript
const response = await fetch("https://api.gigabrain.gg/v1/chat", {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
message: "Analyze BTC 4H chart",
stream: false,
}),
});
```
### Rate Limits
- 30 requests per minute
- 1,000 requests per day
- Check `Retry-After` header on 429 responses
## Intelligence Collective
Queries are routed to specialized agents:
- **Macro Analyst**: Global economic regimes, DXY, VIX, yields
- **Microstructure Analyst**: OI, funding rates, liquidations
- **Fundamentals Analyst**: TVL, revenue, protocol metrics
- **Price Movement Analyst**: Technical analysis, key levels
- **Trenches Analyst**: Micro-cap tokens, social sentiment
- **Polymarket Analyst**: Prediction market analysis
## Code Standards
### Error Handling
Always handle:
- `401` - Invalid API key
- `429` - Rate limit (implement exponential backoff)
- `500` - Server error (retry logic)
### Security Best Practices
- Use environment variables for API keys
- Never expose keys in client-side code
- Rotate keys periodically
### Example Query Types
**Trading:**
- "What's the edge on SOL long here?"
- "Break down ETH fundamentals post-Dencun"
**Microstructure:**
- "Is OI spiking on ETH perps?"
- "Funding rates turning negative?"
**Macro:**
- "Fed pivot incoming, risk on for alts?"
- "Liquidity drying up, BTC pullback likely?"
## Quality Standards
- Test all API integrations thoroughly
- Implement proper retry logic
- Cache responses when appropriate
- Log session_id for debugging