Claude API starter: Python and Node.js examples
A small starter for checking your CAK key and sending an Anthropic-format Messages request. It runs locally with Python or Node.js and does not require a third-party SDK.
Reviewed 2026-10-10 · Claude API documentation
What is included
cak_client.py: Python 3.10+ client using the standard library.cak-client.mjs: Node.js 20+ client using built-in fetch.README.md: setup, response examples and error handling.- Offline contract tests that exercise model listing, message format, errors and safe credential handling.
The examples list models before generation, bound response sizes and timeouts, reject an incorrect base URL, and do not automatically retry a generation request.
Configure locally
Set CAK_API_KEY to your private CAK credential in your terminal. Keep it outside version control. By default both clients use https://claudeapikey.dev. For a private test server, see the explicit localhost option in the README.
python cak_client.py models
node cak-client.mjs modelsChoose a model ID from the returned list and set CAK_MODEL. Listing models does not consume a generated response. The next command sends a short request that uses your active plan or prepaid access.
python cak_client.py message "Reply with OK."
node cak-client.mjs message "Reply with OK."The request format
POST /v1/messages
x-api-key: YOUR_PRIVATE_CAK_KEY
anthropic-version: 2023-06-01
content-type: application/json
{"model":"YOUR_MODEL_ID","max_tokens":64,
"messages":[{"role":"user","content":"Reply with OK."}]}The actual response text is generated by the selected model. These examples print text blocks, report status codes on failure and never print the credential.
Validation and limits
These are diagnostic examples, not a full agent framework. Offline tests cover the request contract and error behavior. The release validation record documents the separate live gateway check. It does not certify every model, tool feature, SDK or editor integration.
No automatic retry is used: a request that loses its response may already have reached the model. Decide whether it is safe to repeat your own workload.
Read the release validation record · Troubleshooting · Claude Code setup