Core concepts
Text generation
The /infer endpoint runs text prompts, loads conversation history, and streams tokens back. Pass an explicit history, or a chat_id to persist context server-side.
A basic request
curl https://api.tnsaai.com/infer \
-H "x-api-key: $TNSA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "NGen-4.3-Pro",
"prompt": "Summarize the theory of relativity.",
"max_tokens": 300,
"temperature": 0.7,
"stream": false
}'Parameters
model— required NGen model name.prompt— required user message.max_tokens— max length of the response (default 1024).temperature— randomness, 0–2 (default 0.7).top_p— nucleus sampling (default 0.95).stream— stream tokens as they are generated (default true).
History & session caching
There are two ways to give the model conversational context:
- Explicit history — pass a
historyarray of{ role, content }turns and it is used directly. - Persistent history — pass a
chat_idand the server retrieves up to the last 40 turns for that session, appends your new prompt, and saves the reply automatically.
json
{
"model": "NGen-4.3-Pro",
"chat_id": "sess_123",
"prompt": "And summarize that in one line."
}Streaming
With stream: true (the default) the response is sent as Server-Sent Events, including token deltas, reasoning tokens, tool-call notifications and a final stats event. See Streaming for the full event format.
Reasoning models
Models like NGen-4.3-Pro can emit reasoning. When enabled, interim thinking_token events stream before the final answer.
Vision input
Multimodal models accept images. Pass base64 images in an
images array on /infer, or upload a file to /vision. See Vision.