Core Concepts

Tokens

Tokens are the fundamental units used by NovaAI to process text. Every request and response is measured in tokens, which directly affect context limits, response length, processing time, and billing. Understanding how tokens work helps you build faster, more efficient, and cost-effective AI applications.

What Are Tokens?

Before a model can understand text, it breaks the input into smaller pieces called tokens. Tokens are not the same as words - depending on the language and formatting, a single word may consist of one or more tokens.

Both the text you send to the model and the text generated by the model contribute to the total number of tokens processed in a request.

Note: Token counts vary depending on the language, punctuation, whitespace, and special characters. Longer conversations generally consume more tokens.

Note: Token counts vary depending on the language, punctuation, whitespace, and special characters. Longer conversations generally consume more tokens.

How Tokens Are Used

Every API request consists of three token categories.

Token Type

Description

Input Tokens

Tokens contained in your prompt, instructions, and conversation history.

Output Tokens

Tokens generated by the model in its response.

Total Tokens

The combined number of input and output tokens processed during the request.

Request Breakdown

Rendering diagram…

Every piece of text sent to the model contributes to the total token count.

Example Usage

{
"usage": {
"prompt_tokens": 142,
"completion_tokens": 58,
"total_tokens": 200
}
}

NovaAI returns token usage with every successful response, allowing you to monitor consumption and optimize your application.

Understanding Usage Statistics

Property

Description

prompt_tokens

Tokens used by the request payload.

completion_tokens

Tokens generated by the model.

total_tokens

Combined total for the request.

Token Lifecycle

Rendering diagram…

Before processing begins, the model converts both your request and response into tokens.

Context Window

Every model has a maximum context window, which represents the total number of tokens it can process in a single request.

The context window includes:

  • System instructions

  • Conversation history

  • User messages

  • Generated response

Once the limit is reached, older context may need to be removed or summarized.

Important: Exceeding a model's context window may cause requests to fail or require truncation of previous conversation history.

Important: Exceeding a model's context window may cause requests to fail or require truncation of previous conversation history.

Estimated Token Consumption

Content

Approximate Tokens

Short sentence

10–20

Paragraph

80–150

Blog article

700–1,500

Source code (100 lines)

600–1,200

Long conversation

2,000+

These values are estimates and may vary depending on formatting and language.

Optimizing Token Usage

  • Keep prompts concise and focused.

  • Remove unnecessary conversation history.

  • Summarize older messages instead of sending the full conversation.

  • Set an appropriate max_tokens value.

  • Choose the right model for your workload.

  • Avoid sending duplicate context in every request.

Tip: Reducing unnecessary tokens not only lowers API costs but can also improve response latency and overall application performance.

Tip: Reducing unnecessary tokens not only lowers API costs but can also improve response latency and overall application performance.

Common Questions

Do spaces and punctuation count as tokens?

Yes. Tokenization considers the entire input, including punctuation, symbols, formatting, and whitespace.

Why is my token count higher than expected?

Long conversation history, detailed system prompts, Markdown formatting, and source code can significantly increase token usage.

Can I control response length?

Yes. Use the max_tokens parameter to limit the maximum number of tokens the model can generate.

Do spaces and punctuation count as tokens?

Yes. Tokenization considers the entire input, including punctuation, symbols, formatting, and whitespace.

Why is my token count higher than expected?

Long conversation history, detailed system prompts, Markdown formatting, and source code can significantly increase token usage.

Can I control response length?

Yes. Use the max_tokens parameter to limit the maximum number of tokens the model can generate.

Token Optimization Checklist

  • Keep prompts as short as possible.

  • Send only relevant conversation history.

  • Monitor token usage in API responses.

  • Set sensible output limits.

  • Review high-usage requests regularly.

Next Step

Now that you understand how tokens influence performance, context, and cost, continue to Responses to learn how NovaAI structures API responses and returns generated content to your application.

Related Documentaion

Was this helpful?

Was this helpful?

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