Primeros pasos

Tu primera solicitud

Envía tu primera solicitud a la API de NovaAI y aprende cómo se estructuran las solicitudes y respuestas. Esta guía te orientará en la creación de una solicitud de completado de chat simple, en la comprensión de los parámetros requeridos y en la interpretación de la respuesta devuelta por la API.

Before You Begin

Before making your first request, ensure you've completed the following:

  • Installed the NovaAI SDK.

  • Configured your API key.

  • Completed authentication.

  • Created a NovaAI project.

Note: If you haven't completed these steps, return to the Installation and Authentication guides before continuing.

Note: If you haven't completed these steps, return to the Installation and Authentication guides before continuing.

Your First API Request

The example below sends a simple prompt to the NovaAI Chat model and returns a generated response.

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: "user",
content: "Explain what machine learning is in one sentence."
}
]
});
 
console.log(response.output);

Understanding the Request

Every chat request consists of a few essential properties.

Property

Type

Required

Description

model

String

Yes

Specifies which AI model processes the request.

messages

Array

Yes

The conversation history sent to the model.

temperature

Number

No

Controls randomness in generated responses.

max_tokens

Integer

No

Limits the maximum response length.

stream

Boolean

No

Enables streaming responses.


Request Lifecycle

Rendering diagram…

Every request follows the same lifecycle regardless of the selected model or endpoint.

Example Response

A successful request returns a structured JSON response.

{
"id": "req_8f31a7",
"model": "nova-chat-4",
"output": "Machine learning is a branch of artificial intelligence that enables computers to learn patterns from data.",
"usage": {
"prompt_tokens": 14,
"completion_tokens": 18,
"total_tokens": 32
}
}

Understanding the Response

Property

Description

id

Unique identifier for the request.

model

AI model that generated the response.

output

Generated content returned by the model.

usage

Token usage statistics for the request.


Response Flow

Rendering diagram…

Try Your Own Prompt

Use the example below to experiment with different prompts.

Try Your Own Prompt

Copiar indicador

Try Your Own Prompt

Copiar indicador

Replace the prompt in the previous example with your own and observe how different instructions influence the generated output.

Common Request Errors

Invalid Model

The requested model does not exist or is unavailable.

Solution

Verify the model name and ensure it is supported by your account.

Invalid Request Body

One or more required properties are missing or incorrectly formatted.

Solution

Validate the JSON payload and confirm all required fields are included.

Rate Limit Exceeded

Too many requests were sent within a short period.

Solution

Retry the request after the recommended wait time or implement exponential backoff.

During development, start with short prompts and smaller token limits. This makes testing faster and helps you better understand how different parameters affect the output.

During development, start with short prompts and smaller token limits. This makes testing faster and helps you better understand how different parameters affect the output.

What's Next?

Congratulations! You've successfully sent your first request to NovaAI.

Continue to Core Concepts to learn how models, prompts, messages, tokens, and responses work together to power every interaction with the NovaAI platform.

Documentación relacionada

¿Te resultó útil?

¿Te resultó útil?

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