Examples (Hello World+)

Already completed your first run? If not, start with the Quick Start. This page collects copy-paste examples beyond the minimal case.

Tool Creation: Create tools from local Python files. The SDK uploads your files to the AIP backend where they're processed.

Tool Examples: See the Tools Guide for complete tool examples and structure requirements.

CLI IDs: When using the CLI, simply copy the ID from the aip agents list or aip tools list output. No need for complex parsing commands.

CLI JSON Output: The CLI examples use --view json + jq for safer ID extraction. Install jq with brew install jq (macOS) or apt install jq (Ubuntu).

🧰 Agent with Tool (Python)

from glaip_sdk import Client

client = Client()

# Create tool from local Python file
tool = client.create_tool(
    name="hello-tool",
    file_path="hello_tool.py"
)

# Create agent with tool
agent = client.create_agent(
    name="hello-agent",
    instruction="You are a friendly AI assistant. Use the hello world tool to greet users.",
    tools=[tool]
)

# Test the agent
agent.run("Please greet me using your hello world tool!")

# Verify
print(f"Agent ID: {agent.id}")
print(f"Tool ID: {tool.id}")

# Clean up
agent.delete()
tool.delete()

🧰 Multi-Tool Agent (Python)

from glaip_sdk import Client

client = Client()

# Create tools from local Python files
calculator_tool = client.create_tool(
    name="calculator",
    file_path="calculator_tool.py"
)

weather_tool = client.create_tool(
    name="weather",
    file_path="weather_tool.py"
)

# Create agent with multiple tools
agent = client.create_agent(
    name="multi-tool-agent",
    instruction="You are a helpful assistant with calculator and weather tools.",
    tools=[calculator_tool, weather_tool]
)

# Test the agent
agent.run("What's 15 + 27? Also, what's the weather like?")

# Verify
print(f"Agent ID: {agent.id}")
print(f"Calculator Tool ID: {calculator_tool.id}")
print(f"Weather Tool ID: {weather_tool.id}")

# Clean up
agent.delete()
calculator_tool.delete()
weather_tool.delete()

πŸ’» CLI Examples

Agent with Tool

# Create tool from local file
aip tools create \
  --file "hello_tool.py" \
  --name "hello-world-tool" \
  --description "A simple tool that says hello to users"

# Get tool ID from the list output above
aip agents create \
  --name "hello-agent" \
  --instruction "You are a friendly AI assistant. Use the hello world tool to greet users." \
  --tools <TOOL_ID>

# Get agent ID from the list output above
aip agents run <AGENT_ID> --input "Please greet me using your hello world tool!"

# Clean up
aip agents delete <AGENT_ID>
aip tools delete <TOOL_ID>

πŸ”„ Multi-Agent Collaboration

Coordinator Pattern

from glaip_sdk import Client

client = Client()

# Create specialized agents
math_agent = client.create_agent(
    name="math-specialist",
    instruction="You are a math expert. Solve mathematical problems."
)

writing_agent = client.create_agent(
    name="writing-specialist",
    instruction="You are a writing expert. Help with writing tasks."
)

# Create coordinator agent
coordinator = client.create_agent(
    name="coordinator",
    instruction="Coordinate between math and writing specialists.",
    agents=[math_agent, writing_agent]
)

# Test coordination
coordinator.run("I need help with both math and writing. Can you coordinate?")

# Clean up
coordinator.delete()
math_agent.delete()
writing_agent.delete()

🎯 What to Try Next

  1. Modify the instructions: Change agent behavior by updating the instruction text

  2. Add more tools: Create additional tools for different capabilities

  3. Experiment with models: Try different language models if available

  4. Build workflows: Create agents that can call each other

  5. Add MCPs: Connect to external services and APIs

πŸš€ Next Steps

  • Learn concepts: Understand Core Concepts

  • Build agents: Follow the Agents Guide

  • Create tools: Learn to build custom tools

  • Connect services: Explore MCP integration

πŸ’‘ Tips for Success

  • Start simple: Begin with basic agents and gradually add complexity

  • Use descriptive names: Make it easy to identify your resources

  • Always clean up: Delete resources when you're done

  • Test incrementally: Verify each step works before adding more

  • Check the logs: Use debug mode if something doesn't work as expected

These examples build on the basics from Quick Start. Copy, paste, modify, and experiment!