Skip to content

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/completions

Authentication

Use the standard Authorization: Bearer header:

http
Authorization: Bearer sk_cdx_YOUR_KEY

Request Body

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g. claude-sonnet-4-20250514).
messagesarrayYesArray of messages with role ("system", "user", "assistant") and content.
temperaturenumberNoSampling temperature (0–1).
max_tokensintegerNoMaximum tokens to generate.
streambooleanNoEnable streaming via SSE.

Field Mapping

Claudexia automatically maps between OpenAI and Anthropic formats:

OpenAI FieldAnthropic EquivalentNotes
messages[role="system"]systemSystem messages are extracted and sent as the system parameter.
max_tokensmax_tokensDirect mapping.
temperaturetemperatureDirect mapping.
stopstop_sequencesAccepts string or array.
choices[0].messagecontentResponse content is wrapped in OpenAI format.
choices[0].finish_reasonstop_reasonend_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)