Build headless AI agents with custom tools.
Quick Start
Python:
python
1from inferencesh import inference, tool, string23calculator = (4 tool("calculator")5 .describe("Do math")6 .param("expression", string("Math expression"))7 .handler(lambda args: str(eval(args["expression"])))8 .build()9)1011client = inference(api_key="inf_...")12agent = client.agent({13 "core_app_ref": "infsh/claude-sonnet-4@latest",14 "system_prompt": "You help with math.",15 "tools": [calculator]16})1718response = agent.send_message("What is 42 * 17?")19print(response.text)JavaScript:
typescript
1import { inference, tool, string } from '@inferencesh/sdk';23const calculator = tool('calculator')4 .describe('Do math')5 .param('expression', string('Math expression'))6 .handler(args => String(eval(args.expression)))7 .build();89const client = inference({ apiKey: 'inf_...' });10const agent = client.agent({11 core_app_ref: 'infsh/claude-sonnet-4@latest',12 system_prompt: 'You help with math.',13 tools: [calculator]14});1516const response = await agent.sendMessage('What is 42 * 17?');17console.log(response.text);Template vs Ad-hoc Agents
| Type | Use Case |
|---|---|
| Template | Use existing agents from workspace |
| Ad-hoc | Create agents on-the-fly with custom tools |
Template Agent
python
1agent = client.agent("my-team/support-agent@latest")Ad-hoc Agent
python
1agent = client.agent({2 "core_app_ref": "infsh/claude-sonnet-4@latest",3 "system_prompt": "...",4 "tools": [...]5})Building Tools
Use the fluent builder API:
python
1from inferencesh import tool, string, number, array23search_tool = (4 tool("search")5 .describe("Search the database")6 .param("query", string("Search query"))7 .param("limit", number("Max results"))8 .handler(lambda args: search(args["query"], args["limit"]))9 .build()10)Parameter types: string, number, integer, boolean, enum_of, array, obj, optional
Streaming
Get real-time message updates. Each update contains the full message content so far (not incremental chunks):
python
1# Python2for message in agent.send_message("Hello", stream=True):3 print(message.text) # Full message contenttypescript
1// JavaScript2for await (const message of agent.sendMessage('Hello', { stream: true })) {3 console.log(message.text); // Full message content4}Learn More
Python SDK:
JavaScript SDK: