Examples

This section contains framework-specific examples that show how to integrate Aeon with popular AI agent frameworks.

LangChain Example

python
1import asyncio 2from aeon import Aeon 3from langchain.agents import create_agent 4from langchain_core.tools import tool 5 6# Initialize Aeon with your credentials 7aeon = Aeon(api_key="YOUR_API", project_id=123) 8 9# Define your tools 10@tool 11def search_tool(query: str) -> str: 12 """Search for information""" 13 return f"Results for: {query}" 14 15# Setup agent 16tools = [search_tool] 17 18agent = create_agent( 19 model="claude-sonnet-4-5-20250929", 20 tools=tools, 21 system_prompt="You are a helpful assistant", 22) 23 24@aeon.track_agent(name="myAgent") 25async def agent(): 26 """Process tasks with LangChain agent""" 27 28 # Run the agent 29 result = agent.invoke({"messages": [{"role": "user", "content": event}]}) 30 31 # Return the agent response 32 return { 33 costs=0.08, 34 model="claude-sonnet-4-5-20250929", 35 }

CrewAI Example

python
1import asyncio 2from aeon import Aeon 3from crewai import Agent 4from crewai_tools import SerperDevTool 5 6# Initialize Aeon with your credentials 7aeon = Aeon(api_key="YOUR_API", project_id=123) 8 9agent = Agent( 10 role="Research Analyst", 11 goal="Find and summarize information about specific topics", 12 backstory="You are an experienced researcher with attention to detail", 13 tools=[SerperDevTool()], 14 verbose=True 15) 16 17@aeon.track_agent(name="myAgent") 18async def agent(): 19 # Run the agent 20 result = agent.kickoff(event) 21 22 # Return model and cost 23 return { 24 costs=0.08, 25 model="gpt-4", 26 }

LlamaIndex Example

python
1import asyncio 2from aeon import Aeon 3from llama_index.core.agent.workflow import FunctionAgent 4from llama_index.llms.openai import OpenAI 5 6# Initialize Aeon with your credentials 7aeon = Aeon(api_key="YOUR_API", project_id=123) 8 9# Define a simple calculator tool 10def multiply(a: float, b: float) -> float: 11 """Useful for multiplying two numbers.""" 12 return a * b 13 14# Create an agent workflow with our calculator tool 15agent = FunctionAgent( 16 tools=[multiply], 17 llm=OpenAI(model="gpt-4o-mini"), 18 system_prompt="You are a helpful assistant that can multiply two numbers.", 19) 20 21@aeon.track_agent(name="myAgent") 22async def agent(): 23 # Run the agent 24 result = await agent.run(event) 25 26 # Return model and cost 27 return { 28 costs=0.08, 29 model="gpt-4", 30 }

Notes

  • Adjust the costs and model based on your actual usage
  • All examples use hardcoded costs for simplicity - in production, calculate costs dynamically based on token usage