Skip to content

Chat

POST
/v1/chat/completions
curl --request POST \
--url http://localhost:8000/v1/chat/completions \
--header 'Content-Type: application/json' \
--data '{}'

Checks run in this order: a declared body size (413, BodyLimitMiddleware), API key (401), the key’s or the client IP’s requests a minute (_rate: 429), the body read and counted (413 for a chunked body over the limit), the in-flight caps (_hold: 503 at the gateway’s, 429 at the key’s), the Idempotency-Key and JSON (400), a stored answer for that key (sent again at once, ADR 0071), request validation (400, including X-Ratchet-Store), the task (400 unknown, 403 not allowed for the key), the daily request quota (429), the US dollar budgets (429), then the cascade. A refused request writes no ledger row and uses no quota or budget, and neither does a replay; past the rate it has taken its key’s (or IP’s) token. The in-flight slots are taken only once the body is in, so a client that trickles its body holds none. Everything after reading the body runs in a worker thread (the default pool, as for sync routes), so neither a large body nor the ledger lock blocks the event loop.

x-ratchet-task
Any of:
string
x-ratchet-store
Any of:
string
x-api-key
Any of:
string
idempotency-key
Any of:
string
x-stainless-retry-count
Any of:
string
Media typeapplication/json
object

Example generated

{}

Successful Response

Media typeapplication/json

Example generated

example

Validation Error

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string

Example generated

{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example"
}
]
}