SDKs & Code Examples¶
Code examples for integrating AG2Trust into your applications.
Official SDKs¶
Coming soon - Official SDKs for Python, JavaScript, and Go.
For now, use the REST API directly with your preferred HTTP client.
Quick Examples¶
Send a Message¶
const response = await fetch(
'https://agents.ag2trust.com/api/v1/ask/support',
{
method: 'POST',
headers: {
'X-API-Key': 'cust_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({ content: 'Hello, I need help' })
}
);
const data = await response.json();
console.log(data.content);
Detailed Examples¶
-
Python
Complete Python examples with requests and httpx
-
JavaScript
Node.js and browser examples with fetch and axios
-
cURL
Command-line examples for testing and scripts
Common Patterns¶
Conversation Threading¶
# First message
response1 = send_message("What's the weather?")
thread_id = response1["thread_id"]
# Follow-up (maintains context)
response2 = send_message("How about tomorrow?", thread_id=thread_id)
Error Handling¶
try:
response = send_message("Hello")
except RateLimitError:
time.sleep(retry_after)
response = send_message("Hello")
except AgentUnavailableError:
notify_user("Please try again later")