Hy4 Chat at a Glance
| Item | Value |
|---|---|
| Model ID | tencent/hy4 |
| Base URL (OpenAI-compatible) | https://tokenra.io/v1 |
| Chat endpoint | https://tokenra.io/v1/chat/completions |
| Context window | 1,048,576 tokens (prompt + history + reply) |
| Maximum output | 64,000 tokens per response |
| Input price | $0.834 / 1M tokens (OpenRouter list) · $0.667 on TokenRa |
| Output price | $2.501 / 1M tokens (OpenRouter list) · $2.001 on TokenRa |
| Official release | November 4, 2026 |
Because the endpoint is OpenAI-compatible, you do not need a Hy4-specific SDK. Existing chat code keeps working when you change the base URL and the model name. For full endpoint reference, authentication options, and SDK examples, see the Hy4 API page.
Three Ways to Chat with Hy4
1. Any OpenAI-compatible chat client
A chat client that lets you set a custom OpenAI base URL and API key can talk to Hy4 directly — self-hosted interfaces
such as Open WebUI or LibreChat, or desktop clients such as Chatbox, are the usual choices. In those settings you enter
the base URL https://tokenra.io/v1, the key you generated at the gateway, and the model name
tencent/hy4. These clients are independent projects; confirm in their documentation that the version you
use supports a custom base URL.
2. A minimal Python chat loop
The smallest working chat: keep the message history in a list and send the whole list on every turn. For a full SDK reference and authentication walkthrough, see the API page.
from openai import OpenAI
client = OpenAI(
base_url="https://tokenra.io/v1",
api_key="YOUR_TOKENRA_API_KEY",
)
history = []
print("Type 'exit' to quit.")
while True:
q = input("You: ").strip()
if q.lower() in {"exit", "quit"}:
break
history.append({"role": "user", "content": q})
resp = client.chat.completions.create(
model="tencent/hy4",
messages=history,
max_tokens=2048,
)
answer = resp.choices[0].message.content
history.append({"role": "assistant", "content": answer})
print("Hy4:", answer)
Two things matter once a conversation gets long. First, the message history is re-sent every turn, so a 50-turn chat costs far more than 50 separate questions — trim or summarise older turns. Second, the 1,048,576-token context is a ceiling, not a target: keep the working window small unless the task genuinely needs the whole document.
3. A single request with curl
curl https://tokenra.io/v1/chat/completions \
-H "Authorization: Bearer $TOKENRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tencent/hy4",
"messages": [
{"role": "system", "content": "You are a concise technical assistant."},
{"role": "user", "content": "Summarise this changelog in five bullets."}
],
"max_tokens": 800,
"stream": true
}'
Prompt Patterns That Suit a 1M-Token Context
A long context changes how you should write prompts. Sending a whole repository or a 200-page PDF is possible, but the useful patterns are narrower than "paste everything".
- Put the instructions last. Long inputs push a system prompt far from the answer. Repeat the task right before the question, and the model follows it more reliably.
- Ask for citations. With a long document in context, request section or line references so you can check answers instead of trusting them.
- Use one document per turn rather than many. Six related files with clear separators outperform fifty files pasted together.
- Ask for structure. JSON, tables or numbered lists reduce vague answers and make the output machine-checkable.
- Keep a short rolling summary. For multi-session work, summarise the previous session into 300–500 tokens and carry that forward instead of the full transcript.
For evaluation, compare the same prompts against a cheaper model on routine requests. Hy4 is a good candidate for long-document reading, codebase questions and multi-step agent work; a smaller model is usually the better default for short factual questions.
What One Hy4 Chat Message Costs
Chat cost is input tokens plus output tokens. A typical exchange — a 2,000-token prompt and an 800-token reply — comes to roughly the following:
| Scenario | Input cost | Output cost | Total |
|---|---|---|---|
| One exchange, TokenRa | 2,000 × $0.667/1M = $0.0013 | 800 × $2.001/1M = $0.0016 | ≈ $0.0029 |
| One exchange, OpenRouter list | 2,000 × $0.834/1M = $0.0017 | 800 × $2.501/1M = $0.0020 | ≈ $0.0037 |
| 50-turn chat, 2,000 tokens each, TokenRa | History is re-sent every turn; actual usage grows faster than 50 × one exchange | ≈ $0.15–$0.25 | |
The third row is the one that surprises people: a 50-turn conversation does not cost 50 message prices, because each turn resends the accumulated history as input. Trimming old turns or summarising them is the cheapest single optimisation in any chat product built on a long-context model.
Hy4 Chat vs Hy4 Preview Chat
Developers who used the grey-testing model during August should note three differences before reusing old chat code.
| Item | Hy4 (official) | Hy4 Preview |
|---|---|---|
| Model ID | tencent/hy4 | tencent/hy4-preview |
| Context window | 1,048,576 tokens | 1,048,576 tokens |
| Maximum output | 64,000 tokens | 64,000 tokens |
| Input / output price | $0.834 / $2.501 per 1M | $0.834 / $2.501 per 1M |
| Visual input and computer use | Supported, per release materials | Not available |
| Hallucination rate | 5.45% | 15.76% |
In short: change the model ID and you get the same context limits and the same price, plus the new multimodal and agentic capabilities. The full history of the two versions is on the Hy4 vs Hy4 Preview page, and benchmark scores are on the benchmarks page.
Common Problems When Chatting with Hy4
The reply comes back as an error or a 404
Nine times out of ten the model name is wrong. The official release is tencent/hy4; if you carried over
tencent/hy4-preview from August, the gateway may reject it or silently route you elsewhere.
The answer is cut off mid-sentence
You hit the output ceiling you set yourself, not the model's limit. Raise max_tokens or enable
stream and read the chunks as they arrive.
Long chats get slow and expensive
This is expected: the whole history is resent as input on every turn. Summarise older turns, or start a new thread with a short carry-over summary.
The answer ignores part of a long document
Check where the instructions sit in the prompt, and whether the document was truncated at the provider's request limit. A gateway may cap request size below the model's context window — confirm that in the provider's documentation.
Frequently Asked Questions
How do I chat with Hy4?
Hy4 is served as an OpenAI-compatible chat API rather than a standalone consumer app. Point any OpenAI-compatible
client at the base URL https://tokenra.io/v1, set the model to tencent/hy4, and add your
API key. You can create an account at
tokenra.io/register to generate the key.
Is there a free way to try Hy4 chat?
Registration at the gateway is free, and after that usage is metered per token: $0.667 per 1M input tokens and $2.001 per 1M output tokens on TokenRa (20% off the OpenRouter list price of $0.834 / $2.501). Check the gateway's current free-credit terms before you rely on them.
What is the Hy4 chat model ID?
The model ID for the official release is tencent/hy4. The earlier grey-testing version used
tencent/hy4-preview.
How long a conversation can Hy4 handle?
Hy4 supports a 1,048,576-token context window covering the system prompt, the whole message history and the reply, with a maximum output of 64,000 tokens per response.
How much does one Hy4 chat message cost?
At TokenRa rates a single exchange — a 2,000-token prompt plus an 800-token reply — costs about $0.0029; at the OpenRouter list price the same exchange costs about $0.0037. Cost scales linearly with the tokens you send and receive.
Can I send images to Hy4 in a chat?
Release materials state that the official Hy4 supports visual input and computer use, which Hy4 Preview did not. Whether a specific gateway exposes image input in its chat endpoint depends on that gateway, so confirm it in the provider's documentation.