What OpenAI-compatible means
An OpenAI-compatible API accepts familiar authentication headers, request objects and response shapes so existing SDKs can use a custom base URL. Compatibility is route-specific rather than absolute: a model may support Responses API, Chat Completions, images or only a subset of parameters. Test the contract your application actually uses.
CLODEX uses https://clodex.xyz/v1 as the OpenAI-compatible base URL. The authenticated /v1/models response is the source of truth for model identifiers available to a key. Avoid copying a model name from an old article or another account because access can differ by group and channel.
OpenAI Python SDK with a custom endpoint
The Python SDK accepts a base_url value directly. Begin with a short non-streaming request, log the request ID and confirm that the final response includes the expected terminal state before migrating a production workflow.
from openai import OpenAI
client = OpenAI(
api_key="clodex_YOUR_KEY",
base_url="https://clodex.xyz/v1",
)
result = client.responses.create(
model="gpt-5.6-terra",
input="Return a three-step deployment checklist",
)
print(result.output_text)
How to test an OpenAI-compatible API
A successful hello-world request is not enough for production acceptance. Long contexts, client cancellation, upstream timeouts and partially delivered streams expose different failure paths. Build a small contract suite and run it whenever the model, SDK or gateway version changes.
- Verify GET /v1/models with the same key used by the application.
- Test both JSON and SSE error handling, including non-200 responses.
- Confirm tool-call arguments are valid JSON before execution.
- Require response.completed or the documented terminal event.
- Measure latency, cached input and output cost on representative prompts.
Custom OpenAI endpoint security
Keep the API key on your backend, never in browser JavaScript or a distributed mobile bundle. Your backend should authenticate the end user, restrict allowed models, cap payload size and enforce a per-tenant budget before forwarding a request.
Log safe operational metadata such as request ID, model, latency and final status. Do not log Authorization headers or sensitive prompts by default. If a key is exposed, revoke it and create a replacement; deleting it from the latest source commit does not remove it from history.
Pin the SDK version used by production and review release notes before upgrades. Compatibility regressions often appear in streaming parsers, optional request fields or retry defaults rather than basic authentication. Run the same contract suite against the new version before rollout.
Frequently asked questions
What base URL should OpenAI SDKs use?
Use https://clodex.xyz/v1 with a CLODEX API key.
Does every model support every OpenAI parameter?
No. Compatibility depends on the route, model and upstream channel, so test required parameters before deployment.
Can I use Chat Completions and Responses API?
Both routes can be available, but support must be checked for the selected model.