Loading...
  • Costruisci
  • Amministrazione
  • Modelli e prezzi
  • Client SDK
  • Riferimento API
Search...
⌘K
Log in
Avvio rapido
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Solutions

  • AI agents
  • Code modernization
  • Coding
  • Customer support
  • Education
  • Financial services
  • Government
  • Life sciences

Partners

  • Amazon Bedrock
  • Google Cloud's Vertex AI

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Company

  • Anthropic
  • Careers
  • Economic Futures
  • Research
  • News
  • Responsible Scaling Policy
  • Security and compliance
  • Transparency

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Help and security

  • Availability
  • Status
  • Support
  • Discord

Terms and policies

  • Privacy policy
  • Responsible disclosure policy
  • Terms of service: Commercial
  • Terms of service: Consumer
  • Usage policy
Costruisci/Primi passi

Inizia con Claude Managed Agents

Crea il tuo primo agente autonomo.

Was this page helpful?

  • Concetti fondamentali
  • Prerequisiti
  • Installa la CLI
  • Installa l'SDK
  • Crea la tua prima sessione
  • Cosa sta succedendo
  • Prossimi passi

Questa guida ti accompagna nella creazione di un agente, nella configurazione di un ambiente, nell'avvio di una sessione e nello streaming delle risposte dell'agente.

Concetti fondamentali

ConceptDescription
AgentThe model, system prompt, tools, MCP servers, and skills
EnvironmentConfiguration for where sessions run: an Anthropic-managed cloud container, or a self-hosted sandbox on your own infrastructure
SessionA running agent instance within an environment, performing a specific task and generating outputs
EventsMessages exchanged between your application and the agent (user turns, tool results, status updates)

Prerequisiti

  • Un account Console Anthropic
  • Una chiave API

Installa la CLI

Verifica l'installazione:

ant --version

Installa l'SDK

Imposta la tua chiave API come variabile d'ambiente:

export ANTHROPIC_API_KEY="your-api-key-here"

Crea la tua prima sessione

Tutte le richieste API di Managed Agents richiedono l'header beta managed-agents-2026-04-01. L'SDK imposta l'header beta automaticamente.

Cosa sta succedendo

Quando invii un evento utente, Claude Managed Agents:

  1. Provisiona un container: La configurazione del tuo ambiente determina come viene costruito.
  2. Esegue il ciclo dell'agente: Claude decide quali strumenti utilizzare in base al tuo messaggio
  3. Esegue gli strumenti: Scritture di file, comandi bash e altre chiamate agli strumenti vengono eseguiti all'interno del container
  4. Trasmette eventi in streaming: Ricevi aggiornamenti in tempo reale mentre l'agente lavora
  5. Va in stato idle: L'agente emette un evento session.status_idle quando non ha più nulla da fare

Prossimi passi

Definisci il tuo agente

Crea configurazioni di agente riutilizzabili e con versioning

  1. 1

    Crea un agente

    Crea un agente che definisce il modello, il prompt di sistema e gli strumenti disponibili.

    ant beta:agents create \
      --name "Coding Assistant" \
      --model '{id: claude-opus-4-7}' \
      --system "You are a helpful coding assistant. Write clean, well-documented code." \
      --tool '{type: agent_toolset_20260401}'

    Il tipo di strumento agent_toolset_20260401 abilita l'intero set di strumenti agente predefiniti (bash, operazioni sui file, ricerca web e altro). Consulta Strumenti per l'elenco completo e le opzioni di configurazione per singolo strumento.

    Salva l'agent.id restituito. Lo utilizzerai come riferimento in ogni sessione che crei.

  2. 2

    Crea un ambiente

    Un ambiente definisce il container in cui viene eseguito il tuo agente.

    ant beta:environments create \
      --name "quickstart-env" \
      --config '{type: cloud, networking: {type: unrestricted}}'

    Salva l'environment.id restituito. Lo utilizzerai come riferimento in ogni sessione che crei.

  3. 3

    Avvia una sessione

    Crea una sessione che fa riferimento al tuo agente e al tuo ambiente.

    session = client.beta.sessions.create(
        agent=agent.id,
        environment_id=environment.id,
        title="Quickstart session",
    )
    
    print(f"Session ID: {session.id}")
  4. 4

    Invia un messaggio e ricevi la risposta in streaming

    Apri uno stream, invia un evento utente, quindi elabora gli eventi man mano che arrivano:

    with client.beta.sessions.events.stream(session.id) as stream:
        # Send the user message after the stream opens
        client.beta.sessions.events.send(
            session.id,
            events=[
                {
                    "type": "user.message",
                    "content": [
                        {
                            "type": "text",
                            "text": "Create a Python script that generates the first 20 Fibonacci numbers and saves them to fibonacci.txt",
                        },
                    ],
                },
            ],
        )
    
        # Process streaming events
        for event in stream:
            match event.type:
                case "agent.message":
                    for block in event.content:
                        print(block.text, end="")
                case "agent.tool_use":
                    print(f"\n[Using tool: {event.name}]")
                case "session.status_idle":
                    print("\n\nAgent finished.")
                    break

    L'agente scriverà uno script Python, lo eseguirà nel container e verificherà che il file di output sia stato creato. Il tuo output sarà simile a questo:

    I'll create a Python script that generates the first 20 Fibonacci numbers and saves them to a file.
    [Using tool: write]
    [Using tool: bash]
    The script ran successfully. Let me verify the output file.
    [Using tool: bash]
    fibonacci.txt contains the first 20 Fibonacci numbers (0 through 4181).
    
    Agent finished.
Configura gli ambienti

Personalizza le impostazioni di rete e del container

Strumenti dell'agente

Abilita strumenti specifici per il tuo agente

Eventi e streaming

Gestisci gli eventi e guida l'agente durante l'esecuzione