OpenAI Compatibility
Claudexia provides an OpenAI-compatible /v1/chat/completions endpoint, allowing you to use the OpenAI SDK or any OpenAI-compatible client with Claude models.
Endpoint
http
POST https://api.claudexia.tech/v1/chat/completionsAuthentication
Use the standard Authorization: Bearer header:
http
Authorization: Bearer sk_cdx_YOUR_KEYRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID (e.g. claude-sonnet-4-20250514). |
messages | array | Yes | Array of messages with role ("system", "user", "assistant") and content. |
temperature | number | No | Sampling temperature (0–1). |
max_tokens | integer | No | Maximum tokens to generate. |
stream | boolean | No | Enable streaming via SSE. |
Field Mapping
Claudexia automatically maps between OpenAI and Anthropic formats:
| OpenAI Field | Anthropic Equivalent | Notes |
|---|---|---|
messages[role="system"] | system | System messages are extracted and sent as the system parameter. |
max_tokens | max_tokens | Direct mapping. |
temperature | temperature | Direct mapping. |
stop | stop_sequences | Accepts string or array. |
choices[0].message | content | Response content is wrapped in OpenAI format. |
choices[0].finish_reason | stop_reason | end_turn → stop, max_tokens → length. |
cURL Example
bash
curl https://api.claudexia.tech/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_cdx_YOUR_KEY" \
-d '{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
}'Python Example (OpenAI SDK)
python
from openai import OpenAI
client = OpenAI(
api_key="sk_cdx_YOUR_KEY",
base_url="https://api.claudexia.tech/v1",
)
response = client.chat.completions.create(
model="claude-sonnet-4.5",
max_tokens=1024,
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in one paragraph."},
],
)
print(response.choices[0].message.content)