B2BB2B LLM

Conversation construction

Build the conversation in the selected protocol rather than mixing envelopes.

The system instruction has a different location in the two conversation protocols. For Anthropic, put it at the top level; messages contains conversation turns. A system role inside Anthropic messages is not a substitute.

{"model":"claude-sonnet-4.6","max_tokens":512,"system":"Write concise support replies.","messages":[{"role":"user","content":"Explain the maintenance window."}]}

For OpenAI Chat Completions, the initial instruction can be a message:

{"model":"gpt-5.4","messages":[{"role":"system","content":"Write concise support replies."},{"role":"user","content":"Explain the maintenance window."}]}

Tool and attachment turns

Keep tool declarations and tool results in the chosen API family's shape. Do not splice an Anthropic tool_result block into an OpenAI tool message or vice versa. Include image/document content only with a model that supports it. A base64 image URL, a PDF data URL and an Anthropic base64 document are distinct encodings.

The request builder can supply a tested starting shape. Extra model-specific fields should come from the selected model's supported configuration, not from a different model's example. See Messages endpoint, Chat endpoint and Responses endpoint.