B2BB2B LLM

Chat message endpoint

Use message-list clients with the Chat Completions interface.

POST /v1/chat/completions accepts the OpenAI-compatible messages conversation shape. Use a model with the required text/tool/vision capabilities; the existence of this endpoint does not make every parameter valid for every model.

Request

curl https://api.b2b-llm.com/v1/chat/completions \
  -H "Authorization: Bearer $B2B_API_KEY" -H 'Content-Type: application/json' \
  -d '{"model":"gpt-5.4","messages":[{"role":"user","content":"Draft one sentence confirming receipt of a support request."}],"stream":false}'

Response

{"id":"chatcmpl_example","object":"chat.completion","choices":[{"index":0,"message":{"role":"assistant","content":"We received your request and will review it."},"finish_reason":"stop"}]}

Read assistant content and tool calls from the returned choices. Do not assume all responses are plain strings. For progressive output, enable streaming and use the stream reader appropriate to Chat Completions.

Native deferred execution adds async: true with streaming disabled. Temporary Playground sessions cannot submit that durable work; use an integration credential. The normal request path does not require a recent browser authenticator code.

Session ID

Use a stable JSON session_id or X-Session-ID header for every turn of this conversation. Priority is session_id → X-Session-ID → recognized session in metadata.user_id → prompt_cache_key → opening conversation content. The identity layer is independent of provider type. Keeping the same ID does not guarantee a cache hit or disable eligible failover. See conversation identity and sticky routing for automatic fallback, scope, limits and the difference from idempotency and stored context.

The same identity is retained for streaming and for asynchronous submission where this endpoint supports it. Do not send a new paid POST merely to test a session after a timeout; check the existing request first.

An existing recognized metadata session is used without a mismatch error; an ordinary metadata.user_id is preserved, not treated as a conversation. Higher-priority explicit fields win. See the linked identity reference for formats and upstream transport limits.

A recognized metadata session takes precedence over a cache hint. Automatic identity ignores known cache_control decorations and equivalent single-text wrappers without changing the model request. A separately configured, compatible upstream session-header transport does not occupy ordinary metadata.user_id; this capability is configured by the operator, not selected by the client.