Use a CLODEx key and an exact model ID
Create a dedicated CLODEx key and select a model from the catalog available to that key, including gemini-4-neon (low, medium, high, xhigh), gemini-4-carbon (low, medium, high), gemini-4-argon and Gemini 3.8 Flash (gemini-3.8-flash). Neon, Carbon, Flash and Pro identify distinct variants; changing the name does not preserve assumptions about price, limits or capabilities.
A Google AI Studio key cannot authenticate this gateway request. Keep CLODEX_API_KEY in the protected server environment and put the selected ID in CLODEX_MODEL. Do not obtain credentials from user chat messages or expose them to browser code.
Why a native Google payload is different
Google generateContent uses contents and parts. This CLODEx example uses messages and reads choices. The request and error schemas are different. An OpenAI-compatible gateway does not make every Google SDK method portable by changing its hostname.
| Input or feature | Required change |
|---|---|
| Task text | Put it in messages[].content |
| Model name | Use the CLODEx route ID |
| Google Search or code execution | Verify an explicitly supported tool |
| Google generation settings | Map individual fields to the chosen endpoint |
Send a text request without an SDK
This example uses Python’s standard library and makes one billable request with no automatic retry. It accepts only a completed text answer. HTTP errors raise an exception. Do not publish the Authorization header or private request contents when recording diagnostics.
import json
import os
from urllib.request import Request, urlopen
payload = {
"model": os.environ["CLODEX_MODEL"],
"messages": [{"role": "user", "content": "Reply with one word: ready"}],
"stream": False,
}
request = Request(
"https://clodex.xyz/v1/chat/completions",
data=json.dumps(payload).encode("utf-8"),
headers={
"Authorization": "Bearer " + os.environ["CLODEX_API_KEY"],
"Content-Type": "application/json",
},
method="POST",
)
with urlopen(request, timeout=60) as response:
result = json.load(response)
choices = result.get("choices", [])
if not choices or choices[0].get("finish_reason") != "stop":
raise RuntimeError("Incomplete text response")
text = choices[0].get("message", {}).get("content")
if not isinstance(text, str) or not text.strip():
raise RuntimeError("Missing text")
print(text)
A fixture with a checkable answer
Compare A={"retries":0,"cache":false,"timeout":30} with B={"retries":2,"timeout":30}. Ask for changed fields only. The expected differences are a retries update and cache removal; timeout is unchanged.
This is a synthetic fixture, not a recorded model result. It catches a real data-processing mistake: treating 0 or false as absent. If software consumes the answer, validate JSON and allowed fields before storing it.
Images and tools are separate checks
Image analysis requires supported image input and the image itself. A private storage URL does not automatically deliver a file. Start with a non-sensitive image and confirm that your client uses the route’s supported format.
Asking for current news does not turn on Google Search. Search, execution and other tools must be explicitly supported and configured. Without such a tool call, the answer is not an online verification.
Keep fixtures and acceptance rules identical when comparing models. Read the usage log: answer length and reasoning can change the task’s cost even when the user question is unchanged.
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.
Frequently asked questions
Can I use a Google API key?
No. This route uses a CLODEx key. Direct Google API access is a separate account, endpoint and integration.
Does every generateContent option work?
No. Map it to the gateway schema first. Repeating an unsupported parameter does not make the route support it.
Why is HTTP 200 not enough?
In streaming, 200 starts delivery. The non-streaming example additionally checks finish_reason and a nonempty text result.