Features

Chat Completion

Chat Completion enables you to generate conversational and structured text using NovaAI language models. Whether you're building AI assistants, customer support agents, content generation tools, or coding companions, the Chat Completion API provides a consistent interface for generating intelligent responses.

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.

Note: Chat Completion is the recommended endpoint for all conversational AI experiences built with NovaAI.

Note: Chat Completion is the recommended endpoint for all conversational AI experiences built with NovaAI.

How Chat Completion Works

Rendering diagram…

The model analyzes the entire conversation before generating the next assistant message.

Create a Chat Completion


import { NovaAI } from "@novaai/sdk";
 
const client = new NovaAI({
apiKey: process.env.NOVA_API_KEY,
});
 
const response = await client.chat.create({
model: "nova-chat-4",
messages: [
{
role: "system",
content: "You are a helpful technical assistant."
},
{
role: "user",
content: "Explain what APIs are in simple terms."
}
]
});
 
console.log(response.output);

Request Properties

model

string

required

The language model used to generate the response.

messages

array

required

Conversation history sent to the model.

temperature

number

optional

Controls response creativity.

max_tokens

integer

optional

Maximum number of generated tokens.

stream

boolean

optional

Enables streaming responses.

top_p

Number

optional

Controls response diversity.

Response Example

{
"id": "chat_9f8ab1",
"model": "nova-chat-4",
"output": "An API allows different software applications to communicate with each other by exchanging information.",
"usage": {
"prompt_tokens": 24,
"completion_tokens": 18,
"total_tokens": 42
}
}

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

temperature

0.0 – 1.0

Controls creativity and randomness.

max_tokens

Depends on model

Limits response length.

stream

true / false

Enables real-time token streaming.

top_p

0.8 – 1.0

Controls token selection diversity.

Response Lifecycle

Rendering diagram…

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.

Tip: For production applications, use lower temperature values when consistency is more important than creativity.

Tip: For production applications, use lower temperature values when consistency is more important than creativity.

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

Can I continue a previous conversation?

Yes. Include the previous conversation history in the messages array to maintain context.

Does the model remember previous requests automatically?

No. Each request is independent. Your application is responsible for sending relevant conversation history.

Should I always include a system message?

Although optional, a system message is recommended because it establishes the assistant's behavior and improves consistency.

Can I continue a previous conversation?

Yes. Include the previous conversation history in the messages array to maintain context.

Does the model remember previous requests automatically?

No. Each request is independent. Your application is responsible for sending relevant conversation history.

Should I always include a system message?

Although optional, a system message is recommended because it establishes the assistant's behavior and improves consistency.

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.

Was this helpful?

Was this helpful?

Create a free website with Framer, the website builder loved by startups, designers and agencies.