agi-python 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. agi_python-0.0.1/LICENSE +21 -0
  2. agi_python-0.0.1/MANIFEST.in +11 -0
  3. agi_python-0.0.1/PKG-INFO +363 -0
  4. agi_python-0.0.1/README.md +325 -0
  5. agi_python-0.0.1/agi/__init__.py +70 -0
  6. agi_python-0.0.1/agi/_http.py +135 -0
  7. agi_python-0.0.1/agi/_session_context.py +345 -0
  8. agi_python-0.0.1/agi/_sse.py +77 -0
  9. agi_python-0.0.1/agi/client.py +142 -0
  10. agi_python-0.0.1/agi/exceptions.py +43 -0
  11. agi_python-0.0.1/agi/py.typed +0 -0
  12. agi_python-0.0.1/agi/resources/__init__.py +5 -0
  13. agi_python-0.0.1/agi/resources/sessions.py +358 -0
  14. agi_python-0.0.1/agi/types/__init__.py +39 -0
  15. agi_python-0.0.1/agi/types/results.py +183 -0
  16. agi_python-0.0.1/agi/types/sessions.py +119 -0
  17. agi_python-0.0.1/agi/types/shared.py +26 -0
  18. agi_python-0.0.1/agi_python.egg-info/PKG-INFO +363 -0
  19. agi_python-0.0.1/agi_python.egg-info/SOURCES.txt +35 -0
  20. agi_python-0.0.1/agi_python.egg-info/dependency_links.txt +1 -0
  21. agi_python-0.0.1/agi_python.egg-info/requires.txt +12 -0
  22. agi_python-0.0.1/agi_python.egg-info/top_level.txt +1 -0
  23. agi_python-0.0.1/pyproject.toml +142 -0
  24. agi_python-0.0.1/setup.cfg +4 -0
  25. agi_python-0.0.1/tests/__init__.py +1 -0
  26. agi_python-0.0.1/tests/conftest.py +145 -0
  27. agi_python-0.0.1/tests/integration/__init__.py +1 -0
  28. agi_python-0.0.1/tests/integration/test_comprehensive.py +337 -0
  29. agi_python-0.0.1/tests/integration/test_edge_cases.py +304 -0
  30. agi_python-0.0.1/tests/integration/test_examples.py +141 -0
  31. agi_python-0.0.1/tests/integration/test_sessions.py +109 -0
  32. agi_python-0.0.1/tests/integration/test_smoke.py +168 -0
  33. agi_python-0.0.1/tests/integration/test_snapshots.py +229 -0
  34. agi_python-0.0.1/tests/unit/__init__.py +1 -0
  35. agi_python-0.0.1/tests/unit/test_client.py +54 -0
  36. agi_python-0.0.1/tests/unit/test_error_handling.py +140 -0
  37. agi_python-0.0.1/tests/unit/test_session_context.py +215 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AGI Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ include SECURITY.md
5
+ include CONTRIBUTING.md
6
+ include pyproject.toml
7
+ recursive-include pyagi *.py py.typed
8
+ recursive-include tests *.py
9
+ recursive-exclude * __pycache__
10
+ recursive-exclude * *.pyc
11
+ recursive-exclude * *.pyo
@@ -0,0 +1,363 @@
1
+ Metadata-Version: 2.4
2
+ Name: agi-python
3
+ Version: 0.0.1
4
+ Summary: Official Python SDK for AGI.tech API
5
+ Author-email: AGI Inc <kaushik@theagi.company>
6
+ Maintainer-email: AGI Inc <kaushik@theagi.company>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/agi-inc/agi-python
9
+ Project-URL: Documentation, https://docs.agi.tech
10
+ Project-URL: Repository, https://github.com/agi-inc/agi-python
11
+ Project-URL: Issues, https://github.com/agi-inc/agi-python/issues
12
+ Project-URL: Changelog, https://github.com/agi-inc/agi-python/releases
13
+ Keywords: agi,automation,browser,ai,agent,api,sdk
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: Internet :: WWW/HTTP
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: httpx>=0.27.0
27
+ Requires-Dist: pydantic>=2.0.0
28
+ Requires-Dist: typing-extensions>=4.5.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
31
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
32
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
33
+ Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
34
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
35
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
36
+ Requires-Dist: pre-commit>=3.0.0; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ <div align="center">
40
+
41
+ <img src="https://cdn.prod.website-files.com/67be56277f6d514dcad939e2/67e48dd1cdab04c17a311669_logo-agi-white.png" alt="AGI" width="120"/>
42
+
43
+ <h1>AGI Python SDK</h1>
44
+
45
+ <p>
46
+ <a href="https://www.theagi.company/">Website</a> •
47
+ <a href="https://docs.agi.tech">Documentation</a> •
48
+ <a href="https://platform.agi.tech">Platform</a> •
49
+ <a href="https://theagi.company/blog">Blog</a>
50
+ </p>
51
+
52
+ ---
53
+
54
+ **AI agent that actually works on the web.**
55
+
56
+ <br />
57
+
58
+ </div>
59
+
60
+ ```python
61
+ from agi import AGIClient
62
+
63
+ client = AGIClient()
64
+
65
+ with client.session("agi-0") as session:
66
+ result = session.run_task(
67
+ "Find three nonstop flights from SFO to JFK next month under $450. "
68
+ "Return flight times, airlines, and booking links."
69
+ )
70
+ print(result)
71
+ ```
72
+
73
+ <br />
74
+
75
+ > Powered by [AGI.tech](https://agi.tech) - the world's most capable computer agent. Trusted by [Visa](https://www.theagi.company/blog/agi-inc-visa) for agentic commerce. Evaluated with [REAL Bench](https://www.theagi.company/blog/introducing-real-bench).
76
+
77
+ <br />
78
+
79
+ ## Installation
80
+
81
+ ```bash
82
+ pip install agi-python
83
+ ```
84
+
85
+ Get your API key at [platform.agi.tech](https://platform.agi.tech/api-keys)
86
+
87
+ ```bash
88
+ export AGI_API_KEY="your-api-key"
89
+ ```
90
+
91
+ ## Quick Start
92
+
93
+ ### Simple Task
94
+
95
+ ```python
96
+ from agi import AGIClient
97
+
98
+ client = AGIClient()
99
+
100
+ with client.session("agi-0") as session:
101
+ result = session.run_task("Find the cheapest iPhone 15 on Amazon")
102
+ print(result)
103
+ ```
104
+
105
+ ### Real-Time Event Streaming
106
+
107
+ ```python
108
+ with client.session("agi-0") as session:
109
+ session.send_message("Research the top 5 AI companies in 2025")
110
+
111
+ for event in session.stream_events():
112
+ if event.event == "thought":
113
+ print(f"💭 Agent: {event.data}")
114
+ elif event.event == "done":
115
+ print(f"✅ Result: {event.data}")
116
+ break
117
+ ```
118
+
119
+ ### Session Control
120
+
121
+ ```python
122
+ with client.session("agi-0") as session:
123
+ session.send_message("Long research task...")
124
+
125
+ # Control execution
126
+ session.pause() # Pause the agent
127
+ session.resume() # Resume later
128
+ session.cancel() # Or cancel
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Core Concepts
134
+
135
+ *Understanding the building blocks of agi*
136
+
137
+ ### Sessions: The Container for Tasks
138
+
139
+ Every task runs inside a **session** - an isolated browser environment:
140
+
141
+ ```python
142
+ # Context manager (recommended) - automatic cleanup
143
+ with client.session("agi-0") as session:
144
+ session.run_task("Find flights...")
145
+
146
+ # Manual management - full control
147
+ session = client.sessions.create(agent_name="agi-0")
148
+ client.sessions.send_message(session.session_id, "task")
149
+ client.sessions.delete(session.session_id)
150
+ ```
151
+
152
+ ▸ Use context managers for most tasks. Use manual management when you need fine-grained control.
153
+
154
+ ### Available Agents
155
+
156
+ - **agi-0** - General purpose agent (recommended)
157
+ - **agi-0-fast** - Faster agent for simple tasks
158
+ - **agi-1** - Advanced agent with enhanced capabilities
159
+
160
+ See [docs.agi.tech](https://docs.agi.tech) for the full list.
161
+
162
+ ---
163
+
164
+ ## Features
165
+
166
+ - **Natural Language** - Describe tasks in plain English, no selectors or scraping code
167
+ - **Real-Time Streaming** - Watch agent execution live with Server-Sent Events
168
+ - **Session Control** - Pause, resume, or cancel long-running tasks
169
+ - **Browser Control** - Navigate and screenshot for visual debugging
170
+ - **Type-Safe** - Full type hints with Pydantic validation
171
+ - **Production-Ready** - Built-in retries, automatic cleanup, comprehensive error handling
172
+
173
+ ---
174
+
175
+ ## Common Use Cases
176
+
177
+ ### Price Monitoring
178
+
179
+ Monitor product prices and availability across retailers.
180
+
181
+ ```python
182
+ with client.session("agi-0") as session:
183
+ result = session.run_task(
184
+ "Go to amazon.com and search for 'Sony WH-1000XM5'. "
185
+ "Get the current price, check if it's in stock, and return the product rating. "
186
+ "Return as JSON with fields: price, in_stock, rating, url."
187
+ )
188
+ ```
189
+
190
+ ### Lead Generation
191
+
192
+ Extract structured data from public sources.
193
+
194
+ ```python
195
+ with client.session("agi-0") as session:
196
+ result = session.run_task(
197
+ "Go to ycombinator.com/companies, find companies in the 'AI' category "
198
+ "from the latest batch. For the first 10 companies, get their name, "
199
+ "description, and website. Return as a JSON array."
200
+ )
201
+ ```
202
+
203
+ ### Flight Booking Research
204
+
205
+ ```python
206
+ with client.session("agi-0") as session:
207
+ result = session.run_task(
208
+ "Find three nonstop SFO→JFK flights next month under $450. "
209
+ "Compare prices on Google Flights, Kayak, and Expedia. "
210
+ "Return flight details and booking links."
211
+ )
212
+ ```
213
+
214
+ <details>
215
+ <summary><b>Browser Control</b> – Navigate and take screenshots for visual debugging</summary>
216
+
217
+ <br />
218
+
219
+ ```python
220
+ with client.session("agi-0") as session:
221
+ # Navigate to specific URL
222
+ session.navigate("https://amazon.com")
223
+
224
+ # Get screenshot for debugging
225
+ screenshot = session.screenshot()
226
+ print(screenshot.url) # Current page URL
227
+ print(screenshot.title) # Page title
228
+ # screenshot.screenshot contains base64 JPEG data
229
+ ```
230
+
231
+ </details>
232
+
233
+ <details>
234
+ <summary><b>Session Snapshots</b> – Preserve authentication and browser state</summary>
235
+
236
+ <br />
237
+
238
+ ```python
239
+ # Create session and save environment
240
+ session1 = client.sessions.create(agent_name="agi-0")
241
+ # ... do some work ...
242
+ client.sessions.delete(session1.session_id, save_snapshot_mode="filesystem")
243
+
244
+ # Later, restore from saved environment
245
+ session2 = client.sessions.create(
246
+ agent_name="agi-0",
247
+ restore_from_environment_id=session1.environment_id
248
+ )
249
+ # Authentication state and cookies preserved!
250
+ ```
251
+
252
+ </details>
253
+
254
+ <details>
255
+ <summary><b>Advanced Session Management</b> – Full control over session lifecycle</summary>
256
+
257
+ <br />
258
+
259
+ ```python
260
+ # Create session manually
261
+ session = client.sessions.create(
262
+ agent_name="agi-0-fast",
263
+ webhook_url="https://yourapp.com/webhook",
264
+ max_steps=200
265
+ )
266
+
267
+ # Send message
268
+ client.sessions.send_message(
269
+ session.session_id,
270
+ "Find flights from SFO to JFK under $450"
271
+ )
272
+
273
+ # Check status
274
+ status = client.sessions.get_status(session.session_id)
275
+ print(status.status) # "running", "finished", etc.
276
+
277
+ # List all sessions
278
+ sessions = client.sessions.list()
279
+
280
+ # Delete when done
281
+ client.sessions.delete(session.session_id)
282
+ ```
283
+
284
+ </details>
285
+
286
+ <details>
287
+ <summary><b>Webhooks</b> – Get notified when tasks complete</summary>
288
+
289
+ <br />
290
+
291
+ ```python
292
+ session = client.sessions.create(
293
+ agent_name="agi-0",
294
+ webhook_url="https://yourapp.com/webhook"
295
+ )
296
+
297
+ # Your webhook will receive events:
298
+ # POST https://yourapp.com/webhook
299
+ # {
300
+ # "event": "done",
301
+ # "session_id": "sess_...",
302
+ # "data": {...}
303
+ # }
304
+ ```
305
+
306
+ </details>
307
+
308
+ ---
309
+
310
+ ## Error Handling
311
+
312
+ <details>
313
+ <summary><b>Robust error handling with detailed debugging</b></summary>
314
+
315
+ <br />
316
+
317
+ ```python
318
+ from agi import (
319
+ AGIClient,
320
+ AuthenticationError,
321
+ NotFoundError,
322
+ RateLimitError,
323
+ AgentExecutionError
324
+ )
325
+
326
+ client = AGIClient()
327
+
328
+ try:
329
+ with client.session("agi-0") as session:
330
+ result = session.run_task("Find flights...")
331
+ except AuthenticationError:
332
+ print("Invalid API key")
333
+ except NotFoundError:
334
+ print("Session not found")
335
+ except RateLimitError:
336
+ print("Rate limit exceeded - please retry")
337
+ except AgentExecutionError as e:
338
+ print(f"Task failed: {e}")
339
+ # Debug at VNC URL if available
340
+ except AGIError as e:
341
+ print(f"API error: {e}")
342
+ ```
343
+
344
+ </details>
345
+
346
+ ---
347
+
348
+ ## Documentation & Resources
349
+
350
+ **Learn More**
351
+ - [API Reference](https://docs.agi.tech) – Complete API documentation
352
+ - [Code Examples](./examples) – Working examples for common tasks
353
+ - [GitHub Issues](https://github.com/agi-inc/agi-python/issues) – Report bugs or request features
354
+
355
+ **Get Help**
356
+ - [Platform](https://platform.agi.tech) – Manage API keys and monitor usage
357
+ - [Documentation](https://docs.agi.tech) – Guides and tutorials
358
+
359
+ ---
360
+
361
+ ## License
362
+
363
+ MIT License - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,325 @@
1
+ <div align="center">
2
+
3
+ <img src="https://cdn.prod.website-files.com/67be56277f6d514dcad939e2/67e48dd1cdab04c17a311669_logo-agi-white.png" alt="AGI" width="120"/>
4
+
5
+ <h1>AGI Python SDK</h1>
6
+
7
+ <p>
8
+ <a href="https://www.theagi.company/">Website</a> •
9
+ <a href="https://docs.agi.tech">Documentation</a> •
10
+ <a href="https://platform.agi.tech">Platform</a> •
11
+ <a href="https://theagi.company/blog">Blog</a>
12
+ </p>
13
+
14
+ ---
15
+
16
+ **AI agent that actually works on the web.**
17
+
18
+ <br />
19
+
20
+ </div>
21
+
22
+ ```python
23
+ from agi import AGIClient
24
+
25
+ client = AGIClient()
26
+
27
+ with client.session("agi-0") as session:
28
+ result = session.run_task(
29
+ "Find three nonstop flights from SFO to JFK next month under $450. "
30
+ "Return flight times, airlines, and booking links."
31
+ )
32
+ print(result)
33
+ ```
34
+
35
+ <br />
36
+
37
+ > Powered by [AGI.tech](https://agi.tech) - the world's most capable computer agent. Trusted by [Visa](https://www.theagi.company/blog/agi-inc-visa) for agentic commerce. Evaluated with [REAL Bench](https://www.theagi.company/blog/introducing-real-bench).
38
+
39
+ <br />
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ pip install agi-python
45
+ ```
46
+
47
+ Get your API key at [platform.agi.tech](https://platform.agi.tech/api-keys)
48
+
49
+ ```bash
50
+ export AGI_API_KEY="your-api-key"
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ ### Simple Task
56
+
57
+ ```python
58
+ from agi import AGIClient
59
+
60
+ client = AGIClient()
61
+
62
+ with client.session("agi-0") as session:
63
+ result = session.run_task("Find the cheapest iPhone 15 on Amazon")
64
+ print(result)
65
+ ```
66
+
67
+ ### Real-Time Event Streaming
68
+
69
+ ```python
70
+ with client.session("agi-0") as session:
71
+ session.send_message("Research the top 5 AI companies in 2025")
72
+
73
+ for event in session.stream_events():
74
+ if event.event == "thought":
75
+ print(f"💭 Agent: {event.data}")
76
+ elif event.event == "done":
77
+ print(f"✅ Result: {event.data}")
78
+ break
79
+ ```
80
+
81
+ ### Session Control
82
+
83
+ ```python
84
+ with client.session("agi-0") as session:
85
+ session.send_message("Long research task...")
86
+
87
+ # Control execution
88
+ session.pause() # Pause the agent
89
+ session.resume() # Resume later
90
+ session.cancel() # Or cancel
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Core Concepts
96
+
97
+ *Understanding the building blocks of agi*
98
+
99
+ ### Sessions: The Container for Tasks
100
+
101
+ Every task runs inside a **session** - an isolated browser environment:
102
+
103
+ ```python
104
+ # Context manager (recommended) - automatic cleanup
105
+ with client.session("agi-0") as session:
106
+ session.run_task("Find flights...")
107
+
108
+ # Manual management - full control
109
+ session = client.sessions.create(agent_name="agi-0")
110
+ client.sessions.send_message(session.session_id, "task")
111
+ client.sessions.delete(session.session_id)
112
+ ```
113
+
114
+ ▸ Use context managers for most tasks. Use manual management when you need fine-grained control.
115
+
116
+ ### Available Agents
117
+
118
+ - **agi-0** - General purpose agent (recommended)
119
+ - **agi-0-fast** - Faster agent for simple tasks
120
+ - **agi-1** - Advanced agent with enhanced capabilities
121
+
122
+ See [docs.agi.tech](https://docs.agi.tech) for the full list.
123
+
124
+ ---
125
+
126
+ ## Features
127
+
128
+ - **Natural Language** - Describe tasks in plain English, no selectors or scraping code
129
+ - **Real-Time Streaming** - Watch agent execution live with Server-Sent Events
130
+ - **Session Control** - Pause, resume, or cancel long-running tasks
131
+ - **Browser Control** - Navigate and screenshot for visual debugging
132
+ - **Type-Safe** - Full type hints with Pydantic validation
133
+ - **Production-Ready** - Built-in retries, automatic cleanup, comprehensive error handling
134
+
135
+ ---
136
+
137
+ ## Common Use Cases
138
+
139
+ ### Price Monitoring
140
+
141
+ Monitor product prices and availability across retailers.
142
+
143
+ ```python
144
+ with client.session("agi-0") as session:
145
+ result = session.run_task(
146
+ "Go to amazon.com and search for 'Sony WH-1000XM5'. "
147
+ "Get the current price, check if it's in stock, and return the product rating. "
148
+ "Return as JSON with fields: price, in_stock, rating, url."
149
+ )
150
+ ```
151
+
152
+ ### Lead Generation
153
+
154
+ Extract structured data from public sources.
155
+
156
+ ```python
157
+ with client.session("agi-0") as session:
158
+ result = session.run_task(
159
+ "Go to ycombinator.com/companies, find companies in the 'AI' category "
160
+ "from the latest batch. For the first 10 companies, get their name, "
161
+ "description, and website. Return as a JSON array."
162
+ )
163
+ ```
164
+
165
+ ### Flight Booking Research
166
+
167
+ ```python
168
+ with client.session("agi-0") as session:
169
+ result = session.run_task(
170
+ "Find three nonstop SFO→JFK flights next month under $450. "
171
+ "Compare prices on Google Flights, Kayak, and Expedia. "
172
+ "Return flight details and booking links."
173
+ )
174
+ ```
175
+
176
+ <details>
177
+ <summary><b>Browser Control</b> – Navigate and take screenshots for visual debugging</summary>
178
+
179
+ <br />
180
+
181
+ ```python
182
+ with client.session("agi-0") as session:
183
+ # Navigate to specific URL
184
+ session.navigate("https://amazon.com")
185
+
186
+ # Get screenshot for debugging
187
+ screenshot = session.screenshot()
188
+ print(screenshot.url) # Current page URL
189
+ print(screenshot.title) # Page title
190
+ # screenshot.screenshot contains base64 JPEG data
191
+ ```
192
+
193
+ </details>
194
+
195
+ <details>
196
+ <summary><b>Session Snapshots</b> – Preserve authentication and browser state</summary>
197
+
198
+ <br />
199
+
200
+ ```python
201
+ # Create session and save environment
202
+ session1 = client.sessions.create(agent_name="agi-0")
203
+ # ... do some work ...
204
+ client.sessions.delete(session1.session_id, save_snapshot_mode="filesystem")
205
+
206
+ # Later, restore from saved environment
207
+ session2 = client.sessions.create(
208
+ agent_name="agi-0",
209
+ restore_from_environment_id=session1.environment_id
210
+ )
211
+ # Authentication state and cookies preserved!
212
+ ```
213
+
214
+ </details>
215
+
216
+ <details>
217
+ <summary><b>Advanced Session Management</b> – Full control over session lifecycle</summary>
218
+
219
+ <br />
220
+
221
+ ```python
222
+ # Create session manually
223
+ session = client.sessions.create(
224
+ agent_name="agi-0-fast",
225
+ webhook_url="https://yourapp.com/webhook",
226
+ max_steps=200
227
+ )
228
+
229
+ # Send message
230
+ client.sessions.send_message(
231
+ session.session_id,
232
+ "Find flights from SFO to JFK under $450"
233
+ )
234
+
235
+ # Check status
236
+ status = client.sessions.get_status(session.session_id)
237
+ print(status.status) # "running", "finished", etc.
238
+
239
+ # List all sessions
240
+ sessions = client.sessions.list()
241
+
242
+ # Delete when done
243
+ client.sessions.delete(session.session_id)
244
+ ```
245
+
246
+ </details>
247
+
248
+ <details>
249
+ <summary><b>Webhooks</b> – Get notified when tasks complete</summary>
250
+
251
+ <br />
252
+
253
+ ```python
254
+ session = client.sessions.create(
255
+ agent_name="agi-0",
256
+ webhook_url="https://yourapp.com/webhook"
257
+ )
258
+
259
+ # Your webhook will receive events:
260
+ # POST https://yourapp.com/webhook
261
+ # {
262
+ # "event": "done",
263
+ # "session_id": "sess_...",
264
+ # "data": {...}
265
+ # }
266
+ ```
267
+
268
+ </details>
269
+
270
+ ---
271
+
272
+ ## Error Handling
273
+
274
+ <details>
275
+ <summary><b>Robust error handling with detailed debugging</b></summary>
276
+
277
+ <br />
278
+
279
+ ```python
280
+ from agi import (
281
+ AGIClient,
282
+ AuthenticationError,
283
+ NotFoundError,
284
+ RateLimitError,
285
+ AgentExecutionError
286
+ )
287
+
288
+ client = AGIClient()
289
+
290
+ try:
291
+ with client.session("agi-0") as session:
292
+ result = session.run_task("Find flights...")
293
+ except AuthenticationError:
294
+ print("Invalid API key")
295
+ except NotFoundError:
296
+ print("Session not found")
297
+ except RateLimitError:
298
+ print("Rate limit exceeded - please retry")
299
+ except AgentExecutionError as e:
300
+ print(f"Task failed: {e}")
301
+ # Debug at VNC URL if available
302
+ except AGIError as e:
303
+ print(f"API error: {e}")
304
+ ```
305
+
306
+ </details>
307
+
308
+ ---
309
+
310
+ ## Documentation & Resources
311
+
312
+ **Learn More**
313
+ - [API Reference](https://docs.agi.tech) – Complete API documentation
314
+ - [Code Examples](./examples) – Working examples for common tasks
315
+ - [GitHub Issues](https://github.com/agi-inc/agi-python/issues) – Report bugs or request features
316
+
317
+ **Get Help**
318
+ - [Platform](https://platform.agi.tech) – Manage API keys and monitor usage
319
+ - [Documentation](https://docs.agi.tech) – Guides and tutorials
320
+
321
+ ---
322
+
323
+ ## License
324
+
325
+ MIT License - see [LICENSE](LICENSE) for details.