# Agent SDK Overview

> Build and interact with AI agents programmatically.

**URL:** https://inference.sh/docs/api/agent/overview
**Last updated:** 2026-09-18

---

Build and interact with AI agents programmatically.

---

## What is the Agent SDK?

The Agent SDK lets you:
- **Use template agents** — Chat with agents from your workspace
- **Create ad-hoc agents** — Build agents on-the-fly with custom tools
- **Handle tool calls** — Execute tools and return results
- **Stream responses** — Get real-time message updates

---

## Quick Start

### Template Agent

Use an existing agent from your workspace:

<div data-type="codegroup">

```python Python
from inferencesh import inference

client = inference(api_key="inf_your_key")

agent = client.agent("my-team/support-agent@latest")

response = agent.send_message("How can I reset my password?")
print(response.text)
```

```typescript JavaScript
import { inference } from '@inferencesh/sdk';

const client = inference({ apiKey: 'inf_your_key' });

const agent = client.agent('my-team/support-agent@latest');

const response = await agent.sendMessage('How can I reset my password?');
console.log(response.text);
```

</div>

### Ad-hoc Agent

Create an agent on-the-fly:

<div data-type="codegroup">

```python Python
from inferencesh import inference, tool, string

# Define a tool
calculator = (
    tool("calculator")
    .describe("Perform math calculations")
    .param("expression", string("Math expression"))
    .handler(lambda args: str(eval(args["expression"])))
    .build()
)

client = inference(api_key="inf_your_key")

agent = client.agent({
    "core_app": { "ref": "infsh/claude-sonnet-4@latest" },
    "system_prompt": "You are a helpful math assistant.",
    "tools": [calculator]
})

response = agent.send_message("What is 42 * 17?")
print(response.text)
```

```typescript JavaScript
import { inference, tool, string } from '@inferencesh/sdk';

const calculator = tool('calculator')
  .describe('Perform math calculations')
  .param('expression', string('Math expression'))
  .handler(args => String(eval(args.expression)))
  .build();

const client = inference({ apiKey: 'inf_your_key' });

const agent = client.agent({
  core_app: { ref: 'infsh/claude-sonnet-4@latest' },
  system_prompt: 'You are a helpful math assistant.',
  tools: [calculator]
});

const response = await agent.sendMessage('What is 42 * 17?');
console.log(response.text);
```

</div>

---

## Features

- **Template agents** — Use agents from your workspace
- **Ad-hoc agents** — Create agents on-the-fly
- **Custom tools** — Define tools with fluent API
- **Streaming** — Real-time message updates
- **Lifecycle hooks** — Observe and gate tool calls via webhooks
- **Multi-turn** — Automatic conversation state

---

## Next Steps

- [Template Agents](/docs/api/agent/template) — Use existing agents
- [Ad-hoc Agents](/docs/api/agent/adhoc) — Create agents on-the-fly
- [Building Tools](/docs/api/agent/tools) — Define custom tools
- [Lifecycle Hooks](/docs/api/agent/lifecycle-hooks) — Observe and block tool execution
- [Streaming](/docs/api/agent/streaming) — Handle real-time responses
