Loading...
    • Costruisci
    • Admin
    • Modelli e prezzi
    • Client SDK
    • Riferimento API
    Search...
    ⌘K
    Primi passi
    Introduzione a ClaudeAvvio rapido
    Costruire con Claude
    Panoramica delle funzionalitàUtilizzo delle Messages APIGestione dei motivi di arresto
    Capacità del modello
    Ragionamento estesoRagionamento adattivoImpegnoModalità rapida (beta: anteprima di ricerca)Output strutturatiCitazioniMessaggi in streamingElaborazione batchRisultati di ricercaRifiuti in streamingSupporto multilingueEmbeddings
    Strumenti
    PanoramicaCome funziona l'uso degli strumentiStrumento di ricerca webStrumento di recupero webStrumento di esecuzione del codiceStrumento di memoriaStrumento BashStrumento di utilizzo del computerStrumento editor di testo
    Infrastruttura degli strumenti
    Ricerca strumentiChiamata programmatica degli strumentiStreaming granulare degli strumenti
    Gestione del contesto
    Finestre di contestoCompattazioneModifica del contestoCaching dei promptConteggio dei token
    Lavorare con i file
    Files APISupporto PDFImmagini e visione
    Skills
    PanoramicaAvvio rapidoBest practiceSkills per l'impresaSkills nell'API
    MCP
    Server MCP remotiConnettore MCP
    Prompt engineering
    PanoramicaBest practice per i promptStrumenti di prompting in Console
    Testa e valuta
    Definisci il successo e crea valutazioniUtilizzo dello strumento di valutazione in ConsoleRiduzione della latenza
    Rafforzare i guardrail
    Ridurre le allucinazioniAumentare la coerenza dell'outputMitigare i jailbreakRidurre la perdita di prompt
    Risorse
    Glossario
    Note di rilascio
    Claude Platform
    Console
    Log in
    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
    • Catalog
    • 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
    • Catalog
    • 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
    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
    EnvironmentA configured container template (packages, network access)
    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.

      set -euo pipefail
      
      agent=$(
        curl -sS --fail-with-body https://api.anthropic.com/v1/agents \
          -H "x-api-key: $ANTHROPIC_API_KEY" \
          -H "anthropic-version: 2023-06-01" \
          -H "anthropic-beta: managed-agents-2026-04-01" \
          -H "content-type: application/json" \
          -d @- <<'EOF'
      {
        "name": "Coding Assistant",
        "model": "claude-sonnet-4-6",
        "system": "You are a helpful coding assistant. Write clean, well-documented code.",
        "tools": [
          {"type": "agent_toolset_20260401"}
        ]
      }
      EOF
      )
      
      AGENT_ID=$(jq -er '.id' <<<"$agent")
      AGENT_VERSION=$(jq -er '.version' <<<"$agent")
      
      echo "Agent ID: $AGENT_ID, version: $AGENT_VERSION"

      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.

      environment=$(
        curl -sS --fail-with-body https://api.anthropic.com/v1/environments \
          -H "x-api-key: $ANTHROPIC_API_KEY" \
          -H "anthropic-version: 2023-06-01" \
          -H "anthropic-beta: managed-agents-2026-04-01" \
          -H "content-type: application/json" \
          -d @- <<'EOF'
      {
        "name": "quickstart-env",
        "config": {
          "type": "cloud",
          "networking": {"type": "unrestricted"}
        }
      }
      EOF
      )
      
      ENVIRONMENT_ID=$(jq -er '.id' <<<"$environment")
      
      echo "Environment ID: $ENVIRONMENT_ID"

      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=$(
        curl -sS --fail-with-body https://api.anthropic.com/v1/sessions \
          -H "x-api-key: $ANTHROPIC_API_KEY" \
          -H "anthropic-version: 2023-06-01" \
          -H "anthropic-beta: managed-agents-2026-04-01" \
          -H "content-type: application/json" \
          -d @- <<EOF
      {
        "agent": "$AGENT_ID",
        "environment_id": "$ENVIRONMENT_ID",
        "title": "Quickstart session"
      }
      EOF
      )
      
      SESSION_ID=$(jq -er '.id' <<<"$session")
      
      echo "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:

      # Send the user message first; the API buffers events until the stream attaches
      curl -sS --fail-with-body \
        "https://api.anthropic.com/v1/sessions/$SESSION_ID/events" \
        -H "x-api-key: $ANTHROPIC_API_KEY" \
        -H "anthropic-version: 2023-06-01" \
        -H "anthropic-beta: managed-agents-2026-04-01" \
        -H "content-type: application/json" \
        -d @- >/dev/null <<'EOF'
      {
        "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"
              }
            ]
          }
        ]
      }
      EOF
      
      # Open the SSE stream and process events as they arrive
      while IFS= read -r line; do
        [[ $line == data:* ]] || continue
        json=${line#data: }
        case $(jq -r '.type' <<<"$json") in
          agent.message)
            jq -j '.content[] | select(.type == "text") | .text' <<<"$json"
            ;;
          agent.tool_use)
            printf '\n[Using tool: %s]\n' "$(jq -r '.name' <<<"$json")"
            ;;
          session.status_idle)
            printf '\n\nAgent finished.\n'
            break
            ;;
        esac
      done < <(
        curl -sS -N --fail-with-body \
          "https://api.anthropic.com/v1/sessions/$SESSION_ID/stream" \
          -H "x-api-key: $ANTHROPIC_API_KEY" \
          -H "anthropic-version: 2023-06-01" \
          -H "anthropic-beta: managed-agents-2026-04-01" \
          -H "Accept: text/event-stream"
      )

      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