Welcome to the WebSim AI Chat Assistant API documentation. This API allows you to interact with our advanced AI assistant to enhance your web simulation experiences.
All API requests require authentication using a bearer token. Include the following header in your requests:
Authorization: Bearer YOUR_API_TOKEN
Start a new chat session or continue an existing one with the AI assistant.
{
"message": "Your message here",
"session_id": "optional_session_id",
"context": {
"current_url": "https://example.com",
"user_role": "developer"
}
}
{
"response": "AI assistant's response",
"session_id": "generated_or_provided_session_id",
"suggested_actions": [
{
"type": "navigate",
"url": "https://example.com/suggested-page"
},
{
"type": "modify_dom",
"selector": "#main-content",
"action": "append",
"content": "Suggested content
"
}
]
}
Retrieve the chat history for a specific session.
{
"session_id": "requested_session_id",
"messages": [
{
"role": "user",
"content": "User message"
},
{
"role": "assistant",
"content": "AI response"
}
]
}
End a chat session and delete its history.
{
"status": "success",
"message": "Session deleted successfully"
}
The WebSim AI Chat Assistant is designed to enhance your web simulation experiences. It can provide contextual assistance, suggest modifications to the simulated web environment, and even generate new content on the fly.
Here's an example of how you might use the Chat Assistant API in a WebSim scenario:
// Request
POST /chat
{
"message": "Can you help me add a navigation menu to this page?",
"context": {
"current_url": "https://websim.ai/c/example-site",
"user_role": "designer"
}
}
// Response
{
"response": "Certainly! I'd be happy to help you add a navigation menu to your page. Here's a suggestion for a simple navigation menu structure:",
"session_id": "abc123",
"suggested_actions": [
{
"type": "modify_dom",
"selector": "body",
"action": "prepend",
"content": ""
},
{
"type": "add_css",
"content": "nav { background-color: #333; } nav ul { list-style-type: none; padding: 0; } nav ul li { display: inline; margin-right: 10px; } nav ul li a { color: white; text-decoration: none; }"
}
]
}
In this example, the AI assistant not only provides a textual response but also suggests specific actions to modify the DOM and add CSS, directly enhancing the simulated web page.
To ensure fair usage, API calls are rate-limited to 60 requests per minute per API token. If you exceed this limit, you'll receive a 429 Too Many Requests response.
The API uses standard HTTP response codes. In case of an error, you'll receive a JSON response with an "error" key explaining the issue.