Skip to main content
The Claude Agent SDK is Anthropic’s official Python SDK for building agents powered by Claude. Superserve provides a production-ready deployment platform with isolation, persistence, and governance.

Quick Start

1

Install the CLI

curl -fsSL https://superserve.ai/install | sh
2

Create your agent

Create a file called agent.py with your Claude Agent:
agent.py
"""
Minimal chatbot built with Claude Agent SDK deployed on Superserve.
"""

import asyncio

from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient, TextBlock

options = ClaudeAgentOptions(
    model="sonnet",
    system_prompt="You are a helpful assistant.",
    permission_mode="bypassPermissions",
    continue_conversation=True,
)


async def main():
    async with ClaudeSDKClient(options=options) as client:
        while True:
            try:
                user_input = input()
            except EOFError:
                break
            await client.query(prompt=user_input)
            async for msg in client.receive_response():
                for block in getattr(msg, "content", []):
                    if isinstance(block, TextBlock):
                        print(block.text)


asyncio.run(main())
3

Deploy your agent

Log in and deploy your agent:
superserve login
superserve deploy agent.py --name chatbot
4

Set your API key

Configure your Anthropic API key as a secret:
superserve secrets set chatbot ANTHROPIC_API_KEY=sk-ant-...
Secrets are encrypted at rest and injected at the network level. The agent never sees them in logs or LLM context.
5

Run your agent

Start an interactive session:
superserve run chatbot
You > What is the capital of France?

Agent > The capital of France is Paris.

Completed in 1.2s

Configuration Options

The Claude Agent SDK supports various configuration options via ClaudeAgentOptions:
options = ClaudeAgentOptions(
    model="sonnet",                      # Use sonnet, opus, or haiku
    system_prompt="You are a helpful assistant.",
    permission_mode="bypassPermissions", # Or "requestPermissions" for tool confirmation
    continue_conversation=True,          # Maintain conversation history
    max_tokens=4096,                     # Maximum tokens per response
)

Model Selection

  • sonnet - Claude 3.5 Sonnet (recommended)
  • opus - Claude 3 Opus (most capable)
  • haiku - Claude 3 Haiku (fastest)

Permission Modes

  • bypassPermissions - Tools execute automatically without confirmation
  • requestPermissions - Prompt user before executing tools

Adding Tools

The Claude Agent SDK supports function calling for tools. Here’s an example with a custom tool:
agent.py
import asyncio
from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient, TextBlock

def get_weather(location: str) -> str:
    """Get the current weather for a location."""
    # Your weather API logic here
    return f"The weather in {location} is sunny."

options = ClaudeAgentOptions(
    model="sonnet",
    system_prompt="You are a helpful weather assistant.",
    tools=[get_weather],  # Register your tools
    permission_mode="bypassPermissions",
    continue_conversation=True,
)

async def main():
    async with ClaudeSDKClient(options=options) as client:
        while True:
            try:
                user_input = input()
            except EOFError:
                break
            await client.query(prompt=user_input)
            async for msg in client.receive_response():
                for block in getattr(msg, "content", []):
                    if isinstance(block, TextBlock):
                        print(block.text)

asyncio.run(main())

Deployment Configuration

Create a superserve.yaml file for advanced deployment options:
superserve.yaml
name: chatbot
command: python agent.py
secrets:
  - ANTHROPIC_API_KEY
ignore:
  - "*.pyc"
  - __pycache__
  - .git
Then deploy with:
superserve deploy

Dependencies

If your agent uses additional Python packages, create a requirements.txt:
requirements.txt
claude-agent-sdk
requests
python-dotenv
Or use pyproject.toml for more complex projects:
pyproject.toml
[project]
name = "my-chatbot"
version = "0.1.0"
dependencies = [
    "claude-agent-sdk",
    "requests",
    "python-dotenv",
]
Superserve automatically installs dependencies during deployment.

Session Persistence

The /workspace directory persists across turns and restarts:
agent.py
import asyncio
import json
from pathlib import Path
from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient, TextBlock

# Persistent storage
WORKSPACE = Path("/workspace")
HISTORY_FILE = WORKSPACE / "conversation_history.json"

def save_message(role: str, content: str):
    """Save message to persistent storage."""
    history = []
    if HISTORY_FILE.exists():
        history = json.loads(HISTORY_FILE.read_text())
    history.append({"role": role, "content": content})
    HISTORY_FILE.write_text(json.dumps(history, indent=2))

options = ClaudeAgentOptions(
    model="sonnet",
    system_prompt="You are a helpful assistant with memory.",
    permission_mode="bypassPermissions",
    continue_conversation=True,
)

async def main():
    async with ClaudeSDKClient(options=options) as client:
        # Load conversation history
        if HISTORY_FILE.exists():
            print("Resuming previous conversation...")
        
        while True:
            try:
                user_input = input()
            except EOFError:
                break
            
            save_message("user", user_input)
            
            await client.query(prompt=user_input)
            async for msg in client.receive_response():
                for block in getattr(msg, "content", []):
                    if isinstance(block, TextBlock):
                        print(block.text)
                        save_message("assistant", block.text)

asyncio.run(main())

Troubleshooting

Make sure you have a requirements.txt or pyproject.toml with claude-agent-sdk listed. Redeploy your agent:
superserve deploy agent.py --name chatbot
Set your Anthropic API key as a secret:
superserve secrets set chatbot ANTHROPIC_API_KEY=sk-ant-...
Check the agent logs:
superserve sessions list
superserve sessions logs <session-id>

Next Steps

Core Concepts

Learn about isolation, persistence, and credentials

CLI Reference

Explore deployment options and CLI commands

Secrets Management

Manage API keys and environment variables

Session Management

Work with persistent sessions

Build docs developers (and LLMs) love