Getting Started
How to use Quench.AI API
Welcome to the Quench.AI API! This guide provides instructions on how to authenticate and interact with key endpoints.
Base URLCopied!
All API requests should be made to the base URL:
https://api.quench.ai
Authentication and TokensCopied!
API KeysCopied!
Quench.AI uses two types of API keys for authentication:
-
Admin Token Key
Use this to generate admin JWT tokens for managing assets. -
Feature Token Key
Use this to generate feature JWT tokens for user operations like search, chat, and roleplay.
Generating TokensCopied!
To generate tokens, include the appropriate API key in the request body when accessing the /v1/auth/admin
or /v1/auth/user
endpoints.
Generate Admin Token
Request an admin JWT using the Admin API Key. This API Key must be kept in a secure fashion since it can be used destructively with your assets (e.g.: updating or deleting an asset).
Generate User Token
Request a user JWT using the User Token Key.
Using the APICopied!
Include the generated JWT token in the x-quench-token
header for all subsequent requests:
x-quench-token: your-jwt-token
Search over your contentCopied!
Initiate a search using /v1/search/
endpoint. Because this is an asynchronous request, you then need to take note of the returned uuid
to poll the Retrieve endpoint.
The answer to the query is finalized when the status
is Answered
.
Chat with your contentCopied!
Initiate a chat session using /v1/chat/
endpoint. With Chat, you can do follow up queries after getting the initial answer. Here’s a sequence of events:
-
Retrieve Answer (like with Search,
status
will beAnswered
) -
Continue chat with a new query, which will be interpreted in the context of the previous one(s)
-
Go to 2
With Chat, you can interact either with all your content, or with a specific Asset from your account. In order to interact with a specific Asset, you’ll need to pass the partner_asset_id
along with the message
when Initiating a Chat.
If the purpose is to interact with your whole content, then you can either omit partner_asset_id
, or pass it as null
.
The partner_asset_id
is the ID you specify when uploading your assets.
RoleplayCopied!
You can do Roleplay sessions against your assets. This is based on specifying what Goal you want to achieve when doing the Roleplay session. In order to facilitate this, we also offer an endpoint which provides you some example goals for the specified asset. Alternatively, you can also supply your own custom Goal.
Generating GoalsCopied!
Generate example goals via the Generate Goals endpoint. As with the other use cases, you can then retrieve them via the Retrieve Goals endpoint, waiting for the status
Answered
.
RoleplayCopied!
Initiate a roleplay session using the /v1/roleplay/
endpoint. Roleplay sessions are executed against an asset with a Goal in mind. On Initiation you need to supply both the partner_asset_id
- the ID of the asset you specified at the time of the upload - and the goal
in a textual description.
The flow is very similar to Chat:
-
Retrieve Roleplay (like with Chat,
status
will beAnswered
) -
Continue Roleplay with a new query
-
Go to 2
Best PracticesCopied!
-
Secure API Keys: Do not share your Admin API keys or tokens publicly.
-
Handle Errors Gracefully: Be prepared for responses like
401 Unauthorized
-
Monitor Token Expiry: Ensure you refresh tokens as needed.
For more details, refer to the full API documentation or contact support.