Skip to main content

Step 1: Get an API Key

Sign into the Butter dashboard. This will create a fresh, empty cache, as well as an API key you’ll use to authenticate requests. To view your active API keys, visit the Keys page. Make sure to save your Butter and other relevant API keys accordingly.
export BUTTER_API_KEY=your-butter-api-key
export OPENAI_API_KEY=your-openai-api-key

Step 2: Configure your Client

Modify your LLM client to point to Butter’s base URL.
export BASE_URL=https://proxy.butter.dev

Step 3: Make your First Request

Submit your first request through Butter.
curl -X POST $BASE_URL/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Butter-Auth: Bearer $BUTTER_API_KEY" \
-d '{"messages":[{"role":"user", "content":"What is the English word for mantequilla?"}],"model":"gpt-4o"}'
First Response: Cache Miss
{
  "id": "chatcmpl-XYZ...",
  # ...
  "choices":[
    {
      # ...
      "message":{
        "content":"The English word for \"mantequilla\" is \"butter\".",
        "role":"assistant"
      }
    }
  ],
}

Step 4: Make your Second Request

Send the previous request once more. You should see a cache hit.
Second Response: Cache Hit
{
  "id":"cached",
  # ...
  "choices":[
    {
      # ...
      "message":{
        "content":"The English word for \"mantequilla\" is \"butter\".",
        "role":"assistant"
      }
    }
  ],
}
Any response served from cache will return with an id field set to "cached".

Step 5: View your Cache

Visit the Requests feed to view your requests and their cache status. The cache is a tree of all message sequences that have been seen. You can view a message’s respective node in the tree by clicking on it from the Request view.

Next Steps

Now that you’ve run your first requests, continue onward to template-aware caching, or learn more about the cache structure.