In 30 seconds
Matthew Berman walks through adapting Together AI’s Mixture of Agents repository to Groq’s API in a sponsored July 2024 tutorial. He configures a Python environment, model choices, credentials and endpoints, then fixes a None-value error encountered in streaming output. The examples produce a joke and sentences with a specified ending. They demonstrate the workflow but do not establish general superiority to GPT-4o or quantify speed and cost against a baseline.
- 1A layered ensembleThe diagram feeds intermediate responses through three layers before a final aggregator produces an answer.
- 2Credentials and setupThe presenter uses an environment file and Groq key; the description clarifies that a valid OpenAI API key is unnecessary.
- 3Changing model defaultsThe tutorial chooses Groq-supported reference models and a Llama 3 70B aggregator available in 2024.
- 4API adaptationTogether API references are replaced with Groq’s OpenAI-compatible endpoint and key references.
- 5Fix and retestA guard skips None streaming values before concatenation. The presenter then tests a joke and a sentence-ending prompt.
Takeaways
- Mixture of Agents passes outputs from multiple model calls through layers to an aggregator.
- Multiple calls can increase latency; the tutorial uses Groq inference to address that concern.
- The 2024 adaptation changes models, API endpoints, credentials and environment loading.
- A valid OpenAI API key is not required for this tutorial, according to the video description’s update.
- The first test exposes a None-value concatenation error; the presenter adds a guard and retries.
- Two illustrative prompts are not a controlled benchmark of quality, latency or cost.
Read the edited text by chapter
Mixture of Agents and latency
Berman explains the layered ensemble and the latency cost of multiple calls. He proposes using Groq inference in a sponsored 2024 tutorial.
Mixture of Agents combines responses from several language models to produce an answer. I am excited by reported results in which an ensemble of open models outperformed GPT-4o on a particular evaluation, but repeated model calls can make the approach slow. In this July 2024 tutorial I adapt the original code to use Groq’s fast inference service; Groq partnered on the video.
The illustrated architecture passes the prompt through several layers of models, feeding intermediate responses forward before an aggregator produces the final answer. The diagram shows three agents in each of three intermediate layers and a final aggregator. Results depend on the models, prompts and evaluation; the demonstration does not establish superiority to GPT-4o on every task.

I start with Together AI’s open-source MoA repository and make changes to use Groq. This is a pragmatic adaptation rather than a full redesign, and I expect that model choices and provider support will evolve. The code, model identifiers and service interfaces shown reflect the 2024 tutorial.
Clone the repository and configure credentials
He sets up a Python environment and explains the API keys. The video description clarifies that a valid OpenAI key is unnecessary for this tutorial.
In VS Code, open a terminal and clone the repository. I create a separate conda environment with Python 3.11, activate it, enter the MoA directory and install the repository requirements with pip. Then I open the project folder and verify the environment is active.

I create a .env file for credentials. The original tutorial discusses an OpenAI key because the repository also has OpenAI benchmark scripts and uses the OpenAI Python library for compatible API calls. The video description later clarifies that a valid OpenAI API key is not required for this tutorial; the library and an actual OpenAI credential are separate things.
I obtain a Groq API key from its console and put it in the environment file. I say the keys shown in my recording will be revoked before publication. The two files containing the main changes are bot.py and utils.py; my modifications are somewhat hacky but sufficient for the demonstration.
Change models and API calls
He updates reference and aggregator models, token defaults, environment loading and endpoints. The specific model names and service interface reflect the tutorial date.
In bot.py I replace the default reference models with Groq-supported options available at the time: Llama 3 8B, Llama 3 70B, Mixtral 8x7B and Gemma 7B. I choose Llama 3 70B as the default aggregator and update the corresponding model references. Other combinations can be tested as service support changes.

I also change the maximum token defaults to 2,048 while retaining the existing temperature setting. In utils.py, I load the .env file with python-dotenv and install that dependency. This lets the script read the configured environment variables rather than requiring them to be exported manually.

Next I replace Together’s API endpoint and key references with Groq’s OpenAI-compatible endpoint and Groq API key. The endpoint path includes /openai/v1. I make the changes in both the ordinary and streaming calls, then save the files and test the interactive bot.
Test and fix streaming output
The first test exposes a None concatenation error and an outdated prompt label. After fixing them, he tests a joke and a constrained sentence prompt.
Running python bot.py prompts for an aggregator model, temperature and maximum tokens. The displayed prompt still says 512 even though the actual default is 2,048; I later correct that label. My first joke request reaches the models but encounters an error when a streaming output is None and is concatenated to a string.

In bot.py I add a check that skips a None value before concatenation, and update the outdated maximum-token prompt. After restarting the program and accepting the defaults, I ask for a joke and receive the familiar bicycle punchline. This confirms that the demonstrated request completes after the fix, not that all failure modes are handled.

I next ask for ten sentences ending in the word “Apple.” The program queries the reference models and aggregates their responses; I report that the sentences satisfy the constraint. The two examples show a working interactive workflow, but they are not a controlled comparison of latency, cost or answer quality against GPT-4o.
More from this channel
34:21EN
25:50EN
32:20EN
1:03:37EN
0:53EN
0:22EN