# Agent Run inference queries with tools. ```bash npm install @agent-smith/agent ``` Supported backends: - [Llama.cpp](https://github.com/ggerganov/llama.cpp) - Any server that supports an OpenAI-compatible API ## Initialize an agent ### Create a language model client Create an `Lm` instance to connect to your inference backend: ```typescript import { Lm } from "@agent-smith/agent"; const lm = new Lm({ name: "llamacpp", serverUrl: "http://localhost:8080/v1", }); ``` For a remote OpenAI-compatible backend (e.g., OpenRouter): ```typescript import { Lm } from "@agent-smith/agent"; const lm = new Lm({ name: "openrouter", serverUrl: "https://openrouter.ai/api/v1", apiKey: process.env.OPENROUTER_API_KEY, }); ``` ### Initialize an agent The `Agent` constructor takes an `AgentParams` object containing the `lm` provider and optional callbacks: ```typescript import { Agent } from "@agent-smith/agent"; const agent = new Agent({ name: "my-agent", lm, onToken: (t) => process.stdout.write(t), }); ``` ### Run an inference query The `run()` method takes a prompt and an options object. Model and sampling parameters go in the `params` field: ```typescript const result = await agent.run("List the planets of the solar system", { params: { model: "qwen35b", temperature: 0.6, top_k: 40, top_p: 0.95, min_p: 0, max_tokens: 4096, }, //debug: true, //verbose: true, //tools: [get_current_weather] }); console.log(result); ``` Next: tools