Skip to main content
In this tutorial, we will teach you how to use the Together Python library to run a chat model. We will be querying the mistralai/Mixtral-8x7B-Instruct-v0.1 model to list out fun things to do in New York.

Pre-requisites

  • Ensure you have Python installed on your machine.
  • Create a free account to obtain a Together API Key, found in your account settings.
  • Install the Together library with pip install --upgrade together:

Querying a chat model

The model we are using for this guide is mistralai/Mixtral-8x7B-Instruct-v0.1. You can browse all available models in this list. Now that we’ve chosen our model, let’s query it using the Together Python SDK.

Output

Streaming tokens from a chat model

If you want to stream the response back, simply specify stream=True.

Async support

If you want to run several calls in parallel, use our async method.

Querying a completion model

Completions are for code and language models shown here.

Querying an image model

To query an image model, use the .images method and specify the image model you want to use.
For your reference, here is a link to the Python Library.