This guide will help you make your first API call to Nexus in just 5 minutes. By the end, you’ll have created a chat session and sent your first message.
Let’s create your first chat session. This establishes a conversation thread with your AI agent.
Copy
curl -X POST https://api.nexusgpt.io/api/public/thread \ -H "Content-Type: application/json" \ -H "api-key: $NEXUS_API_KEY" \ -d '{"message": "Hello! I need help with my order."}'
Now let’s send a follow-up message to the session we just created:
Copy
# Replace SESSION_ID with the id from Step 2curl -X POST https://api.nexusgpt.io/api/public/thread/SESSION_ID/messages \ -H "Content-Type: application/json" \ -H "api-key: $NEXUS_API_KEY" \ -d '{"message": "My order number is #12345"}'
To see the conversation history, including the AI’s responses:
Copy
curl -X GET "https://api.nexusgpt.io/api/public/thread/SESSION_ID/messages?limit=10" \ -H "api-key: $NEXUS_API_KEY"
Expected Response:
Copy
[ { "id": "msg_001", "type": "user", "content": "Hello! I need help with my order.", "createdAt": "2024-01-20T10:30:00Z" }, { "id": "msg_002", "type": "assistant", "content": "I'd be happy to help you with your order! Could you please provide your order number?", "createdAt": "2024-01-20T10:30:05Z" }, { "id": "msg_003", "type": "user", "content": "My order number is #12345", "createdAt": "2024-01-20T10:31:00Z" }, { "id": "msg_004", "type": "assistant", "content": "Thank you! I'm looking up order #12345 for you now...", "createdAt": "2024-01-20T10:31:05Z" }]