Create a Chat Completion
Endpoint:POST /v1/chat
This is the only endpoint you need to remember. Everything else is just parameters.
Simple Request:
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model to use: specific model name or “auto” |
messages | array | Yes | Array of conversation messages |
temperature | number | No | Controls randomness (0.0 to 2.0, default: 0.7) |
max_tokens | number | No | Maximum tokens in response |
stream | boolean | No | Enable streaming responses (default: false) |
top_p | number | No | Nucleus sampling parameter (0.0 to 1.0) |
maxSources | number | no | Number of sources (default: 4) |
frequency_penalty | number | No | Reduce repetition (-2.0 to 2.0) |
presence_penalty | number | No | Encourage new topics (-2.0 to 2.0) |
compareModel | string | No | Model for side-by-side comparison |
includeSources | boolean | No | Include web sources (default: false) |
includeSuggestions | boolean | No | Include follow-up suggestions (default: false) |
Message Format
Messages follow the standard chat format with role-based conversation:- system: Sets the AI’s behavior and context
- user: Messages from the human user
- assistant: Previous AI responses (for conversation context)
Response Format
Streaming Responses
When stream: true, the response comes as a series of chunks, allowing for real-time display. Each chunk contains a piece of the generated response:Context Management
Your conversations don’t exist in a vacuum. Our API intelligently manages conversation context across multiple exchanges, letting you build truly interactive experiences:- Natural follow-up questions without restating context
- Progressive exploration of complex topics
- Personalized experiences that build on previous interactions
- Long-running assistants that remember user preferences and history
Reliability and Performance
When integrating AI into mission-critical applications, reliability isn’t optional. AnswerrAI’s infrastructure is built for enterprise-grade dependability:- Global edge network ensuring low latency worldwide
- Automatic failover between model providers during outages
- Intelligent request routing to optimize response times
- Horizontal scaling to handle traffic spikes without degradation
Error Handling
When something goes wrong, you’ll know exactly why:| Status | Error Code | Description | Solution |
|---|---|---|---|
| 400 | invalid_request | Malformed request | Check request format and required parameters |
| 401 | invalid_api_key | Invalid or missing API key | Verify your API key is correct |
| 403 | insufficient_quota | Quota exceeded | Upgrade your plan or wait for quota reset |
| 429 | rate_limit_exceeded | Too many requests | Implement exponential backoff |
| 500 | internal_error | Server error | Retry the request after a delay |
Practical Applications
The simplicity and power of our Chat Completion API make it perfect for a wide range of applications:Customer Experience Enhancement
Build intelligent chatbots that understand context, answer questions accurately, and maintain a conversational flow that feels natural. With the ability to switch between models, you can use cost-effective options for simple queries and premium models for complex support cases.Content Creation and Editing
Create tools that help writers generate ideas, improve prose, or translate content into multiple languages. The streaming capability allows for real-time collaborative editing between humans and AI.Educational Tools
Develop personalized tutoring systems that adapt to each student’s learning style and pace. Context management allows the AI to build on previous lessons, creating a cohesive learning journey.Internal Knowledge Management
Transform your company documentation into an interactive assistant that employees can query conversationally, making institutional knowledge more accessible and useful.AI Security and Compliance
We understand that data security is paramount when working with AI. Our platform is built with security-first principles:- Data isolation: Your API calls and data never influence model training
- SOC 2 Type II compliance: Independent verification of our security controls
- End-to-end encryption: Data is encrypted both in transit and at rest
- Configurable data retention: Control how long your data is stored
- Regional deployment options: Keep data in your preferred jurisdiction