@reminix/anthropic
v0.0.22
Published
Reminix agents for Anthropic - serve AI agents as REST APIs
Downloads
301
Maintainers
Readme
@reminix/anthropic
Reminix agents for the Anthropic API. Serve Claude models as a REST API.
Ready to go live? Deploy to Reminix Cloud for zero-config hosting, or self-host on your own infrastructure.
Installation
npm install @reminix/anthropic @anthropic-ai/sdkThis will also install @reminix/runtime as a dependency.
Quick Start
Chat Agent (streaming conversations)
import Anthropic from '@anthropic-ai/sdk';
import { AnthropicChatAgent } from '@reminix/anthropic';
import { serve } from '@reminix/runtime';
const client = new Anthropic();
const agent = new AnthropicChatAgent(client, { name: 'my-claude' });
serve({ agents: [agent] });Task Agent (structured output)
import Anthropic from '@anthropic-ai/sdk';
import { AnthropicTaskAgent } from '@reminix/anthropic';
import { serve } from '@reminix/runtime';
const client = new Anthropic();
const schema = {
type: 'object',
properties: {
sentiment: { type: 'string', enum: ['positive', 'negative', 'neutral'] },
confidence: { type: 'number' },
},
required: ['sentiment', 'confidence'],
};
const agent = new AnthropicTaskAgent(client, { outputSchema: schema, name: 'sentiment-analyzer' });
serve({ agents: [agent] });Thread Agent (tool-calling loop)
import Anthropic from '@anthropic-ai/sdk';
import { AnthropicThreadAgent } from '@reminix/anthropic';
import { serve, tool } from '@reminix/runtime';
import { z } from 'zod';
const getWeather = tool('get_weather', {
description: 'Get the current weather for a city',
inputSchema: z.object({ city: z.string() }),
handler: async ({ city }) => ({ temperature: 72, condition: 'sunny' }),
});
const client = new Anthropic();
const agent = new AnthropicThreadAgent(client, { tools: [getWeather], name: 'weather-assistant' });
serve({ agents: [agent] });Your agents are now available at:
POST /agents/{name}/invoke- Execute the agent
API Reference
new AnthropicChatAgent(client, options?)
Create an Anthropic chat agent. Supports streaming.
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| client | Anthropic | required | An Anthropic client |
| options.name | string | "anthropic-agent" | Name for the agent (used in URL path) |
| options.model | string | "claude-sonnet-4-5-20250929" | Model to use |
| options.maxTokens | number | 4096 | Maximum tokens in response |
| options.description | string | "anthropic chat agent" | Description shown in agent metadata |
| options.instructions | string | — | System instructions merged with system messages |
| options.tags | string[] | — | Tags for categorizing/filtering agents |
| options.metadata | Record<string, unknown> | — | Custom metadata merged into agent info |
Returns: AnthropicChatAgent - A Reminix chat agent instance
The chat agent:
- Converts incoming messages to Anthropic format
- Extracts system messages and merges with
instructionsas thesystemparameter - Returns the assistant's text response
- Supports streaming via Server-Sent Events
new AnthropicTaskAgent(client, options)
Create an Anthropic task agent. Returns structured output via tool-use. Does not support streaming.
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| client | Anthropic | required | An Anthropic client |
| options.outputSchema | Record<string, unknown> | required | JSON Schema defining the structured output |
| options.name | string | "anthropic-task-agent" | Name for the agent (used in URL path) |
| options.model | string | "claude-sonnet-4-5-20250929" | Model to use |
| options.maxTokens | number | 4096 | Maximum tokens in response |
| options.description | string | "anthropic task agent" | Description shown in agent metadata |
| options.instructions | string | — | System instructions passed as system parameter |
| options.tags | string[] | — | Tags for categorizing/filtering agents |
| options.metadata | Record<string, unknown> | — | Custom metadata merged into agent info |
Returns: AnthropicTaskAgent - A Reminix task agent instance
The task agent:
- Reads the
taskfield from the request input - Includes any additional input fields as context
- Forces a tool call using the provided
outputSchema - Extracts and returns the structured result from the tool-use block
new AnthropicThreadAgent(client, options)
Create an Anthropic thread agent with a tool-calling loop. Does not support streaming.
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| client | Anthropic | required | An Anthropic client |
| options.tools | Tool[] | required | List of tools available to the agent |
| options.name | string | "anthropic-thread-agent" | Name for the agent (used in URL path) |
| options.model | string | "claude-sonnet-4-5-20250929" | Model to use |
| options.maxTokens | number | 4096 | Maximum tokens in response |
| options.maxTurns | number | 10 | Maximum number of tool-calling turns |
| options.description | string | "anthropic thread agent" | Description shown in agent metadata |
| options.instructions | string | — | System instructions merged with system messages |
| options.tags | string[] | — | Tags for categorizing/filtering agents |
| options.metadata | Record<string, unknown> | — | Custom metadata merged into agent info |
Returns: AnthropicThreadAgent - A Reminix thread agent instance
The thread agent:
- Converts incoming messages to Anthropic format
- Calls the model in a loop, executing tool calls each turn
- Continues until the model produces a final response or
maxTurnsis reached - Returns the full conversation including tool calls and results
System Messages
All three agents automatically handle Anthropic's system message format. System messages in your request are extracted and passed as the system parameter to the API.
// This works automatically:
const request = {
messages: [
{ role: 'system', content: 'You are a helpful assistant' },
{ role: 'user', content: 'Hello!' },
],
};Endpoint Input/Output Formats
Chat Agent -- POST /agents/{name}/invoke
Request with prompt:
{
"input": {
"prompt": "Summarize this text: ..."
}
}Request with messages:
{
"input": {
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
}
}Response:
{
"output": "Hello! How can I help you today?"
}Task Agent -- POST /agents/{name}/invoke
Request:
{
"input": {
"task": "Analyze the sentiment of this review: 'Great product, love it!'"
}
}Response:
{
"output": {
"sentiment": "positive",
"confidence": 0.95
}
}Thread Agent -- POST /agents/{name}/invoke
Request:
{
"input": {
"messages": [
{"role": "user", "content": "What's the weather in San Francisco?"}
]
}
}Response:
{
"output": [
{"role": "user", "content": "What's the weather in San Francisco?"},
{"role": "assistant", "content": "", "tool_calls": [{"id": "toolu_01...", "type": "function", "function": {"name": "get_weather", "arguments": "{\"city\": \"San Francisco\"}"}}]},
{"role": "tool", "content": "{\"temperature\": 72, \"condition\": \"sunny\"}", "tool_call_id": "toolu_01..."},
{"role": "assistant", "content": "The weather in San Francisco is 72 degrees and sunny."}
]
}Streaming
For streaming responses (chat agent only), set stream: true in the request:
{
"input": {
"prompt": "Tell me a story"
},
"stream": true
}The response will be sent as Server-Sent Events (SSE).
Runtime Documentation
For information about the server, endpoints, request/response formats, and more, see the @reminix/runtime package.
Deployment
Ready to go live?
- Deploy to Reminix Cloud - Zero-config cloud hosting
- Self-host - Run on your own infrastructure
Links
License
Apache-2.0
