anthropic
Anthropic's Messages API, as pure functions (llm-openai-compatible §OCP-W1, §OCP-W2).
In the namespace octomy::llm::wire.
Detailed description
OnlineAPIClient and OnlineSessionFacet built and read this form in place until 2026-10-20. The functions here are that code, moved without a change of behavior, so that each protocol has its form in one place and the clients only send, receive and emit. `testOnlineAPIClient` holds the behavior.
Function documentation
chatRequest
QByteArray anthropic::chatRequest(const octomy::llm::wire::anthropic::ChatRequest &request)
The body of request. A turn with neither images nor files is a plain string, as the requests always were. The files go after the content blocks of the last user turn. The maximum 0 or less is the default (§OCP-F4).
contentBlocks
QJsonArray anthropic::contentBlocks(const octomy::llm::driver::Message &message)
The content blocks of message: its images first, then its text. The Anthropic vision documentation is explicit: "Claude works best when images come before text" (opal-vision §OVR-9). An image that cannot be read is left out with a warning: the text still says what was asked.
describeFailure
QString anthropic::describeFailure(const QString &transportError, const QByteArray &body)
The user's text for a failed request. transportError is Qt's message ("server replied with status code 400"), which never says why. A well-formed error body says it in `error.message`, so that wins. A body of another shape, an upstream proxy's HTML page for example, is appended in part: an opaque HTTP error helps nobody. Only with no body at all is transportError the whole text.
fileBlock
QJsonObject anthropic::fileBlock(const QString &path)
The block of the file at path (§DR-7.1 FileAttach): an image or a document block, base64, for a known media type, else an inline text block with the file's name.
readCompletion
octomy::llm::wire::anthropic::Completion anthropic::readCompletion(int httpStatus, const QByteArray &body)
Read body, a response that is not a stream, of the status httpStatus: the text blocks joined, and the usage. A status that is not 2xx gives the error's message, or "HTTP n".
readStreamEvent
octomy::llm::wire::anthropic::StreamStep anthropic::readStreamEvent(const QString &event, const QString &data)
Read the event event of a stream, with its data: `message_start` (the prompt's tokens), `content_block_start` (the activity: "Thinking" for a thinking block), `content_block_delta` (text), `message_delta` (the answer's tokens), `message_stop` and `error`.