Skip to content

Commit 390f8df

Browse files
committed
latest and clean integrations docs
1 parent a7fbc38 commit 390f8df

14 files changed

Lines changed: 334 additions & 1048 deletions

docs/v2/integrations/ag2.mdx

100644100755
Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,20 @@ os.environ["AGENTOPS_API_KEY"] = os.getenv("AGENTOPS_API_KEY")
5454

5555
Initialize AgentOps at the beginning of your application to automatically track all AG2 agent interactions:
5656

57-
<CodeGroup>
58-
```python Python
57+
<CodeGroup>
58+
```python Single Agent Conversation
5959
import agentops
6060
import autogen
61+
import os
6162

6263
# Initialize AgentOps
63-
agentops.init(<INSERT YOUR API KEY HERE>)
64+
agentops.init()
6465

6566
# Configure your AG2 agents
6667
config_list = [
6768
{
6869
"model": "gpt-4",
69-
"api_key": "<YOUR_OPENAI_API_KEY>"
70+
"api_key": os.getenv("OPENAI_API_KEY"),
7071
}
7172
]
7273

@@ -75,7 +76,7 @@ llm_config = {
7576
"timeout": 60,
7677
}
7778

78-
# Create AG2 agents
79+
# Create a single agent
7980
assistant = autogen.AssistantAgent(
8081
name="assistant",
8182
llm_config=llm_config,
@@ -95,34 +96,27 @@ user_proxy.initiate_chat(
9596
assistant,
9697
message="How can I implement a basic web scraper in Python?"
9798
)
98-
99-
# All agent interactions are automatically tracked by AgentOps
10099
```
101-
</CodeGroup>
102-
103-
## Multi-Agent Conversation Example
104-
105-
AgentOps tracks interactions across multiple AG2 agents:
106100

107-
<CodeGroup>
108-
```python Python
101+
```python Multi-Agent Conversation
102+
import os
109103
import agentops
110104
import autogen
111105

112106
# Initialize AgentOps
113-
agentops.init(<INSERT YOUR API KEY HERE>)
107+
agentops.init()
114108

115-
# Configure LLM
109+
# Configure your AG2 agents
116110
config_list = [
117111
{
118112
"model": "gpt-4",
119-
"api_key": "<YOUR_OPENAI_API_KEY>"
113+
"api_key": os.getenv("OPENAI_API_KEY"),
120114
}
121115
]
122116

123117
llm_config = {
124118
"config_list": config_list,
125-
"timeout": A 60,
119+
"timeout": 60,
126120
}
127121

128122
# Create a team of agents
@@ -169,8 +163,6 @@ user_proxy.initiate_chat(
169163
manager,
170164
message="Create a Python program to analyze sentiment from Twitter data."
171165
)
172-
173-
# All agent interactions across the group chat are automatically tracked by AgentOps
174166
```
175167
</CodeGroup>
176168

docs/v2/integrations/agents_sdk.mdx

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -59,44 +59,32 @@ OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
5959

6060
## Usage
6161

62-
Initialize AgentOps at the beginning of your application. It will automatically instrument the OpenAI Agents SDK. The "Hello World Example" below demonstrates basic usage.
62+
AgentOps will automatically instrument the OpenAI Agents SDK after being initialized. You can then create agents, run them, and track their interactions.
6363

64-
<CodeGroup>
65-
```python Hello World Example
66-
from agents import Agent, Runner
64+
```python
6765
import agentops
68-
import os # Ensure os is imported if using os.getenv
69-
70-
# Initialize AgentOps.
71-
# If AGENTOPS_API_KEY is in env, it's used. Otherwise, pass it directly.
72-
# Example: agentops.init(os.getenv("AGENTOPS_API_KEY")) or agentops.init("<YOUR_AGENTOPS_API_KEY>")
73-
agentops.init() # Assumes AGENTOPS_API_KEY is in environment
66+
from agents import Agent, Runner
7467

75-
# OpenAI client used by Agents SDK will pick up OPENAI_API_KEY from env.
68+
# Initialize AgentOps
69+
agentops.init()
7670

71+
# Create an agent with instructions
7772
agent = Agent(name="Assistant", instructions="You are a helpful assistant")
7873

7974
result = Runner.run_sync(agent, "Write a haiku about recursion in programming.")
8075
print(result.final_output)
81-
82-
# Expected Output:
83-
# Code within the code,
84-
# Functions calling themselves,
85-
# Infinite loop's dance.
8676
```
87-
</CodeGroup>
88-
89-
## Advanced Examples
9077

91-
### Handoffs Example
78+
## Examples
9279

93-
```python
80+
<CodeGroup>
81+
```python Handoffs
9482
from agents import Agent, Runner
9583
import asyncio
9684
import agentops
9785
import os
9886

99-
agentops.init() # Assumes AGENTOPS_API_KEY is in environment
87+
agentops.init()
10088

10189
spanish_agent = Agent(
10290
name="Spanish agent",
@@ -125,15 +113,13 @@ if __name__ == "__main__":
125113
asyncio.run(main())
126114
```
127115

128-
### Functions Example
129-
130-
```python
116+
```python Function Calling
131117
import asyncio
132118
from agents import Agent, Runner, function_tool
133119
import agentops
134120
import os
135121

136-
agentops.init() # Assumes AGENTOPS_API_KEY is in environment
122+
agentops.init()
137123

138124
@function_tool
139125
def get_weather(city: str) -> str:
@@ -156,27 +142,9 @@ async def main():
156142
if __name__ == "__main__":
157143
asyncio.run(main())
158144
```
145+
</CodeGroup>
159146

160-
## The Agent Loop
161-
162-
When you call `Runner.run()`, the SDK runs a loop until it gets a final output:
163-
164-
1. The LLM is called using the model and settings on the agent, along with the message history.
165-
2. The LLM returns a response, which may include tool calls.
166-
3. If the response has a final output, the loop ends and returns it.
167-
4. If the response has a handoff, the agent is set to the new agent and the loop continues from step 1.
168-
5. Tool calls are processed (if any) and tool response messages are appended. Then the loop continues from step 1.
169-
170-
You can use the `max_turns` parameter to limit the number of loop executions.
171-
172-
## Final Output
173-
174-
Final output is the last thing the agent produces in the loop:
175-
176-
- If you set an `output_type` on the agent, the final output is when the LLM returns something of that type using structured outputs.
177-
- If there's no `output_type` (i.e., plain text responses), then the first LLM response without any tool calls or handoffs is considered the final output.
178-
179-
## Examples
147+
## More Examples
180148
<CardGroup cols={2}>
181149
<Card title="Customer Service Agent" icon="notebook" href="/v2/examples/openai_agents">
182150
Demonstrates a customer service workflow

docs/v2/integrations/anthropic.mdx

Lines changed: 21 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -58,107 +58,65 @@ os.environ["AGENTOPS_API_KEY"] = os.getenv("AGENTOPS_API_KEY")
5858

5959
Initialize AgentOps at the beginning of your application to automatically track all Anthropic API calls:
6060

61-
<CodeGroup>
62-
```python Basic Usage
61+
```python
6362
import agentops
6463
import anthropic
6564

6665
# Initialize AgentOps
67-
agentops.init(<INSERT YOUR API KEY HERE>)
66+
agentops.init()
6867

6968
# Create Anthropic client
70-
client = anthropic.Anthropic(api_key="<YOUR_ANTHROPIC_API_KEY>")
69+
client = anthropic.Anthropic()
7170

7271
# Make a completion request - AgentOps will track it automatically
7372
message = client.messages.create(
74-
model="claude-3-opus-20240229",
75-
max_tokens=1000,
73+
model="claude-sonnet-4-20250514",
7674
messages=[
7775
{"role": "user", "content": "What is artificial intelligence?"}
7876
]
7977
)
8078

79+
# Print the response received
8180
print(message.content[0].text)
82-
```
83-
</CodeGroup>
84-
85-
86-
## Advanced Examples
81+
```
8782

88-
### Streaming Example
8983

90-
AgentOps automatically tracks streaming completions:
84+
## Examples
9185

92-
<CodeGroup>
93-
```python Streaming Example
86+
<CodeGroup>
87+
```python Streaming
9488
import agentops
9589
import anthropic
9690

9791
# Initialize AgentOps
98-
agentops.init(<INSERT YOUR API KEY HERE>)
92+
agentops.init()
9993

10094
# Create Anthropic client
101-
client = anthropic.Anthropic(api_key="<YOUR_ANTHROPIC_API_KEY>")
95+
client = anthropic.Anthropic()
10296

10397
# Make a streaming request
10498
with client.messages.stream(
105-
model="claude-3-haiku-20240307",
106-
max_tokens=1000,
99+
model="claude-sonnet-4-20250514",
107100
messages=[
108101
{"role": "user", "content": "Write a short poem about artificial intelligence."}
109102
]
110103
) as stream:
111104
for text in stream.text_stream:
112105
print(text, end="", flush=True)
113-
print() # Add a newline at the end
114-
```
115-
</CodeGroup>
116-
117-
### System Prompt Example
118-
119-
AgentOps tracks interactions with system prompts:
120-
121-
<CodeGroup>
122-
```python System Prompt
123-
import agentops
124-
import anthropic
125-
126-
# Initialize AgentOps
127-
agentops.init(<INSERT YOUR API KEY HERE>)
128-
129-
# Create Anthropic client
130-
client = anthropic.Anthropic(api_key="<YOUR_ANTHROPIC_API_KEY>")
131-
132-
# Make a request with a system prompt
133-
message = client.messages.create(
134-
model="claude-3-sonnet-20240229",
135-
max_tokens=1000,
136-
system="You are a helpful AI assistant with expertise in science and technology. Keep your answers concise and accurate.",
137-
messages=[
138-
{"role": "user", "content": "Explain quantum computing in simple terms."}
139-
]
140-
)
141-
142-
print(message.content[0].text)
143-
```
144-
</CodeGroup>
145-
146-
### Tool Use Example
147-
148-
AgentOps tracks tool use with Claude:
106+
print()
107+
```
149108

150-
<CodeGroup>
151109
```python Tool Use
152110
import agentops
153111
import anthropic
154112
import json
155113
from datetime import datetime
156114

157115
# Initialize AgentOps
158-
agentops.init(<INSERT YOUR API KEY HERE>)
116+
agentops.init()
159117

160118
# Create Anthropic client
161-
client = anthropic.Anthropic(api_key="<YOUR_ANTHROPIC_API_KEY>")
119+
client = anthropic.Anthropic()
162120

163121
# Define tools
164122
tools = [
@@ -179,8 +137,7 @@ def get_current_time():
179137

180138
# Make a request with tools
181139
message = client.messages.create(
182-
model="claude-3-opus-20240229",
183-
max_tokens=1000,
140+
model="claude-opus-4-20250514",
184141
tools=tools,
185142
messages=[
186143
{"role": "user", "content": "What time is it now?"}
@@ -197,8 +154,7 @@ if message.content[0].type == "tool_calls":
197154

198155
# Continue the conversation with the tool response
199156
second_message = client.messages.create(
200-
model="claude-3-opus-20240229",
201-
max_tokens=1000,
157+
model="claude-opus-4-20250514",
202158
messages=[
203159
{"role": "user", "content": "What time is it now?"},
204160
{
@@ -230,20 +186,17 @@ else:
230186
```
231187
</CodeGroup>
232188

233-
## Examples
189+
## More Examples
234190

235191
<CardGroup cols={2}>
236192
<Card title="Understanding Tools" icon="notebook" href="/v2/examples/anthropic">
237193
Claude integration with tool usage and advanced features
238194
</Card>
239-
<Card title="Async Example" icon="notebook" href="https://github.com/AgentOps-AI/agentops/blob/main/examples/anthropic/anthropic-example-async.ipynb" newTab={true}>
240-
Demonstrates asynchronous calls with the Anthropic SDK.
241-
</Card>
242195
<Card title="Sync Example" icon="notebook" href="https://github.com/AgentOps-AI/agentops/blob/main/examples/anthropic/anthropic-example-sync.ipynb" newTab={true}>
243196
Shows synchronous calls with the Anthropic SDK.
244197
</Card>
245-
<Card title="Tool Use (Alternative)" icon="notebook" href="https://github.com/AgentOps-AI/agentops/blob/main/examples/anthropic/anthropic-example-tool.ipynb" newTab={true}>
246-
Another example of tool usage with Anthropic models.
198+
<Card title="Async Example" icon="notebook" href="https://github.com/AgentOps-AI/agentops/blob/main/examples/anthropic/anthropic-example-async.ipynb" newTab={true}>
199+
Demonstrates asynchronous calls with the Anthropic SDK.
247200
</Card>
248201
</CardGroup>
249202

0 commit comments

Comments
 (0)