Anvia SDK ​
The Anvia SDK is a set of TypeScript runtime primitives for model calls, agents, tools, structured data, retrieval, workflows, application transports, and observability.
Anvia owns the model-facing runtime. Your application continues to own credentials, authentication, permissions, product data, persistence, side effects, deployment, and the response shown to users.
Start with the smallest runtime shape ​
Choose the primitive that matches the work instead of starting every feature with an agent.
Use a completion for one model call ​
A completion is appropriate when application code already knows the exact input and owns the entire flow.
import { generateCompletion } from '@anvia/core'
const result = await generateCompletion({
prompt: 'Summarize this support ticket in one paragraph.',
model,
instructions: 'Keep the summary factual and concise.'
})
console.log(result.text)generateCompletion() normalizes the request, response, content, and token usage. It does not run tools or persist conversation memory.
Use an agent for reusable behavior ​
An agent is appropriate when instructions should be reused or the task may need tools, memory, context, approvals, guardrails, or multiple model turns.
import { Agent } from '@anvia/core'
const supportAgent = new Agent({
id: 'support',
model,
instructions: 'Answer support questions clearly. Ask for missing details.',
maxTurns: 4,
})
const response = await supportAgent.generate({
prompt: 'What should I check when a password reset email does not arrive?'
})In the v1 API, agents are constructed directly and runs start with generate() or stream().
Add capabilities as the product grows ​
The SDK is organized around explicit dependencies:
- Models connect provider packages to the provider-neutral runtime.
- Completions perform direct model calls.
- Agents coordinate reusable behavior and model/tool turns.
- Guardrails enforce or observe input and output policies.
- Evaluations check behavior against versioned cases and metrics.
- Tools expose typed application-owned actions.
- Memory loads and appends durable session messages.
- Knowledges attach documents and retrieval indexes.
- Structured output turns model responses into validated data.
- Pipelines compose repeatable sequential and parallel workflows.
- Streaming exposes normalized runtime events.
- Server and React connect the runtime to product interfaces.
- Observability records runs, generations, tools, usage, and traces.
These capabilities extend the same runtime objects. Adding memory to an agent or observability to a pipeline does not require moving the feature into a different framework.
Install Anvia v1 ​
Install the core runtime and one provider package from the same release channel:
pnpm add @anvia/core @anvia/openaiimport { Agent } from '@anvia/core'
import { OpenAIClient } from '@anvia/openai'
const apiKey = process.env.OPENAI_API_KEY
if (!apiKey) {
throw new Error('OPENAI_API_KEY is required')
}
const client = new OpenAIClient({ apiKey })
const agent = new Agent({
id: 'assistant',
model: client.completionModel({
modelId: 'gpt-5.6-sol',
api: "responses"
}),
instructions: 'Answer clearly and concisely.',
})
const response = await agent.generate({
prompt: 'Explain Anvia in one sentence.'
})
if (response.type === 'response') {
console.log(response.output)
}Provider clients receive configuration explicitly. They do not load environment variables on their own.
Learn in order ​
- Install and setup verifies the provider connection with a direct completion.
- Your first agent adds reusable instructions and bounded execution.
- Tools connects the model to application-owned reads and actions.
- Memory adds durable conversation identity.
- Build applications exposes runtime events from a server.
For a complete package map, continue to the Package catalog.