• Husein

    Administrator
    March 20, 2025 at 9:38 am

    Oh okay, i get it now, but what is the error you’re getting. Anyways, here is my code if you want to try it directly:

    from os import getenv

    from phi.agent import Agent

    from phi.model.openai.like import OpenAILike

    # Ensure the Together API key is set as an environment variable

    api_key = getenv(“TOGETHER_API_KEY”)

    if not api_key:

    raise ValueError(“TOGETHER_API_KEY environment variable is not set.”)

    # Initialize the agent with the Together AI model

    agent = Agent(

    model=OpenAILike(

    id=”mistralai/Mixtral-8x7B-Instruct-v0.1″,

    api_key=api_key,

    base_url=”https://api.together.xyz/v1″,

    )

    )

    # Define the prompt

    prompt = “Share a 2-sentence horror story.”

    # Get the response from the agent

    response = agent.run(prompt)

    # Print the response content

    print(response.content)

    • This reply was modified 1 month ago by  Husein.
    • This reply was modified 1 month ago by  Husein.