OpenAI compatibility
codexkey has an OpenAI-compatible /v1/chat/completions endpoint, so Claude models are reachable from the OpenAI SDK and any OpenAI-compatible client.
Endpoint
http
POST https://api.codexkey.online/v1/chat/completionsAuthentication
Send the key in 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-5). |
messages | array | Yes | Array of messages; each has a role ("system", "user" or "assistant") and content. |
temperature | number | No | Sampling temperature, from 0 to 1. |
max_tokens | integer | No | Maximum tokens to generate. |
stream | boolean | No | Enable streaming via SSE. |
Field mapping
codexkey converts between the OpenAI and Anthropic formats on its own:
| OpenAI Field | Anthropic equivalent | Notes |
|---|---|---|
messages[role="system"] | system | System messages are pulled out and sent as a separate system parameter. |
max_tokens | max_tokens | Direct mapping. |
temperature | temperature | Direct mapping. |
stop | stop_sequences | Accepts string or array. |
choices[0].message | content | The response text is wrapped in the OpenAI format. |
choices[0].finish_reason | stop_reason | end_turn → stop, max_tokens → length. |
cURL Example
bash
curl https://api.codexkey.online/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_cdx_YOUR_KEY" \
-d '{
"model": "claude-sonnet-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.codexkey.online/v1",
)
response = client.chat.completions.create(
model="claude-sonnet-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)