Skip to main content

Reminix agents for Anthropic - serve AI agents as REST APIs

Project description

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

pip install reminix-anthropic

This will also install reminix-runtime as a dependency.

Quick Start

Chat Agent (streaming conversations)

from anthropic import AsyncAnthropic
from reminix_anthropic import AnthropicChatAgent
from reminix_runtime import serve

client = AsyncAnthropic()
agent = AnthropicChatAgent(client, name="my-claude")
serve(agents=[agent])

Task Agent (structured output)

from anthropic import AsyncAnthropic
from reminix_anthropic import AnthropicTaskAgent
from reminix_runtime import serve

client = AsyncAnthropic()
schema = {
    "type": "object",
    "properties": {
        "sentiment": {"type": "string", "enum": ["positive", "negative", "neutral"]},
        "confidence": {"type": "number"},
    },
    "required": ["sentiment", "confidence"],
}
agent = AnthropicTaskAgent(client, output_schema=schema, name="sentiment-analyzer")
serve(agents=[agent])

Thread Agent (tool-calling loop)

from anthropic import AsyncAnthropic
from reminix_anthropic import AnthropicThreadAgent
from reminix_runtime import serve, tool

@tool(name="get_weather", description="Get the current weather for a city")
async def get_weather(city: str) -> dict:
    return {"temperature": 72, "condition": "sunny"}

client = AsyncAnthropic()
agent = AnthropicThreadAgent(client, tools=[get_weather], name="weather-assistant")
serve(agents=[agent])

Your agents are now available at:

  • POST /agents/{name}/invoke - Execute the agent

API Reference

AnthropicChatAgent(client, *, name, model, max_tokens, description, instructions, tags, metadata)

Create an Anthropic chat agent. Supports streaming.

Parameter Type Default Description
client AsyncAnthropic required An Anthropic async client
name str "anthropic-agent" Name for the agent (used in URL path)
model str "claude-sonnet-4-5-20250929" Model to use
max_tokens int 4096 Maximum tokens in response
description str "anthropic chat agent" Description shown in agent metadata
instructions str None System instructions merged with system messages
tags list[str] None Tags for categorizing/filtering agents
metadata dict None Custom metadata merged into agent info

Returns: AnthropicChatAgent - A Reminix chat agent instance

The chat agent:

  1. Converts incoming messages to Anthropic format
  2. Extracts system messages and merges with instructions as the system parameter
  3. Returns the assistant's text response
  4. Supports streaming via Server-Sent Events

AnthropicTaskAgent(client, *, output_schema, name, model, max_tokens, description, instructions, tags, metadata)

Create an Anthropic task agent. Returns structured output via tool-use. Does not support streaming.

Parameter Type Default Description
client AsyncAnthropic required An Anthropic async client
output_schema dict required JSON Schema defining the structured output
name str "anthropic-task-agent" Name for the agent (used in URL path)
model str "claude-sonnet-4-5-20250929" Model to use
max_tokens int 4096 Maximum tokens in response
description str "anthropic task agent" Description shown in agent metadata
instructions str None System instructions passed as system parameter
tags list[str] None Tags for categorizing/filtering agents
metadata dict None Custom metadata merged into agent info

Returns: AnthropicTaskAgent - A Reminix task agent instance

The task agent:

  1. Reads the task field from the request input
  2. Includes any additional input fields as context
  3. Forces a tool call using the provided output_schema
  4. Extracts and returns the structured result from the tool-use block

AnthropicThreadAgent(client, *, tools, name, model, max_tokens, max_turns, description, instructions, tags, metadata)

Create an Anthropic thread agent with a tool-calling loop. Does not support streaming.

Parameter Type Default Description
client AsyncAnthropic required An Anthropic async client
tools list[Tool] required List of tools available to the agent
name str "anthropic-thread-agent" Name for the agent (used in URL path)
model str "claude-sonnet-4-5-20250929" Model to use
max_tokens int 4096 Maximum tokens in response
max_turns int 10 Maximum number of tool-calling turns
description str "anthropic thread agent" Description shown in agent metadata
instructions str None System instructions merged with system messages
tags list[str] None Tags for categorizing/filtering agents
metadata dict None Custom metadata merged into agent info

Returns: AnthropicThreadAgent - A Reminix thread agent instance

The thread agent:

  1. Converts incoming messages to Anthropic format
  2. Calls the model in a loop, executing tool calls each turn
  3. Continues until the model produces a final response or max_turns is reached
  4. 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:
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?

Links

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reminix_anthropic-0.0.20.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reminix_anthropic-0.0.20-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file reminix_anthropic-0.0.20.tar.gz.

File metadata

  • Download URL: reminix_anthropic-0.0.20.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for reminix_anthropic-0.0.20.tar.gz
Algorithm Hash digest
SHA256 0822bac610f7ad86ae57d0e10b4b0bb3df3fab313929a2cdf5bd900df0c0b422
MD5 e56cfebdff23d98389df550236bf621c
BLAKE2b-256 5e0732c7db8086820110e50ef71b6e2c0a076de61801c06a57a3df87f7169708

See more details on using hashes here.

File details

Details for the file reminix_anthropic-0.0.20-py3-none-any.whl.

File metadata

  • Download URL: reminix_anthropic-0.0.20-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for reminix_anthropic-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 02fedc87f703a8ffe7ecbe214ce2e3510b90bc38bc924ce5ab6e87c968ba40bc
MD5 5b820671cef0c9efd767e97236336ee3
BLAKE2b-256 04ccc9400e3118e604496689616c26c9cb9f55b035d6a3d469bd7f96b7ae5edd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page