Skip to main content

1. Request a quote

Send the same body you intend to use for chat to POST /v1/quotes. The Gateway:
  1. Resolves the canonical model.
  2. Filters active offers and any explicit offer selection.
  3. Refreshes stale provider verification.
  4. Checks endpoint state and tokenizes the request.
  5. Rejects offers that cannot fit the context.
  6. Reads each offer’s current on-chain tariff.
  7. Selects the lowest maximum credit charge.
The result includes the quote, model, offer, tariff version, estimated input tokens, maximum output tokens, wake state, maximum credits, and expiry.

2. Send the chat request

Submit POST /v1/chat/completions with the API key and permit ID. Include the quote ID if you need the request to use that exact offer and maximum. The Gateway verifies the permit and reserves the maximum charge before contacting the endpoint.

3. Route and fail over

The Gateway forwards the request to the selected endpoint. If automatic selection was used and the endpoint fails before output, Tulip may release the first reservation and try one different eligible offer. Failover is disabled when:
  • The request explicitly names an offer.
  • The permit pins an offer.
  • The client supplies an existing quote.

4. Meter usage

For a non-streaming response, the Gateway reads usage from the returned JSON. For a stream, it reads terminal usage from the SSE events. Missing or invalid usage fails the request. Tulip does not estimate a bill.

5. Sign and settle

The Gateway recomputes the actual charge from the same on-chain tariff version, releases any unused reservation, and signs the usage receipt. A settlement worker submits completed receipts to settleBatch. The escrow verifies the signature, timing, permit, model, offer, tariff effectiveness, replay protection, and charge before transferring credits.

Response headers

HeaderMeaning
X-Tulip-Request-IdUnique request ID used in the settlement receipt.
X-Tulip-Quote-IdQuote used for the request.
X-Tulip-Offer-IdProvider offer that served the request.
X-Tulip-Tariff-VersionOn-chain tariff version used for billing.
X-Tulip-Credits-ChargedActual charge for a completed non-streaming response.