Integration guides · 2026-10-30

SEA-LION's 8,192 tokens: long text, max_tokens and cost

Split long text for the 8,192-token window of Qwen-SEA-LION-v4.5-27B-IT, set max_tokens together with the prompt, and work out the cost of each request.

Diagram: the marscompute/qwen-sea-lion-v4.5-27b box under https://llmtr.com/v1 and, below it, a bar in two parts: prompt_tokens and max_tokens.

Short answer: keep prompt plus max_tokens within 8,192 and split long text

LLMTR is a gateway that gives access to language models from different providers through one OpenAI-compatible API. Qwen-SEA-LION-v4.5-27B-IT is called on LLMTR with the marscompute/qwen-sea-lion-v4.5-27b id on the /v1/chat/completions endpoint at https://llmtr.com/v1, using the API key from your llmtr.com account. On this row the prompt and the reply share the same 8,192 tokens. When you work with long text, split it into pieces, send each piece in its own request, and set max_tokens so that it and the prompt stay within 8,192.

The model card describes a longer context; on LLMTR this row's window is 8,192 tokens. The prompt text also cannot exceed about 32,000 characters; a longer prompt is refused with 400 invalid_request and is not billed. The model is an instruction model AI Singapore trained for Southeast Asian languages, and on LLMTR it is served by MarsCompute. It supports seven Southeast Asian languages alongside English; Turkish is not among its supported languages.

How do you fit long text into an 8,192-token window?

Work out the budget first. The window is 8,192 tokens; the more room the prompt takes, the less is left for the reply. The table shows, for three prompt sizes, how much room is left for max_tokens and what the request costs when the reply is 1,000 tokens. The values use the catalog price as of 30 October 2026, $0.60 input and $3.60 output per 1M tokens.

You cannot know the exact token count of a prompt before you send it; the same number of characters takes a different number of tokens depending on the language. A practical approach: read prompt_tokens from the usage field of the first request, work out how many characters make up one token in your text, and size the next pieces accordingly. The system message and the conversation history are part of the prompt too and come out of the same budget.

Prompt, max_tokens and cost in the 8,192-token window as of 30 October 2026
Prompt (tokens)Left for max_tokens (tokens)Cost with a 1,000-token reply
1,0007,192$0.0042
3,0005,192$0.0054
5,0003,192$0.0066

Two limits: 8,192 tokens and about 32,000 characters

This row has two separate limits. The first is the token limit: if prompt and max_tokens together exceed 8,192, the request is refused with 400. The second is the character limit: if the prompt text goes over about 32,000 characters, the request is refused with 400 invalid_request and is not billed. Which one applies first depends on the language and the writing of the text; in a text where one token covers many characters, the character limit can come before the token limit.

If you do not send max_tokens, the reply is at most 4,096 tokens. With long prompts, always send max_tokens explicitly; that way the room you give the reply and the output share of the request are written in the request itself. If the reply is cut at the max_tokens limit, finish_reason is length. In that case ask for a shorter reply, or make the prompt smaller and raise max_tokens.

Splitting long text into pieces

The Python example splits a text at paragraph breaks into pieces of 16,000 characters, has each piece summarised with max_tokens set to 1,024, and finally merges the summaries into one summary. If a piece does not fit the window, the request returns 400; the example splits that piece in two and tries again. 16,000 characters is half the 32,000-character limit and leaves room for the system message; adjust the value to the language of your text by looking at the prompt_tokens values you see in the usage field.

Context can get lost between pieces: a topic that starts in one piece may carry on in the next. Splitting at paragraph breaks reduces this. If you need to, add the last paragraph of the previous piece to the start of each piece; but every token you add makes the prompt and the bill larger, and leaves less room for max_tokens.

OpenAI Python SDK example that splits a long text into pieces, has Qwen-SEA-LION-v4.5-27B-IT summarise each piece through https://llmtr.com/v1/chat/completions and merges the summaries.

import os

from openai import BadRequestError, OpenAI

client = OpenAI(base_url="https://llmtr.com/v1", api_key=os.environ["LLMTR_API_KEY"])

MODEL = "marscompute/qwen-sea-lion-v4.5-27b"
WINDOW = 8192        # prompt and max_tokens together, on this row
MAX_TOKENS = 1024    # the room each summary may use
CHUNK_CHARS = 16000  # half of the prompt text limit of about 32,000 characters
SYSTEM = "Summarise the text in five sentences, in the language of the text."


def pieces(text, size=CHUNK_CHARS):
    """Cut on paragraph breaks; a paragraph longer than size is cut by characters."""
    part = ""
    for paragraph in text.split("\n\n"):
        if part and len(part) + len(paragraph) > size:
            yield part
            part = ""
        while len(paragraph) > size:
            yield paragraph[:size]
            paragraph = paragraph[size:]
        part += paragraph + "\n\n"
    if part.strip():
        yield part


def summarise(text):
    try:
        response = client.chat.completions.create(
            model=MODEL,
            messages=[{"role": "system", "content": SYSTEM}, {"role": "user", "content": text}],
            max_tokens=MAX_TOKENS,
        )
    except BadRequestError:
        # A 400 here means the piece did not fit the window: halve it and summarise both halves.
        if len(text) < 2000:
            raise
        half = len(text) // 2
        return summarise(text[:half]) + "\n" + summarise(text[half:])
    usage = response.usage
    print(usage.prompt_tokens, "+", MAX_TOKENS, "<=", WINDOW, response.choices[0].finish_reason)
    return response.choices[0].message.content


with open("report.txt", encoding="utf-8") as f:
    document = f.read()

summaries = [summarise(part) for part in pieces(document)]
print(summarise("\n\n".join(summaries)))

The cost of a long report

Say you split a 20,000-token report into four pieces of 5,000 tokens and ask for a 500-token summary of each. Each piece comes to $0.003 of input and $0.0018 of output, so $0.0048; the four pieces cost $0.0192. The final request that merges the four summaries, with 2,000 tokens of input and 500 tokens of output, costs $0.003. The whole report costs $0.0222.

There is no cache discount on this row: a system message sent again with every request is billed at the input price every time. Sending a 1,500-token system message with 1,000 requests costs $0.90 for that message alone. Keep the system message short, and add to each piece only the instruction that describes that piece's job. These amounts use the catalog price of 30 October 2026; real token counts vary with the language and the text.

Common mistakes

The cases you will see most often in the 8,192-token window, and how to fix them:

  • Sending the conversation history as it is with every request: as the history grows, no room is left for max_tokens. Trim old messages or replace them with a summary of a few sentences.
  • Sending a high max_tokens with a long prompt: a request whose total exceeds 8,192 returns 400. Lower max_tokens to suit the size of the prompt.
  • Trying to split the text by tokens before sending it: you cannot know a prompt's exact token count in advance. Split by characters and size the pieces by looking at prompt_tokens in the first responses.
  • Sending response_format to get the summary as JSON: on this row a JSON response_format returns 400. Describe the format of the summary in the prompt.
  • Judging the result on a single example: the result of a piecewise summary depends on how the text is split. Try a few piece sizes and, before you decide on quality, compare on your own examples.

Summarising long text in an 8,192-token window

Split the text into pieces by characters, have each piece summarised with a max_tokens that keeps the total within 8,192, and merge the summaries in a final request.

  1. Split. Split the text at paragraph breaks into pieces that stay under the limit of about 32,000 characters.
  2. Budget. Send each piece to marscompute/qwen-sea-lion-v4.5-27b with a max_tokens that keeps the total within 8,192, and read prompt_tokens from the usage field.
  3. Merge. Merge the piece summaries in a final request; split a piece that returns 400 in two and send it again.

Frequently asked questions

How high can max_tokens be on Qwen-SEA-LION-v4.5-27B-IT?

High enough that the prompt and max_tokens together stay within 8,192. With a 3,000-token prompt, max_tokens can be at most 5,192.

Is a prompt longer than 32,000 characters billed?

No. If the prompt text goes over about 32,000 characters, the request is refused with 400 invalid_request and is not billed.

What does a summary of a 20,000-token report cost?

$0.0222 with four pieces and one merge request. The price is $0.60 input and $3.60 output per 1M tokens.

Related posts