---
title: "OpenAI-compatible metered chat completions"
method: POST
path: "/wrapped/credits/v1/chat/completions"
tags: ["Burn"]
---

# OpenAI-compatible metered chat completions

`POST /wrapped/credits/v1/chat/completions`

## Request

- Base URL: `https://api.paywithlocus.com/api`
- URL: `https://api.paywithlocus.com/api/wrapped/credits/v1/chat/completions`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer

Accepts the OpenAI Chat Completions request shape. With stream=true, returns provider-native SSE without full-response buffering. Locus captures the fixed authorized charge before delivering the first byte.

## Headers

- `X-Locus-Session-Id` string
- `Idempotency-Key` string, required
- `X-Locus-End-User` string: Case-sensitive immutable ID in the tenant namespace. Prefer an identity-provider subject, not an email address.
- `X-Locus-Agent-Loop-Id` string

## Request body

- OpenAIChatCompletionRequest
  - `model` string, required
  - `messages` object[], required
  - `stream` boolean
  - `stream_options` object
  - `max_tokens` integer
  - `max_completion_tokens` integer: For reviewed reasoning models, an explicit value must be at least that model's recommendedMinOutputTokens (currently 4000); smaller budgets are rejected before dispatch or billing because hidden reasoning can exhaust the budget before visible output.
  - `tools` object[]
  - `tool_choice` unknown

## Response `200`

OpenAI JSON response, or unbuffered OpenAI SSE when stream=true

- object

## Other responses

- `400`: Local request validation or provider validation error before stream delivery
- `402`: Insufficient credits; no provider dispatch
- `403`: Endpoint or native end-user policy denied execution
- `409`: Idempotency conflict or stream_not_replayable status response
- `413`: Encoded JSON request exceeds the 4 MiB Locus Pro chat limit
- `429`: Tenant or provider rate limit before stream delivery
- `503`: Provider configuration or stream settlement pending, or a provider/transport failure or timeout before stream delivery with the reservation released. Locus sends gateway failures as 503 so the JSON body passes the edge; X-Locus-Origin-Status carries the original 502 or 504.

---

[API](https://skmtc.dev/paywithlocus/apis/locus-pro-api.md) - [All operations](https://skmtc.dev/paywithlocus/apis/locus-pro-api/llms.txt) - [OpenAPI document](https://skmtc.dev/paywithlocus/apis/locus-pro-api/revisions/aab8fa5d6cef?raw)
