Skip to main content
Togetherโ€™s API endpoints for chat, vision, images, embeddings, speech are fully compatible with OpenAIโ€™s API. If you have an application that uses one of OpenAIโ€™s client libraries, you can easily configure it to point to Togetherโ€™s API servers, and start running your existing applications using our open-source models.

Configuring OpenAI to use Togetherโ€™s API

To start using Together with OpenAIโ€™s client libraries, pass in your Together API key to the api_key option, and change the base_url to https://api.together.xyz/v1:
You can find your API key in your settings page. If you donโ€™t have an account, you can register for free.

Querying a language model

Now that your OpenAI client is configured to point to Together, you can start using one of our open-source models for your inference queries. For example, you can query one of our chat models, like Llama 3.1 8B:

Streaming a response

You can also use OpenAIโ€™s streaming capabilities to stream back your response:

Using Vision Models

Output:

Image Generation

Output:
Image Generation

Text-to-Speech

Output:

Generating vector embeddings

Use our embedding models to generate an embedding for some text input:
Output

Structured Outputs

Output:

Function Calling

Output:

Community libraries

The Together API is also supported by most OpenAI libraries built by the community. Feel free to reach out to support if you come across some unexpected behavior when using our API.