Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.together.ai/llms.txt

Use this file to discover all available pages before exploring further.

Using a coding agent? Install the together-embeddings skill to let your agent write correct embeddings code automatically. See agent skills for details.
The embeddings API turns an input string into a vector of numbers. You can compare two vectors to measure how closely related the source texts are. Common use cases include search, classification, recommendations, and retrieval-augmented generation (RAG). For long-term retrieval, store embeddings in a vector database and query by similarity. For the full parameter list, see the Create embedding reference. For available embedding models, see the serverless and dedicated endpoint model catalogs.

Generate an embedding

Call client.embeddings.create with a model and an input string.
from together import Together

client = Together()

response = client.embeddings.create(
    model="intfloat/multilingual-e5-large-instruct",
    input="Our solar system orbits the Milky Way galaxy at about 515,000 mph",
)
The response contains the embedding under data, along with metadata.
JSON
{
  "model": "intfloat/multilingual-e5-large-instruct",
  "object": "list",
  "data": [
    {
      "index": 0,
      "object": "embedding",
      "embedding": [0.2633975, 0.13856208, 0.04331574]
    }
  ]
}

Generate multiple embeddings

Pass an array of strings to input to embed several texts in one call.
from together import Together

client = Together()

response = client.embeddings.create(
    model="intfloat/multilingual-e5-large-instruct",
    input=[
        "Our solar system orbits the Milky Way galaxy at about 515,000 mph",
        "Jupiter's Great Red Spot is a storm that has been raging for at least 350 years.",
    ],
)
response.data contains one object per input, each with the matching index.
JSON
{
  "model": "intfloat/multilingual-e5-large-instruct",
  "object": "list",
  "data": [
    {
      "index": 0,
      "object": "embedding",
      "embedding": [0.2633975, 0.13856208, 0.04331574]
    },
    {
      "index": 1,
      "object": "embedding",
      "embedding": [-0.14496337, 0.21044481, -0.16187587]
    }
  ]
}

Next steps