JavaScript Examples

This page introduces the JavaScript example code for the A2A Protocol.

These examples are built based on Genkit and the Gemini API.

Provided Agent Examples

  • Movie Agent: Uses the TMDB API to search for movie information and answer questions.
  • Coder Agent: Generates complete code files as Artifacts.

Testing the Agents

  1. Preparation: First, follow the setup instructions in the README file within the specific Agent directory (e.g., src/agents/movie-agent/ or src/agents/coder/).
  2. Start the Agent: Start the corresponding Agent service according to the Agent’s README instructions (e.g., use npm run agents:coder to start the Coder Agent).
  3. Start the CLI Client: In another terminal window, run the following commands to start the command-line client and interact with the Agent:
    # Set your Gemini API key (if required by the Agent)
    export GEMINI_API_KEY=<your_api_key>
    
    # Start the CLI client
    npm run a2a:cli
    # or npx tsx ./cli.ts

Please refer to the README in the specific Agent directory for more detailed configuration and running instructions.


Note: This is example code and not a production-ready library.