Skip to main content
You can point DSPy through Butter using its LM class, which accepts the necessary base URL and headers. See it in the example below.
DSPy offers some light caching of its own. This may prevent certain queries from reaching Butter.
import os
import dspy

lm = dspy.LM(
    api_base="https://proxy.butter.dev/v1",
    headers={"Butter-Auth": f"Bearer {os.getenv('BUTTER_API_KEY')}"},
    api_key=os.getenv("OPENAI_API_KEY"),
    model="openai/gpt-4"
)

dspy.configure(lm=lm)

response = lm(messages=[{"role": "user", "content": "What is the English word for mantequilla?"}])

print(response)