Tmpt.me offers a REST API to allow Experts to provide access to their Knowledge Agent via 3rd party applications.
Now any developer can interact with an Expert's Knowledge Assistant via a simple REST API, using a secret key tied to the Expert's Knowledge Hub.
As the Expert adds content, curates answers, makes changes to their Agent, and so on, those changes will be reflected in the API responses.
Creating an API Key
To create an API Key, sign in to Tmpt.me, select Hub from the left navigation, and then click the API Keys tab. Select the Create new secret key button. The secret key will only be presented once, so make sure to copy it and put it in a safe place. You can create as many keys as you want for different applications, and delete a key if it is no longer used.
Using the API Key
The API is intended to be as easy to use as other LLM APIs, but is a bit different because it allows you as the developer to create multiple stateful conversations on behalf of your end users, and interact with the Expert's Agent in those conversations.
Please note that this API is in beta and may change as we receive user feedback.
Authentication
Authentication requires an API Key, which Experts can create in the Tmpt.me application. Once you have an Expert's API key, you can create a client token and start a conversation with the Expert's Agent. The API key must be passed as a Bearer token in the Authorization header. Specifically, the header should be:
Authorization: Bearer (your secret key)
Using the API
Please see the full API specification at: https://dev.tmpt.app/api.yaml
(The Website https://editor-next.swagger.
The basic actions are as follows:
- Create a client token using the /client_token endpoint. Pass in any string for external_user_id that you want to use to identify the client. The client token is used to distinguish conversations that may be started by different users on your app.
- Use the client token to create a new thread by POSTing the /threads endpoint. The thread is the conversation with the Expert's Agent.
- Use the thread ID to POST messages to the Expert's Agent using the /threads/{threadId}/messages endpoint.
- Use the thread ID to GET messages from the Expert's Agent using the /threads/{threadId}/messages endpoint. The returned messages array will include the full ordered conversation Agent's greeting, your inputs, and the Agent's responses.
You can call GET on the /threads endpoint to see all conversations associated with a client token.
Waiting on the Agent reply
For better client interactivity, once you POST a new message and receive back a message with an ID, you can immediately call GET /threads/{threadId}/reply/{messageId} with an optional timeout to wait for a response. This is useful for waiting for the Expert's Agent to respond to a question. Responses generally take from 5 to 15 seconds, but can take longer if the Expert's Agent is complex. Omitting the timeout or calling with a timeout of 0 will return immediately.
Python Example
To help get you started, we created a Python script that asks a question and then waits for a response: https://dev.tmpt.app/
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article