API Model for the Conversational AI Assistant Service
Explore how to model a conversational AI assistant API around conversation state and generation status. Learn to define endpoints for conversations, messages, responses, and cancellation. Understand streaming events, idempotency, pagination, partial responses, error handling, and recovery after interrupted connections.
This lesson models the assistant API using the decisions from the preceding lesson. We will define its base URL, operations, data entities, and the requests and responses used to create a conversation, generate an answer, retrieve history, and stop generation. The service stores conversation history, so a client sends the new user message rather than replaying every earlier response.
Base URL and API endpoints
The following host and version prefix are illustrative:
https://api.assistant.example/v1
The API groups operations around conversations and the turns generated within them.
Conversation IDs identify durable threads. Response IDs identify individual generation attempts and allow the client to inspect the result after a lost stream. Cancellation changes a response's state; it does not delete messages or the conversation. Clients can list conversations and update instructions with GET /v1/conversations and PATCH /v1/conversations/{conversationID}.