v1.0.0

Toffee API Reference

Integrate Toffee's semantic compression engine directly into your own applications. The API allows you to programmatically compress AI conversations, manage context bundles, and synchronize state across devices.

Quick Start

The Toffee API is organized around REST. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes.

Base URL

https://api.toffee.ai/v1

Authentication

The Toffee API uses Firebase Auth ID tokens to authenticate requests. You can view and manage your API keys in the Toffee Dashboard.

Keep your tokens secureDo not share your ID tokens in publicly accessible areas such as GitHub, client-side code, and so forth.

All API requests must include your token in an Authorization HTTP header:

Authorization:Bearer <YOUR_FIREBASE_ID_TOKEN>

Compress Context

POST/v1/compress

Compresses a raw conversation array into an optimized .toffee bundle. This endpoint runs the full 8-stage semantic compression pipeline.

Request Body

conversationobject (required)

The raw conversation payload extracted from the AI platform.

profileenum (optional)

Compression aggressiveness. Defaults to standard. Allowed values: minimal, standard, aggressive.

Example Request

curl -X POST https://api.toffee.ai/v1/compress \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{
  "profile": "standard",
  "conversation": {
    "platform": "chatgpt",
    "model": "gpt-4o",
    "turns": [
      {
        "role": "user",
        "content": "Let's build a Next.js app."
      }
    ]
  }
}'

Rate Limits

The Toffee API implements rate limiting to ensure stability. Limits are applied per authenticated user account.

EndpointRate LimitWindow
POST /compress60 requestsPer minute
GET /bundles300 requestsPer minute

Error Codes

Toffee uses conventional HTTP response codes to indicate the success or failure of an API request.

200OK

Everything worked as expected.

400Bad Request

The request was unacceptable, often due to missing a required parameter.

401Unauthorized

No valid API key or Firebase token provided.

429Too Many Requests

Too many requests hit the API too quickly. We recommend an exponential backoff.

500Server Error

Something went wrong on Toffee's end.