Skip to main content
You can repoint CrewAI through Butter using its Agent class, which accepts a custom LLM client with the necessary base URL and headers. See it in the example below.
import os
from crewai import Agent, Task, Crew, LLM

# Initialize custom LLM pointing to Butter proxy
custom_llm = LLM(
    base_url="https://proxy.butter.dev/v1",
    extra_headers={"Butter-Auth": f"Bearer {os.getenv('BUTTER_API_KEY')}"},
    api_key=os.getenv("OPENAI_API_KEY"),
    model="openai/gpt-4"
)

# Create a simple agent
chat_agent = Agent(
    role="Helpful Assistant",
    goal="Provide clear and accurate responses to user questions",
    backstory="You are a knowledgeable assistant who helps users with their questions.",
    llm=custom_llm,
    verbose=True
)

# Create a task for the agent
chat_task = Task(
    description="Answer the following question: What is the English word for mantequilla?",
    expected_output="A clear answer to the question",
    agent=chat_agent
)

# Create and run the crew
crew = Crew(
    agents=[chat_agent],
    tasks=[chat_task],
    verbose=True
)

if __name__ == "__main__":
    result = crew.kickoff()
    print(result)