Reference this guide to learn how to run inference using REST API.

This tutorial covers how to use the Together Embedding endpoint to get embeddings.

For the full API reference go to API Reference.


  • Ensure you have curl installed in your machine.
  • Get your Together API key by signing up at

Define the Endpoint URL and API Key

Launch your terminal. Define the endpoint URL and the API key for authentication.


Find your API token in your account settings.

Choose your embedding model and text

The input to the API is a JSON-formatted object with the following request parameters:

  • The model field specifies an embedding model that you’d like to use. In this example, we'll specify togethercomputer/m2-bert-80M-8k-retrieval. You can find a full list of models here.
  • The input field is a text or a list of texts that you want to embed. You may want to chunk this text into smaller pieces not to exceed the model specific context length if it's a large body of text. You can find the max context length of a model in the model table.

Create the curl Request

To retrieve the embeddings for your input, issue the following curl command as seen below.

     -H "Authorization: Bearer $TOGETHER_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
         "input": "Our solar system orbits the Milky Way galaxy at about 515,000 mph.",
         "model": "togethercomputer/m2-bert-80M-8k-retrieval"


Your output should be a JSON array that contains the embeddings. The dimension of the embedding vector should match the model embedding dimension.

  "object": "list",
  "data": [
      "object": "embedding",
      "embedding": [
      "index": 0
  "model": "togethercomputer/m2-bert-80M-8k-retrieval",
  "request_id": "840fc1b5bb2830cb-SEA"

The response’s data[0].embedding key contains the embeddings for your input. For the full API reference, go to API Reference.