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/uikit
component library.
Get an API key
- Log in to the Inkeep Dashboard
- Navigate to the Projects section and select your project
- Open the Integrations tab
- Click Create Integration and choose API from the options
- Enter a Name for your new API integration.
- Click on Create
- A generated API key will appear that you can use to authenticate API requests.
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:
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.