POST /api/ai/chat (Streaming)
Real-time streaming chat endpoint for interactive AI applications.Endpoint
Authentication
Required header:X-API-Key: sk_your_api_key
See Authentication for details.
Request
Headers
Body Parameters
Message Object
Request Example
Response
Response Headers
Governor Headers (if enabled)
Response Body
Streaming text response via Server-Sent Events.Code Examples
Quality Tiers
RegPilot automatically routes your request to the optimal model based on quality:Governor Integration
Add compliance validation to your requests:Governor Metadata Fields
Action Types
customer_support- General customer service (Low risk)legal_advice- Legal queries (Medium risk)medical_advice- Health/medical queries (Medium risk)hr_message- Human resources communications (Medium risk)suspension- Account actions (High risk)refund_denial- Payment decisions (High risk)policy_warning- Policy enforcement (Medium risk)other- General content (Low risk)
Multi-turn Conversations
Maintain conversation context by including message history:Model Override
Specify a particular model instead of using quality tiers:Supported Models
- OpenAI:
gpt-4o,gpt-4o-mini,gpt-4-turbo - Anthropic:
claude-3-opus-20240229,claude-3-sonnet-20240229,claude-3-haiku-20240307 - Mistral:
mistral-large-latest,mistral-medium-latest
Caching
RegPilot automatically caches responses for identical requests:Cache hits are free! You’re only charged for cache misses.
Error Handling
Rate Limits
Rate limits vary by plan:
See Rate Limits for details.
Best Practices
1. Stream Processing
Always process streams efficiently:2. Error Recovery
Implement retry logic for transient errors:3. Context Management
Trim old messages to stay within token limits:Next: Complete (Non-Streaming) →