Introduction
In this cookbook, we’ll build a simple chat with a model deployed on orq.ai using Deployment. We’ll explore how to maintain a chat history and context for the conversation.Prerequisite
To get started make sure your orq.ai account is setup and that you have access to a Workspace. We’ll also need an API Key ready, to see how to generate an API key, see Authentication.Preparing a Deployment
The first step is to prepare a Deployment. We’ll first head to the orq.ai Studio and choose a Projects where to create our Deployment.
Prepare a Deployment using any chat model, here we’re using claude sonnet 4, the default configuration is sufficient for this cookbook.

To learn more about the creation of a Deployment, see Creating a Deployment.
SDK code
In this part we’ll setup the SDK code to call the Deployment we just created.Get the environment ready
Install the orq.ai SDK using the following command:Building a Chat Loop
Here are the main features of what we’re building:- We’re building a small CLI to interact with a deployment in the terminal
- We’re using a local variable conv_memoryas a way to store history of messages the user sends to the model. Every succeeding messages will hold context for the past conversation, making the model generation stateful during the session.
- The conv_memoryis sent to the model generation within themessagesfield, this is where context is sent to the model.
Contact Tracking (Optional)
Contacts in Orq.ai help track user interactions and API usage across your application. They can represent users, teams, or projects and enable better analytics and budget management. Create a contact through the Orq.ai Studio:- Go to Contact Analytics in your workspace
- Click Create a Contact
- Add the user details (name, email, external ID)
- Set optional metadata and budget limits
Learn more about creating contacts, see Creating a Contact.
Testing
Here’s an example discussion, note that the second question asked directly references the first one, the model is aware of the previous par of the conversation and can therefore reply with context.Feedback Collection (Optional)
Feedback in Orq.ai helps track response quality and identify areas for improvement. You can collect user ratings, defect classifications, and corrections to continuously enhance your application. Provide feedback through the Orq.ai Studio:- Go to Logs in your workspace
- Find the specific deployment invocation
- Use the feedback interface to rate responses
- Add defect classifications or corrections as needed
You’ve successfully interacted with a Deployment through our SDK, integrating the