Python SDK

When to use: You are coding in Python, iterating from notebooks or applications, and want typed helpers during development.

1

Install or Upgrade the Package

# Standard install (includes local execution)
pip install --upgrade "glaip-sdk[local]"

# Or install without local extra (remote execution only)
pip install --upgrade glaip-sdk
2

Create and Run Your First Agent Locally

Ensure you installed glaip-sdk[local] and set your LLM provider key (for example OPENAI_API_KEY) before running locally.

from glaip_sdk.agents import Agent

agent = Agent(
    name="hello-world-agent",
    instruction="You are a friendly AI assistant.",
)

response = agent.run("Hello! How are you today?")
print(response)
3

(Optional) Connect to AIP Server

If you want to run against the remote AIP server instead of using aip-agents locally, add your API details to a .env file:

echo "AIP_API_URL=https://your-aip-instance.com" >> .env
echo "AIP_API_KEY=your-api-key-here" >> .env

When targeting the AIP server, call agent.deploy() once before running:

agent.deploy()
response = agent.run("Hello! How are you today?")

The SDK reads AIP_API_URL and AIP_API_KEY from the environment when deploying and running agents.

Optional Next Steps

  • Attach a tool (see the Tools guide) and rerun the agent.

  • Attach a file with agent.run(..., files=["/path/to/file.pdf"]) and follow the File processing guide.

  • Persist conversation context with chat_history or agent_config.memory (covered in the Agents guide).

Last updated