Completado de Chat
La finalización de chat (Chat Completion) le permite generar texto conversacional y estructurado utilizando los modelos de lenguaje de NovaAI. Ya sea que esté creando asistentes de IA, agentes de atención al cliente, herramientas de generación de contenido o compañeros de codificación, la API de Chat Completion proporciona una interfaz consistente para generar respuestas inteligentes.
Overview
The Chat Completion API processes a sequence of messages and generates a context-aware response from the selected language model. Unlike traditional text generation, chat models understand conversation history, system instructions, and user intent, allowing them to produce more accurate and natural responses.
Every request consists of a model and a messages array, while optional parameters allow you to control creativity, response length, streaming, and more.
How Chat Completion Works
The model analyzes the entire conversation before generating the next assistant message.
Create a Chat Completion
Request Properties
model
string
requerido
The language model used to generate the response.
messages
array
requerido
Conversation history sent to the model.
temperature
number
opcional
Controls response creativity.
max_tokens
integer
opcional
Maximum number of generated tokens.
stream
boolean
opcional
Enables streaming responses.
top_p
Number
opcional
Controls response diversity.
Response Example
Supported Use Cases
Use Case | Description |
Customer Support | Build intelligent support agents and help desks. |
AI Chatbots | Create conversational assistants for web and mobile apps. |
Content Generation | Generate articles, emails, and marketing copy. |
Code Assistance | Explain, write, and optimize source code. |
Knowledge Base | Answer questions using internal documentation. |
Data Summarization | Summarize long documents and reports. |
Parameter Guide
Parameter | Recommended Range | Purpose |
| 0.0 – 1.0 | Controls creativity and randomness. |
| Depends on model | Limits response length. |
|
| Enables real-time token streaming. |
| 0.8 – 1.0 | Controls token selection diversity. |
Response Lifecycle
Best Practices
Start every conversation with a clear system instruction.
Keep conversation history relevant.
Choose the appropriate model for your workload.
Limit response length using
max_tokens.Enable streaming for real-time conversational experiences.
Monitor token usage to optimize performance and cost.
Common Errors
Invalid Messages Format
The messages array is missing or contains invalid objects.
Solution
Ensure every message includes both a role and content property.
Unsupported Model
The selected model is unavailable or does not support chat completion.
Solution
Verify the model identifier before sending the request.
Context Window Exceeded
The combined conversation exceeds the model's maximum context window.
Solution
Remove unnecessary messages or summarize earlier parts of the conversation.
Frequently Asked Questions
Next Step
Now that you've learned how to generate conversational responses, continue to Image Generation to explore how NovaAI creates high-quality images from natural language prompts.