B2BB2B LLM

Anthropic message endpoint

Send native system, conversation and content blocks.

No current prepared translation is available. The English source is shown without machine translation.

POST /v1/messages uses the Anthropic conversation structure. system is top-level and max_tokens sets the requested output ceiling. A tool-capable or vision-capable model is still required for those content types.

Request

curl https://api.b2b-llm.com/v1/messages \
  -H "x-api-key: $B2B_API_KEY" -H 'anthropic-version: 2023-06-01' \
  -H 'Content-Type: application/json' \
  -d '{"model":"claude-sonnet-4.6","max_tokens":256,"system":"Use professional language.","messages":[{"role":"user","content":"Confirm the planned maintenance in one sentence."}]}'

Response

{"id":"msg_example","type":"message","role":"assistant","content":[{"type":"text","text":"The maintenance window is confirmed."}],"stop_reason":"end_turn","usage":{"input_tokens":20,"output_tokens":9}}

Content is a list of blocks rather than one text property. Preserve supported tool-use/tool-result turns when continuing a conversation. Count input separately with token estimation.

For a PDF-capable model, a document block uses source.type=base64, source.media_type=application/pdf and bare base64 in source.data. Do not copy the Responses file_data property into this protocol. Hosted search on the supported Responses interface is described in the search guide.

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.