1. Request a quote
Send the same body you intend to use for chat toPOST /v1/quotes. The Gateway:
- Resolves the canonical model.
- Filters active offers and any explicit
offerselection. - Refreshes stale provider verification.
- Checks endpoint state and tokenizes the request.
- Rejects offers that cannot fit the context.
- Reads each offer’s current on-chain tariff.
- Selects the lowest maximum credit charge.
2. Send the chat request
SubmitPOST /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 readsusage 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 tosettleBatch. The escrow verifies the signature, timing, permit, model, offer, tariff effectiveness, replay protection, and charge before transferring credits.
Response headers
| Header | Meaning |
|---|---|
X-Tulip-Request-Id | Unique request ID used in the settlement receipt. |
X-Tulip-Quote-Id | Quote used for the request. |
X-Tulip-Offer-Id | Provider offer that served the request. |
X-Tulip-Tariff-Version | On-chain tariff version used for billing. |
X-Tulip-Credits-Charged | Actual charge for a completed non-streaming response. |