Agention is a TypeScript library for building AI agents that work with multiple providers. In this post, we'll walk through the basics: installing the library, creating your first agent, and switching providers without rewriting your code.
Installation
Agention ships as a small core package plus one package per provider, so you only install the SDKs you actually use:
npm install @agentionai/agents @anthropic-ai/sdk
Set your API key as an environment variable:
export ANTHROPIC_API_KEY=your-key-here
Creating Your First Agent
Here's a minimal example using ClaudeAgent:
import { ClaudeAgent } from "@agentionai/agents/claude";
const agent = new ClaudeAgent({
id: "assistant",
name: "Assistant",
description: "You are a helpful assistant.",
apiKey: process.env.ANTHROPIC_API_KEY,
model: "claude-sonnet-4-5",
});
const response = await agent.execute("Explain TypeScript in one sentence.");
console.log(response);
description doubles as the system prompt. It's what sets the agent's behavior.
Switching Providers
Every agent shares the same execute() interface, so moving to a different provider means swapping the class, not rewriting your calling code. Here's the same agent on OpenAI:
import { OpenAiAgent } from "@agentionai/agents/openai";
const agent = new OpenAiAgent({
id: "assistant",
name: "Assistant",
description: "You are a helpful assistant.",
apiKey: process.env.OPENAI_API_KEY,
model: "gpt-4o",
});
GeminiAgent, MistralAgent, OllamaAgent, and LlamaCppAgent all follow the same shape. The last two run entirely locally, no API key required.
What's Next
- Keep the context window lean automatically: see Context Management
- Chain multiple agents together: see Graph Pipelines
- Explore the full documentation at docs.agention.ai