Add analytics to any OpenAI compatible chat
With Inkeep's Analytics API, you can log your AI chat conversations to:
- Get Inkeep's analytics and reporting for the chats
- Provide and track "Thumbs up/down" feedback
- Power "Share" or "Saved Chats" experiences
The Inkeep Analytics API is designed to be flexible and can log any OpenAI-compatible conversation, including those with tool calls or custom functionality.
If you're using Inkeep's Chat API to create your own chat UX or custom copilot, you should use the Analytics API to enable the same reporting as provided by the @inkeep/cxkit-react
component library.
Authentication
All Analytics API endpoints require authentication using an API key in the request headers. See our Authentication Page for details.
Log a conversation
Initial message
To log a new conversation, make a POST request to the /conversations
endpoint.
Follow-up messages
To log additional messages in an existing conversation, include the id
returned from the initial submission:
You can provide your own IDs for conversations and messages, or Inkeep will
auto-generate them. For logging continuous exchanges in a conversation, make
sure to retain and use the same conversation ID and always include the entire
message history. POST /conversation
works like an upsert operation.
Submit feedback
Use the /feedback
endpoint to log 👍 / 👎 feedback from your UI.
Monitor
To view analytics for your logged conversations and feedback:
- Go to portal.inkeep.com
- Navigate to Projects and select the relevant one
- View the Chat Sessions, Insights, and Analytics tabs
Use for "Share" or "Saved Chats"
You can use the GET /conversations
endpoint to retrieve logged conversations and power "Share" or "Saved Chats" features.
Here's an example of how to fetch a specific conversation:
The response will contain detailed information about the conversation:
This response includes all extended details about the conversation and its messages, including any properties you associated with it.
The messagesOpenAIFormat
property provides the messages of the conversation in a format compatible with OpenAI's chat completions API. You can use this to implement Share a chat, Saved Chats, or any other functionality that requires retrieving an existing chat.
Here's how:
- Share a chat - Create an entry point in your application or UI that parses a query parameter, e.g.
?chatId=<id>
. Then, use theGET /conversations/{id}
endpoint to get the last state of a conversation and hydrate the chat UI in your own application. If you want to be able to "fork" shared chats, then simply use a differentid
when logging the continuation of a shared conversation toPOST /conversations
. This will log it as a separate conversation from the original. - Saved Chats - Whenever a user creates a new conversation, associate that
id
with the user in your database or application. This way, you have a relationship ofchats<>user
and can display a user's history in your UI. You can also store that relationship in a user's browser session for unauthenticated contexts.
Log usage events
In addition to logging conversations and feedback, you can also track specific usage events related to conversations or messages using the /events
endpoint.
For example, you may want to track events like:
message:copied
: When a user copies a messagemessage:code_snippet:copied
: When a user runs a code snippet from a messageconversation:shared
: When a user shares a conversation
When logged, they will be incorporated in the Inkeep Analytics reporting.
The below shows an example of how to log these events.
Concepts
This glossary defines the key objects and concepts used throughout the Inkeep Analytics API and explains how they relate to each other.
Conversation
A conversation represents a series of messages between a user and an AI assistant. Conversations are the primary unit for tracking chat interactions in the Analytics API. Each conversation contains multiple messages and can receive feedback from users. Conversations can be grouped into semantic threads based on their topical similarity.
Message
A message represents a single interaction within a conversation, either from a user or the assistant. Messages are contained within conversations and can individually receive feedback. Users can perform various actions on messages (like copying), which are tracked as events.
Feedback
Feedback captures user reactions to assistant messages, typically in the form of thumbs up/down reactions with optional explanations. Feedback is associated with specific messages and helps improve the quality of responses over time.
Event
Events track specific user interactions with the Analytics API, such as copying a message, sharing a conversation, or clicking on a source. Events are always associated with either a message or a conversation entity and help analyze user engagement patterns.
Query
Queries allow for retrieving and analyzing analytics data stored in the system. There are several types of queries:
- Conversation queries: Retrieve conversation data
- Event queries: Access logged events
- Semantic thread queries: Retrieve semantically linked conversation threads
Properties / User Properties
Custom properties can be attached to Analytics API objects for filtering and segmentation. These properties allow for flexible data organization and analysis across conversations, messages, and other entities.
SemanticThread
A semantic thread is a set of one or more related conversations grouped by semantic meaning rather than by converstion ID or timestamp. Threads connect conversations that discuss similar topics, allowing for analysis of user interests and common questions across multiple interactions.
Project
The organizational unit that groups analytics data in the Inkeep system. Projects contain conversations, messages, and all related analytics data, typically corresponding to a specific integration or implementation.