Practical integration

Claude API: Messages setup

Send one Messages request, read every text block and check stop_reason. Claude Code uses the same gateway base and key, but its client configuration is covered separately.

Get a key for Claude API access and CLAUDE_AWS / CLAUDE_MAX routes

Create a key in the CLODEX dashboard and inspect the models available to it through /v1/models. Store the secret as CLODEX_API_KEY and the selected ID as CLODEX_MODEL. A public Claude Fable page does not guarantee access for every key.

For flagship coding and reasoning workloads (claude-opus-5-5, claude-sonnet-5-5, claude-opus-5), CLODEx provides native CLAUDE_AWS and CLAUDE_MAX upstream channels verified by independent model authenticity checkers without silent substitution. claude-fable-5 and claude-fable-5.1 are also distinct IDs: do not replace a dot with a hyphen or assume settings transfer between versions. For the terminal agent, use the Claude Code guide.

Create and check a key · Configure Claude Code

Address and required fields

Messages uses a top-level system field, not a message with role=system. This minimal request does not need a system instruction. Do not copy Chat Completions parameters into Messages based on similar names.

ItemValueCommon mistake
Raw HTTPhttps://clodex.xyz/v1/messagesSending a Messages body to /chat/completions.
Anthropic SDK base URLhttps://clodex.xyzDuplicating /v1, which the SDK adds itself.
Headersx-api-key; anthropic-version: 2023-06-01; content-type: application/jsonPutting the credential in the body instead of a header.
Bodymodel, max_tokens, messagesMissing max_tokens or an ID unavailable to the key.

One text request in Python

Use Python 3; the example needs only the standard library. Set CLODEX_API_KEY and CLODEX_MODEL in a protected environment. Running it creates a paid generation. max_tokens=128 bounds the output but does not make the request free.

An HTTP error causes urlopen to raise an exception. The example does not retry automatically. On a timeout, check request state and usage before sending the same generation again.

import json
import os
from urllib.request import Request, urlopen

payload = {
    "model": os.environ["CLODEX_MODEL"],
    "max_tokens": 128,
    "stream": False,
    "messages": [{"role": "user", "content": "Reply with one word: ready"}],
}
request = Request(
    "https://clodex.xyz/v1/messages",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "content-type": "application/json",
        "x-api-key": os.environ["CLODEX_API_KEY"],
        "anthropic-version": "2023-06-01",
    },
    method="POST",
)
with urlopen(request, timeout=60) as response:
    result = json.load(response)
if result.get("stop_reason") != "end_turn":
    raise RuntimeError(f"Incomplete text turn: {result.get('stop_reason')}")
blocks = result.get("content", [])
if not blocks or any(block.get("type") != "text" for block in blocks):
    raise RuntimeError("Expected text blocks only")
print("\n".join(block["text"] for block in blocks))
print(result.get("usage"))

Read all content blocks, not just the first

content is an array of blocks. Text may span several type=text blocks, which the example joins in order. It deliberately rejects other block types because this probe did not request tools.

end_turn indicates a finished turn. max_tokens indicates the output limit was reached, so do not treat that answer as complete. tool_use needs a dedicated tool handler, validated arguments and authorization; a model request alone is not permission to run a command.

Streaming requires a Messages event handler. A closed TCP connection is not a substitute for the expected message_stop event. Validate streaming separately after a normal request works.

Official Messages specification

Check prices and billing units for the exact ID

Check the tariff before sending and actual usage afterwards. Do not infer Fable 5 pricing from Fable 5.1. max_tokens is an output limit, not the number of tokens actually consumed.

CLODEX access is not a subscription to Anthropic’s website. The credential works with the CLODEX endpoint. Protocol compatibility does not establish support for every beta feature, context limit or an official partnership.

Current rates · Usage reference (Russian) · Messages troubleshooting (Russian)

Documentation and example scope

Connection settings follow CLODEx documentation. Examples target the stated protocol; they are not recorded inference results and do not promise identical features across models. A successful generation request can incur a charge.

Client configuration · API protocols

Frequently asked questions

Why can I not read choices[0] in a Messages response?

Messages returns content blocks. choices belongs to Chat Completions; using the wrong parser can fail even with HTTP 200.

Does every Claude alias from another guide work?

There is no such guarantee. Use an exact ID available to your CLODEX key and a protocol supported by that model.

What should I send support?

Time, HTTP status, model ID, stop_reason or error text, and a safe request ID. Remove keys and personal data; never send the complete x-api-key header.

Connect CLODEX API to your application

One key-management layer, compatible endpoints and several LLM families for apps, agents and developer tools.