Getting Started
The invera SDK streams chat completions in which every generated word carries word-level attributions back to the words of your prompt. This page installs the SDK and streams a first attributed completion against a running invera Engine deployment.
Install
- TypeScript
- Python
npm install @layerwise/invera-sdk
Requires Python 3.11 or newer.
pip install invera-sdk
Stream your first attributed completion
Point the client at your Engine deployment. Discovery, compatibility checks, and tokenizer initialization happen lazily on the first request — constructing the client performs no I/O.
- TypeScript
- Python
import { InveraClient } from "@layerwise/invera-sdk";
const client = new InveraClient({
baseUrl: "https://host.example/api/invera-engine/v1",
});
for await (const chunk of client.chat.completions.stream({
messages: [{ role: "user", content: "What is attention attribution?" }],
maxTokens: 256,
})) {
console.log(chunk.content, chunk.input_attributions);
}
Deploying this default tokenizer in a Node.js container requires a glibc image and an explicitly preserved native dependency tree. Follow the Node.js and Docker deployment guide.
from invera_sdk import ChatMessage, CompletionRequest, InveraClient
client = InveraClient("https://host.example/api/invera-engine/v1")
for chunk in client.chat.completions.stream(
CompletionRequest(
messages=[ChatMessage("user", "What is attention attribution?")],
max_tokens=256,
)
):
print(chunk.content, chunk.input_attributions)
What each chunk contains
Every streamed chunk is a ready-to-consume fragment:
type—textfor visible assistant output, ortool_start/tool_delta/tool_endfor parsed tool-call fragments.content— the text of this fragment.input_attributions— scored links from this fragment's words back to words of the prompt (messages and tool definitions).output_attributions— scored links to previously generated output words.
How the attribution entries are structured and what the scores mean is covered in Understanding attribution.
Checking the connected model
client.models.current() returns stable model information for UI and
diagnostics without exposing the Engine's raw discovery schema.
Next steps
- Add evidence to text responses — turn attributed chunks into source-linked claims with grounding scores.
- Validate and gate tool calls — schema-check and risk-gate generated tool calls before executing them.
- Prepare for production — compatibility, deprecations, timeouts, and cancellation.