Files
Claude e6043b5d4d Add a C++ (libcurl) example and a curl request; state the exact host
A tester's Copilot wrote a C++ client against "ai.oathbreaker", which is the
MCP Registry name of the MCP server, not a host. Languages without an SDK had
no example to copy the URL from.

- cpp/hello.cpp: one Chat Completions request with libcurl and nlohmann/json,
  same behaviour as the JavaScript and Python examples (no redirects, no
  retries, incomplete answers are errors, key never printed).
- tests/cpp: builds the example with -Wall -Wextra -Werror and runs it against
  a local fixture server; a separate CI job installs the libraries.
- README: curl request and C++ section; the Base URL row says the host is
  oathbreaker.ai, with no api. subdomain, and that ai.oathbreaker/oathbreaker
  is a registry name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CfDjYxQRJkxzA91xGFyjpJ
2026-11-27 16:16:27 -03:00
..

C++ example (libcurl)

One Chat Completions request from C++17, using libcurl for HTTPS and nlohmann/json for JSON. Oathbreaker has no C++ SDK and needs none: send an HTTPS POST to the full URL below.

Request URL https://oathbreaker.ai/v1/chat/completions
Base URL https://oathbreaker.ai/v1
Headers Authorization: Bearer <key> and Content-Type: application/json
Key read from OATHBREAKER_API_KEY

The host is oathbreaker.ai. There is no api. subdomain. ai.oathbreaker/oathbreaker, which you may see in MCP directories, is the registry name of the Oathbreaker MCP server (the domain written backwards), not a hostname.

Build and run

Install a C++17 compiler, libcurl and nlohmann/json:

System Install
Ubuntu / Debian sudo apt install g++ libcurl4-openssl-dev nlohmann-json3-dev
macOS (Homebrew) brew install nlohmann-json (libcurl ships with macOS)
Windows (vcpkg) vcpkg install curl nlohmann-json

Then, from the repository root:

g++ -std=c++17 -O2 cpp/hello.cpp -o hello -lcurl
export OATHBREAKER_API_KEY=...   # your key; never commit it
./hello

On macOS with Homebrew, add -I"$(brew --prefix)/include" to the g++ line (or use clang++).

Running it with a real key makes one billable request with oathbreaker-glm-5.3, low reasoning effort and a 2,048-token output budget. It prints the answer and the returned token usage.

What it does

  • Sends only the request fields the API reference lists: model, messages, max_tokens, reasoning_effort and stream. The API rejects any other top-level field with HTTP 400.
  • Does not follow redirects and does not retry. A non-2xx status, a timeout (660 seconds) or a finish_reason other than stop is an error. Check your usage before sending the request again.
  • Never prints the key. The optional command-line argument replaces the base URL for the local tests only. Leave it out in real use, because the key is sent to whatever base URL is used.

To use another model, change "oathbreaker-glm-5.3" to any identifier in the models table. For streaming and function calling, see the API reference.

Test

node --test tests/cpp/*.test.mjs

The test builds the example (set CXX to choose the compiler) and runs it against a local fixture server, with no paid requests. It checks the URL, headers, request body, usage output, HTTP errors, incomplete answers and that redirects are not followed.